fileprocessor.cpp
907 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <QDebug>
#include "fileprocessor.h"
FileProcessor::FileProcessor()
{
}
bool FileProcessor::folderExist(const QString &path){
QDir qdir(path);
qDebug() << "check path" << path;
return qdir.exists();
}
bool FileProcessor::fileExist(const QString &path_file){
QFile qfile(path_file);
return qfile.exists();
}
bool FileProcessor::detectUSB(QString &usbPath){
int curUsbNum=0xff;
bool usbMountErr = false;
QString checkUsbName[3] = {
"sda",
"sdb",
"sdc"
};
for(int i =2;i >=0 ; i--){
if(folderExist(QString("/sys/block/").append(checkUsbName[i]))){
if(folderExist(QString("/mnt/%111").arg(checkUsbName[i]))){
usbPath = QString("/mnt/%111").arg(checkUsbName[i]);
return true;
}
break;
}
}
qDebug() << "usb detect fail";
return false;
}