| 1 | = FindFlashDrive = |
| 2 | Search for plugged in flash drives |
| 3 | |
| 4 | {{{ |
| 5 | bool FindFlashDrive(std::vector<string>& pathList, bool checkForUnmounted = false); |
| 6 | }}} |
| 7 | |
| 8 | == Parameters == |
| 9 | |
| 10 | pathList = a vector of std::string to be populated with the result paths found |
| 11 | checkForUnmounted = If true will also check if drive is unmounted and mount it |
| 12 | |
| 13 | == Return Value == |
| 14 | |
| 15 | This function returns true if any flash drive found/mounted. |
| 16 | |
| 17 | == Remarks == |
| 18 | |
| 19 | The function reads /proc/mounts to obtain the result. |
| 20 | |
| 21 | == Examples == |
| 22 | |
| 23 | {{{ |
| 24 | int result; |
| 25 | char writeFilePath[180]; |
| 26 | #if ARM64 |
| 27 | vector<string> pathList; |
| 28 | if(FindFlashDrive(pathList, true) == false) { |
| 29 | result = -1; |
| 30 | } else { |
| 31 | result = 0; |
| 32 | // pathList item will already have a trailing slash |
| 33 | // so writeFilePath will become something like "/run/media/sda1/data.csv" |
| 34 | sprintf_s(writeFilePath, "%sdata.csv", pathList[0].c_str()); |
| 35 | } |
| 36 | #else |
| 37 | result = system("mount -t vfat /dev/sda1 /mnt/fl1"); |
| 38 | strcpy(writeFilePath, "/mnt/fl1/data.csv"); |
| 39 | #endif |
| 40 | if(result != 0) { |
| 41 | DrawErrorBox("Error mounting USB drive", 2); |
| 42 | } else { |
| 43 | // ... Write data to flash drive |
| 44 | |
| 45 | #if ARM64 |
| 46 | UnmountDirectory(pathList[0].c_str()); |
| 47 | #else |
| 48 | system("umount /mnt/fl1"); |
| 49 | #endif |
| 50 | } |
| 51 | |
| 52 | |
| 53 | |
| 54 | }}} |
| 55 | |
| 56 | |
| 57 | == See Also == |
| 58 | |
| 59 | |
| 60 | |