The Win32 API function CreateFile()
opens a “file” using a path, but this path can also open a volume (e.g. \.D:
), or a physical drive (e.g. \.PHYSICALDRIVE2
), or console handles, “changer drivers”, or even tape. This remembers UNIX, but different to UNIX, if I use GetFileSize()
on a volume/drive, it fails with “The parameter is incorrect”, being necessary to use DeviceIoControl()
.
But how can I know if the handle is a regular file or a device? Or even tape?
I fear the only safe way is parsing the actual path beforehand and restricting to known formats.