FindFirstFile and FindNextFile found direcotry which I don't have (direcotry with dot name) (help)

  • Thread starter Thread starter Striebrovlas
  • Start date Start date
S

Striebrovlas

Guest
When I use FindFirstFile and FindNextFile and it detect direcotry, it allways detect one directory with "." and second directory with ".." for evry directory. How to avoid detect this non existing direcotries?

Here is how I use FindFirsFile

void FilePath_2::WinWatchDir(std::wstring path)
{
WIN32_FIND_DATA ffd;
HANDLE hFind = INVALID_HANDLE_VALUE;
LARGE_INTEGER filesize;
FILETIME fTime;
DWORD dwError = 0;

std::wstring dir = path + L"\\*";
std::wstring apath = L"";

hFind = FindFirstFile(dir.c_str(), &ffd);
if (INVALID_HANDLE_VALUE == hFind)
{
std::wcout << "[ WinWatchDir ] FindFirstFile ERROR 1 : " << GetLastError() <<
" For " << dir <<std::endl;
return;
}
std::tm tmT;
do
{
if (
!(ffd.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY)
)
{
if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
std::wstring fdir(ffd.cFileName);
std::wcout << "DIRECTORY : " << fdir << std::endl;
if (fdir == L"." || fdir == L"..")
{
continue;
}
// ...
}
else
{
// ...
}
}
} while (FindNextFile(hFind, &ffd) != 0);

dwError = GetLastError();
if (dwError != ERROR_NO_MORE_FILES)
{
std::wcout << "[ WinWatchDir ] FindFirstFile ERROR 2 : " << dwError << std::endl;
}

FindClose(hFind);
}

Continue reading...
 
Back
Top