summaryrefslogtreecommitdiff
path: root/zen/FindFilePlus/find_file_plus.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:20:50 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:20:50 +0200
commit7e706cf64654aea466c059c307e5723e2423ed5d (patch)
treee85f0d28d7c81b6d21419fc38e1a654cca2212b1 /zen/FindFilePlus/find_file_plus.cpp
parent5.5 (diff)
downloadFreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.tar.gz
FreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.tar.bz2
FreeFileSync-7e706cf64654aea466c059c307e5723e2423ed5d.zip
5.6
Diffstat (limited to 'zen/FindFilePlus/find_file_plus.cpp')
-rw-r--r--zen/FindFilePlus/find_file_plus.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/zen/FindFilePlus/find_file_plus.cpp b/zen/FindFilePlus/find_file_plus.cpp
index 19f43998..a6e82617 100644
--- a/zen/FindFilePlus/find_file_plus.cpp
+++ b/zen/FindFilePlus/find_file_plus.cpp
@@ -107,13 +107,13 @@ bool findplus::initDllBinding() //evaluate in ::DllMain() when attaching process
class findplus::FileSearcher
{
public:
- FileSearcher(const wchar_t* dirname); //throw FileError
+ FileSearcher(const wchar_t* dirname); //throw NtFileError
~FileSearcher();
- void readDir(FileInformation& output); //throw FileError
+ void readDir(FileInformation& output); //throw NtFileError
private:
- template <class QueryPolicy> void readDirImpl(FileInformation& output); //throw FileError
+ template <class QueryPolicy> void readDirImpl(FileInformation& output); //throw NtFileError
UNICODE_STRING dirnameNt; //it seems hDir implicitly keeps a reference to this, at least ::FindFirstFile() does no cleanup before ::FindClose()!
HANDLE hDir;
@@ -136,7 +136,7 @@ FileSearcher::FileSearcher(const wchar_t* dirname) :
dirnameNt.Length = 0;
dirnameNt.MaximumLength = 0;
- zen::ScopeGuard guardConstructor = zen::makeGuard([&]() { this->~FileSearcher(); });
+ zen::ScopeGuard guardConstructor = zen::makeGuard([&] { this->~FileSearcher(); });
//--------------------------------------------------------------------------------------------------------------
//convert dosFileName, e.g. C:\Users or \\?\C:\Users to ntFileName \??\C:\Users
@@ -222,11 +222,11 @@ struct DirQueryFileId
inline
-void FileSearcher::readDir(FileInformation& output) { readDirImpl<DirQueryFileId>(output); } //throw FileError
+void FileSearcher::readDir(FileInformation& output) { readDirImpl<DirQueryFileId>(output); } //throw NtFileError
template <class QueryPolicy>
-void FileSearcher::readDirImpl(FileInformation& output) //throw FileError
+void FileSearcher::readDirImpl(FileInformation& output) //throw NtFileError
{
//although FILE_ID_FULL_DIR_INFORMATION should suffice for our purposes, there are problems on Windows XP for certain directories, e.g. "\\Vboxsvr\build"
//making NtQueryDirectoryFile() return with STATUS_INVALID_PARAMETER while other directories, e.g. "C:\" work fine for some reason
@@ -335,6 +335,11 @@ void FileSearcher::readDirImpl(FileInformation& output) //throw FileError
output.fileAttributes = dirInfo.FileAttributes;
output.shortNameLength = dirInfo.FileNameLength / sizeof(TCHAR); //FileNameLength is in bytes!
+ if (dirInfo.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) //analog to FindFirstFile(), confirmed for Win XP and Win 7
+ output.reparseTag = dirInfo.EaSize; //
+ else
+ output.reparseTag = 0;
+
if (dirInfo.FileNameLength + sizeof(TCHAR) > sizeof(output.shortName)) //this may actually happen if ::NtQueryDirectoryFile() decides to return a
throw NtFileError(STATUS_BUFFER_OVERFLOW); //short name of length MAX_PATH + 1, 0-termination is not required!
@@ -352,7 +357,7 @@ FindHandle findplus::openDir(const wchar_t* dirname)
{
try
{
- return new FileSearcher(dirname); //throw FileError
+ return new FileSearcher(dirname); //throw NtFileError
}
catch (const NtFileError& e)
{
@@ -366,7 +371,7 @@ bool findplus::readDir(FindHandle hnd, FileInformation& output)
{
try
{
- hnd->readDir(output); //throw FileError
+ hnd->readDir(output); //throw NtFileError
return true;
}
catch (const NtFileError& e)
bgstack15