-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathMyCompress.cpp
54 lines (50 loc) · 1.39 KB
/
MyCompress.cpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "MyCompress.h"
MyCompress::MyCompress()
{
m_App_floder = QCoreApplication::applicationDirPath() + COMPRESSPATHSEG;
}
bool MyCompress::UnCompress(QString unCompressFile, QString unCompress_floder)
{
if(!isDirExist(unCompress_floder))
return false;
bool is_Support = true;
int point_index = unCompressFile.lastIndexOf(".");
QString extent_name = unCompressFile.mid(point_index).trimmed();
// is_Support = extent_name.compare(".Z", Qt::CaseInsensitive) == 0;
if(is_Support)
{
if(MYCOMPRESS_H_isLiux)
{
QProcess myProcess;
QString app_path = "uncompress";
QStringList param;
param << "-d" << "-f" << unCompressFile;
myProcess.start(app_path, param);
return myProcess.waitForFinished();
}
else
{
QProcess myProcess;
QString app_path = m_App_floder.append("gzip.exe");
QStringList param;
param << "-d" << "-f" << unCompressFile;
myProcess.start(app_path, param);
return myProcess.waitForFinished();
}
}
return false;
}
bool MyCompress::isDirExist(QString fullPath)
{
QDir dir(fullPath);
if(dir.exists())
{
return true;
}
else
{
bool ok = dir.mkpath(fullPath);//Create a multi-level directory
return ok;
}
return false;
}