Hack Forums
[C] Win32 way to determine if a file is not accessible/private - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C] Win32 way to determine if a file is not accessible/private (/showthread.php?tid=1825976)



Win32 way to determine if a file is not accessible/private - gretty - Oct 16, 2011

Hello

In win32 c++; is there a way to determine if a folder/file is accessible? You know how if you try to access a certain folder in the C:/Windows directory & you will get a popup saying "This folder is not accessible".

Maybe there is a file attribute constant that signifies that the file is private? Maybe something like FILE_ATTRIBUTE_PRIVATE?

Code
WIN32_FIND_DATA dirData;

while (FindNextFile( dir, &dirData ) != 0 )
{
    // I made the following constant up
    if ( fileData.dwFileAttributes & FILE_ATTRIBUTE_PRIVATE )
    {
        // file is inaccessible
    }
}

Or is the only way to know by going:

Code
dir = FindFirstFileEx( (LPCTSTR)directory.c_str(), FindExInfoStandard, &dirData, FindExSearchNameMatch, NULL, 0 );
                        
if ( dir == ??? ) { the file is inaccessible }



* - -Felix- - Oct 16, 2011

Well, im not sure what you mean with private. But you are actually giving FindNextFile() a WIN32_FIND_DATA structure as output parameter. And as you can see here : http://msdn.microsoft.com/en-us/library/windows/desktop/aa365740(v=vs.85).aspx

There are some things that you can find out about the file by checking it after calling FindNextFile().
I don't think that there actually noticeable more to find out about a file, because even this function http://msdn.microsoft.com/en-us/library/aa363788(v=VS.85).aspx would not tell you more than the WIN32_FIND_DATA-struct.