linux 查看u盘挂载目录,Linux C++ 获取U盘挂载路径

  • Post author:
  • Post category:linux


#include #endif

bool isFolderExists(const string& strFolder)

{

#ifndef _WIN32

DIR *pDir = opendir(strFolder.c_str());

if(pDir){

closedir(pDir);

return true;

}

#endif

return false;

}

bool isParentNode(const string& strNode)

{

#ifndef _WIN32

long nTotal = 0;

char cData[2048] = {0};

char cStram[2048] = {0};

sprintf(cStram, “lsblk -m /dev/%s”, strNode.c_str());

FILE *fstream = popen(cStram, “r”);

if(fstream){

while(fgets(cData, sizeof(cData), fstream)){

nTotal++;

}

pclose(fstream);

}

if(nTotal > 2){

return true;

}

#endif

return false;

}

void EnumDevicePath(const string&am