FindFlashDrive 825gen2
Search for plugged in flash drives
bool FindFlashDrive(std::vector<string>& pathList, bool checkForUnmounted = false);
Parameters
pathList = a vector of std::string to be populated with the result paths found checkForUnmounted = If true will also check if drive is unmounted and mount it
Return Value
This function returns true if any flash drive found/mounted.
Remarks
The function reads /proc/mounts to obtain the result.
Examples
int result; char usbFilePath[180]; #if ARM64 vector<string> pathList; // pass true to mount the drive if a drive found but not mounted if(FindFlashDrive(pathList, true) == false) { result = -1; } else { result = 0; // pathList item will already have a trailing slash // so usbFilePath will become something like "/run/media/sda1/data.csv" sprintf_s(usbFilePath, "%sdata.csv", pathList[0].c_str()); } #else result = system("mount -t vfat /dev/sda1 /mnt/fl1"); strcpy(usbFilePath, "/mnt/fl1/data.csv"); #endif if(result != 0) { DrawErrorBox("Error mounting USB drive", 2); } else { // ... Write data to flash drive, or read from the drive #if ARM64 UnmountDirectory(pathList[0].c_str()); #else system("umount /mnt/fl1"); #endif }
See Also
Last modified
6 months ago
Last modified on 05/17/24 12:51:50
Note:
See TracWiki
for help on using the wiki.