Changes between Initial Version and Version 1 of Docs/Prog/Manual/ApplicationLibraries/lib825ev/File/FindFlashDrive


Ignore:
Timestamp:
05/17/24 11:53:39 (6 months ago)
Author:
Don Wilson
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Docs/Prog/Manual/ApplicationLibraries/lib825ev/File/FindFlashDrive

    v1 v1  
     1= FindFlashDrive =
     2Search for plugged in flash drives
     3
     4{{{
     5bool FindFlashDrive(std::vector<string>& pathList, bool checkForUnmounted = false);
     6}}}
     7
     8== Parameters ==
     9
     10pathList = a vector of std::string to be populated with the result paths found
     11checkForUnmounted = If true will also check if drive is unmounted and mount it
     12
     13== Return Value ==
     14
     15This function returns true if any flash drive found/mounted.
     16
     17== Remarks ==
     18
     19The 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