bool CFindFileBase::Close() throw()
{ if (_handle == INVALID_HANDLE_VALUE) returntrue; if (!::FindClose(_handle)) returnfalse;
_handle = INVALID_HANDLE_VALUE; returntrue;
}
/* WinXP-64 FindFirstFile(): "" - ERROR_PATH_NOT_FOUND folder\ - ERROR_FILE_NOT_FOUND \ - ERROR_FILE_NOT_FOUND c:\ - ERROR_FILE_NOT_FOUND c: - ERROR_FILE_NOT_FOUND, if current dir is ROOT ( c:\ ) c: - OK, if current dir is NOT ROOT ( c:\folder ) folder - OK
\\ - ERROR_INVALID_NAME \\Server - ERROR_INVALID_NAME \\Server\ - ERROR_INVALID_NAME \\Server\Share - ERROR_BAD_NETPATH \\Server\Share - ERROR_BAD_NET_NAME (Win7). !!! There is problem : Win7 makes some requests for "\\Server\Shar" (look in Procmon), when we call it for "\\Server\Share" \\Server\Share\ - ERROR_FILE_NOT_FOUND \\?\UNC\Server\Share - ERROR_INVALID_NAME \\?\UNC\Server\Share - ERROR_BAD_PATHNAME (Win7) \\?\UNC\Server\Share\ - ERROR_FILE_NOT_FOUND \\Server\Share_RootDrive - ERROR_INVALID_NAME \\Server\Share_RootDrive\ - ERROR_INVALID_NAME c:\* - ERROR_FILE_NOT_FOUND, if thare are no item in that folder
*/
/* WinXP-64 FindFirstStream(): "" - ERROR_PATH_NOT_FOUND folder\ - OK folder - OK \ - OK c:\ - OK c: - OK, if current dir is ROOT ( c:\ ) c: - OK, if current dir is NOT ROOT ( c:\folder ) \\Server\Share - OK \\Server\Share\ - OK
/* WinXP-64 GetFileAttributes(): If the function fails, it returns INVALID_FILE_ATTRIBUTES and use GetLastError() to get error code
\ - OK C:\ - OK, if there is such drive, D:\ - ERROR_PATH_NOT_FOUND, if there is no such drive,
C:\folder - OK C:\folder\ - OK C:\folderBad - ERROR_FILE_NOT_FOUND
\\Server\BadShare - ERROR_BAD_NETPATH \\Server\Share - WORKS OK, but MSDN says: GetFileAttributes for a network share, the function fails, and GetLastError returns ERROR_BAD_NETPATH. You must specify a path to a subfolder on that share.
*/
/* if path is "c:" or "c::" then CFileInfo::Find() returns name of current folder for that disk
so instead of absolute path we have relative path in Name. That is not good in some calls */
/* In CFileInfo::Find() we want to support same names for alt streams as in CreateFile(). */
/* CFileInfo::Find() We alow the following paths (as FindFirstFile): C:\folder c: - if current dir is NOT ROOT ( c:\folder )
also we support paths that are not supported by FindFirstFile: \ \\.\c: c:\ - Name will be without tail slash ( c: ) \\?\c:\ - Name will be without tail slash ( c: ) \\Server\Share \\?\UNC\Server\Share
c:\folder:stream - Name = folder:stream c:\:stream - Name = :stream c::stream - Name = c::stream
*/
bool CFileInfo::Find(CFSTR path)
{ #ifdef SUPPORT_DEVICE_FILE if (IsDevicePath(path))
{
ClearBase();
Name = path + 4;
IsDevice = true;
NIO::CInFile inFile; // ::OutputDebugStringW(path); if (!inFile.Open(path)) returnfalse; // ::OutputDebugStringW(L"---"); if (inFile.SizeDefined)
Size = inFile.Size; returntrue;
} #endif
#ifdefined(_WIN32) && !defined(UNDER_CE)
int colonPos = FindAltStreamColon(path); if (colonPos >= 0 && path[(unsigned)colonPos + 1] != 0)
{
UString streamName = fs2us(path + (unsigned)colonPos);
FString filePath (path);
filePath.DeleteFrom(colonPos); /* we allow both cases: name:stream name:stream:$DATA
*/ constunsigned kPostfixSize = 6; if (streamName.Len() <= kPostfixSize
|| !StringsAreEqualNoCase_Ascii(streamName.RightPtr(kPostfixSize), ":$DATA"))
streamName += ":$DATA";
bool isOk = true;
if (IsDrivePath2(filePath) &&
(colonPos == 2 || colonPos == 3 && filePath[2] == '\\'))
{ // FindFirstFile doesn't work for "c:\" and for "c:" (if current dir is ROOT)
ClearBase();
Name.Empty(); if (colonPos == 2)
Name = filePath;
} else
isOk = Find(filePath);
if (isOk)
{
Attrib &= ~(FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT);
Size = 0;
CStreamEnumerator enumerator(filePath); for (;;)
{
CStreamInfo si; bool found; if (!enumerator.Next(si, found)) returnfalse; if (!found)
{
::SetLastError(ERROR_FILE_NOT_FOUND); returnfalse;
} if (si.Name.IsEqualTo_NoCase(streamName))
{ // we delete postfix, if alt stream name is not "::$DATA" if (si.Name.Len() > kPostfixSize + 1)
si.Name.DeleteFrom(si.Name.Len() - kPostfixSize);
Name += us2fs(si.Name);
Size = si.Size;
IsAltStream = true; returntrue;
}
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.