- 判断目录是否存在:
-
QString proFile(t_path);
proFile.append("/dir");
QFileInfo proFileInfo(proFile);
if(proFileInfo.exists()) {
//
} - 新建目录
-
QString t_tmpDir(theDir);
t_tmpDir.append("/tmp"); QFileInfo t_tmpDirInfo(t_tmpDir);
QDir* t_dir = new QDir;
if(t_tmpDirInfo.isDir()) {
QString t_oldTmpDir(theDir);
QDate date;
QTime time;
QDateTime dt;
dt.setTime(time.currentTime());
dt.setDate(date.currentDate());
QString currentDate = dt.toString("yyyy-MM-dd-hh-mm-ss");
t_oldTmpDir.append("/");
t_oldTmpDir.append(currentDate);
t_dir->rename(t_tmpDir, t_oldTmpDir);
}
t_dir->mkdir(t_tmpDir); - 读写文件:
-
FILE* fp = fopen(t_pro.toStdString().c_str(), "r");
int t_count = 0;
fscanf(fp, "%*d%*d%*d%*d%d", &t_count);
fclose(fp);