Hi all! Is there a Windows function that check me if it's a directory? If it doesn't exist, is there a mode?
Hi all! Is there a Windows function that check me if it's a directory? If it doesn't exist, is there a mode?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Or even more succintly
PathIsDirectory Function (Windows)
thank you both!
For other user that they will have same problem, this is the solution:
Code:... isDirectory = GetFileAttributes( struttura.cFileName ); if ( isDirectory == FILE_ATTRIBUTE_DIRECTORY ) cout << "it's a dir" << endl; else cout << "it isn't a dir" << endl; ....
It's still wrong -> File Attribute Constants (Windows)
The result is a bit-mask, so your example would fail for a hidden directory.
You need to do
Code:isDirectory = GetFileAttributes( struttura.cFileName ); if ( ( isDirectory & FILE_ATTRIBUTE_DIRECTORY ) == FILE_ATTRIBUTE_DIRECTORY )
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.