So, I'm trying to write an executable that needs to access the drives connected to a device (Read/Write). My problem however is finding a process that can relay to me all the possible drives/partitions programmatically and provide their file paths. I can do it on Windows (kinda) via things like "GetLogicalDrives" (for lettered drives) or alternatives... And I can do it on Linux with things like "fdisk -l" and such. But, I can't seem to figure out how to get a program readable list that will work on Windows and Linux (running via Wine). I basically want a 2D array if I can, of drive paths that I could use with Windows function calls (that Wine will redirect to Linux calls when needed) like "FindFirstFileA" and such.
Will I have to hard code each case? And if so, what are the cases? What are all the possible default drive paths on Linux? Will I need to programmatically mount them?
eg:
Code: Select all
bool DoesDriveExist(char* szDrivePath);
void ProcessDrive(char* szDrivePath);
ProcessDrive("C:\\"); // Note the different drive names
ProcessDrive("\\dev\\sda1");
ProcessDrive("\\dev\\sda2");
ProcessDrive("\\dev\\sdb1");
ProcessDrive("\\dev\\hdb1");
ProcessDrive("\\root\\");
// etc...
bool DoesDriveExist(char* szDrivePath)
{
BOOL bResult = false;
// GetFileAttributes or Drive/Partition compliant equivalent
...
return bResult;
}
void ProcessDrive(char* szDrivePath)
{
if(DoesDriveExist(szDrivePath))
{
// Do Stuff eg. FindFirstFileA(szDrivePath, FileData);
...
}
}
Thanks in advance for any help or insight y'all can provide.