← Back to team overview

linuxdcpp-team team mailing list archive

[Bug 653295] Re: Support Win32 Symbolic Links when indexing share

 

Directory symbolic link already work fine so I will leave those alone.
Not tested hardlinks or junctions, but I think they should work.


I came up with a solution (not fully tested yet). Its not a very clean solution, since it basically exploits the fact that CreateFile will resolve the reprase points, and then I can use the resulting file HANDLE to pull other data about the file (eg the actual path using GetFinalPathNameByHandle).


The basic concept is to have the following function that is called
everytime the iterator gets a new file to overwrite some of the fields
in the data struct, and also store a full path to the target file (which
can then be used elsewhere as needed).


void FileFindIter::updateData()
{
	//only file symbolic links, not any other type
	if(!data.isDirectory() && (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && (data.dwReserved0 & IO_REPARSE_TAG_SYMLINK))
	{
		//todo, error check. This may fail if the links target can not be accessed for some reason (eg simply doesnt exist).
		HANDLE file = CreateFileW((Text::toT(parentDir) + data.cFileName).c_str(), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0);
		//path
		char path[MAX_PATH];
		GetFinalPathNameByHandleA(file, path, MAX_PATH, FILE_NAME_NORMALIZED);
		data.linkTargetPath = path;
		//size
		data.nFileSizeLow = GetFileSize(file, &data.nFileSizeHigh);
                //time
		GetFileTime(file, &data.ftCreationTime, &data.ftLastAccessTime, &data.ftLastWriteTime);
		//done
		CloseHandle(file);
	}
}


It seems to work, although I need todo a major cleanup of a bunch of stuff I left lying around, and am not really sure this is an acceptable solution.

-- 
Support Win32 Symbolic Links when indexing share
https://bugs.launchpad.net/bugs/653295
You received this bug notification because you are a member of
Dcplusplus-team, which is subscribed to DC++.

Status in DC++: Confirmed

Bug description:
I want to share a directory which contains a number of files linked to via symbolic links (http://msdn.microsoft.com/en-us/library/aa365680%28VS.85%29.aspx). However the index/hashing thing seems to fail, skip, or otherwise just not work on large numbers of the files. The files physical locations the links target are spread across a number of physical locations (including some shared network locations) and also includes some personal files in the same directory (hence sym linking the files I want and not sharing the directory) that I do not wish to share.

Is there anything I can do about this? Symbolic links are supposed to be a file system feature and transparent so I don't really see why this is failing to work :(





References