How to check with WINAPI file path is disk or file or directory?
A:
Could try FindFirstFile:
http://msdn.microsoft.com/en-us/library/aa364418%28v=VS.85%29.aspx
Once you have the find data (passed as the 2nd argument to that function):
if(result->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
//file is a directory
}
else
{
//file is not a directory
}
Also, to see if something is a volume, could try something like:
if(result->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
{
if(result->dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT)
{
//path is a volume; try using GetVolumeNameForVolumeMountPoint for info
}
}
HTH
cubic1271
2010-08-20 08:27:32
Something else that may be useful: http://api.farmanager.com/en/winapi/win32_find_data.html [explanation of WIN32_FIND_DATA structure].
cubic1271
2010-08-20 08:29:44
But how to check is file path a disk?
na1s
2010-08-20 08:32:32
See if the path has a drive letter in front of it? All UNC's take the form "\\server\share\file_path" No drive letter.
JustBoo
2010-08-20 15:58:13
+1
A:
See if the path has a drive letter in front of it? All UNC's take the form "\\server\share\file_path" No drive letter.
Out of curiousity I looked this up. Based on this MSDN article Naming Files, Paths, and Namespaces, it seems my advice is exactly how it says it should be done.
JustBoo
2010-08-20 15:58:43