Информация об изменениях

Сообщение Re[2]: bug с сетевым диском от 14.01.2022 21:17

Изменено 14.01.2022 21:18 maks1180

Re[2]: bug с сетевым диском
S>Код показывай, без этого непонятно, куда смотреть, особенно после замечания про nFileIndex.

void PrintTime(const FILETIME *lpFileTime, LPCSTR name)
{
SYSTEMTIME t = {0};
if (::FileTimeToSystemTime(lpFileTime, &t)==0) {
printf("ERROR %u of FileTimeToSystemTime() \n", (int)::GetLastError());
}
printf("%s = %4u-%02u-%02u %02u:%02u:%02u.%03u \n", name, (int)t.wYear, (int)t.wMonth, (int)t.wDay, (int)t.wHour, (int)t.wMinute, (int)t.wSecond, (int)t.wMilliseconds);
}

void PrintFileTime(LPCSTR name)
{
HANDLE h = ::CreateFileA(name, 0, // GENERIC_READ
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (h==INVALID_HANDLE_VALUE) {
printf("ERROR %u open file %s \n", (int)::GetLastError(), name);
return;
}

printf("%s \n", name);

FILETIME t1 = {0}, t2, t3;
BY_HANDLE_FILE_INFORMATION info = {0};

if (::GetFileTime(h, &t1, &t2, &t3)==0) {
printf("ERROR %u of GetFileTime() \n", (int)::GetLastError());
}

if (::GetFileInformationByHandle(h, &info)==0) {
printf("ERROR %u of GetFileInformationByHandle() \n", (int)::GetLastError());
}
else {
printf("attr=%X, size=%u %u \n", (int)info.dwFileAttributes, (int)info.nFileSizeLow, (int)info.nFileSizeHigh);
unsigned long long int v = info.nFileIndexHigh; v = v << 32; v += info.nFileIndexLow;
printf("index=%X %X = %u %u \n", (int)info.nFileIndexLow, (int)info.nFileIndexHigh, (int)info.nFileIndexLow, (int)info.nFileIndexHigh);
printf("index=%I64llu \n", v);
PrintTime(&info.ftLastAccessTime, "LastAccessTime");
PrintTime(&t2, "LastAccessTime");
PrintTime(&info.ftLastWriteTime, "LastWriteTime ");
PrintTime(&t3, "LastWriteTime ");
PrintTime(&info.ftCreationTime, "CreationTime ");
PrintTime(&t1, "CreationTime ");

}

printf("\n");

::CloseHandle(h);
}

#define NETPATH "Z:\\T_8T\\xxx\\xxx\\Tester\\"

int main()
{
PrintFileTime(NETPATH"Debug");
PrintFileTime(NETPATH"Debug\\01.txt");
return 1;
}
Re[2]: bug с сетевым диском
S>Код показывай, без этого непонятно, куда смотреть, особенно после замечания про nFileIndex.

void PrintTime(const FILETIME *lpFileTime, LPCSTR name)
{
SYSTEMTIME t = {0};
if (::FileTimeToSystemTime(lpFileTime, &t)==0) {
printf("ERROR %u of FileTimeToSystemTime() \n", (int)::GetLastError());
}
printf("%s = %4u-%02u-%02u %02u:%02u:%02u.%03u \n", name, (int)t.wYear, (int)t.wMonth, (int)t.wDay, (int)t.wHour, (int)t.wMinute, (int)t.wSecond, (int)t.wMilliseconds);
}

void PrintFileTime(LPCSTR name)
{
HANDLE h = ::CreateFileA(name, 0, // GENERIC_READ
FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (h==INVALID_HANDLE_VALUE) {
printf("ERROR %u open file %s \n", (int)::GetLastError(), name);
return;
}

printf("%s \n", name);

FILETIME t1 = {0}, t2, t3;
BY_HANDLE_FILE_INFORMATION info = {0};

if (::GetFileTime(h, &t1, &t2, &t3)==0) {
printf("ERROR %u of GetFileTime() \n", (int)::GetLastError());
}

if (::GetFileInformationByHandle(h, &info)==0) {
printf("ERROR %u of GetFileInformationByHandle() \n", (int)::GetLastError());
}
else {
printf("attr=%X, size=%u %u \n", (int)info.dwFileAttributes, (int)info.nFileSizeLow, (int)info.nFileSizeHigh);
unsigned long long int v = info.nFileIndexHigh; v = v << 32; v += info.nFileIndexLow;
printf("index=%X %X = %u %u \n", (int)info.nFileIndexLow, (int)info.nFileIndexHigh, (int)info.nFileIndexLow, (int)info.nFileIndexHigh);
printf("index=%I64llu \n", v);
PrintTime(&info.ftLastAccessTime, "LastAccessTime");
PrintTime(&t2, "LastAccessTime");
PrintTime(&info.ftLastWriteTime, "LastWriteTime ");
PrintTime(&t3, "LastWriteTime ");
PrintTime(&info.ftCreationTime, "CreationTime ");
PrintTime(&t1, "CreationTime ");

}

printf("\n");

::CloseHandle(h);
}

#define NETPATH "Z:\\T_8T\\xxx\\xxx\\Tester\\"

int main()
{
PrintFileTime(NETPATH"Debug");
PrintFileTime(NETPATH"Debug\\01.txt");
return 1;
}