-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathziptool.cpp
67 lines (57 loc) · 1.32 KB
/
ziptool.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
55
56
57
58
59
60
61
62
63
64
65
66
67
#pragma once
#include "stdafx.h"
#include <string>
#include "ZipTool.h"
#include <direct.h>
#include "ZLibWrap.h"
#ifdef _DEBUG
#pragma comment(lib, "ZlibWraplibd.lib")
#else
#pragma comment(lib, "ZlibWraplib.lib")
#endif
bool ZipTool::extractDir(std::string fileCompressed, std::string dir)
{
return ZipExtract(fileCompressed.c_str(), dir.c_str()) == TRUE;
}
bool ZipTool::compressDir(std::string fileCompressed, std::string dir, bool deleteDir)
{
return ZipCompress(dir.c_str(), fileCompressed.c_str(), true) == TRUE;
}
void ZipTool::deleteFolder(const std::string &folderFullPath)
{
if (folderFullPath.length()==0)
{
RemoveDirectory(folderFullPath.c_str());
return;
}
CFileFind ff;
std::string tmpPath = folderFullPath + _T("\\*");
BOOL bFound = ff.FindFile(tmpPath.c_str(), 0);
while (bFound)
{
bFound = ff.FindNextFile();
if (ff.GetFileName() == _T(".") || ff.GetFileName() == _T(".."))
{
continue;
}
SetFileAttributes(ff.GetFilePath(), FILE_ATTRIBUTE_NORMAL);
if (ff.IsDirectory())
{
deleteFolder(ff.GetFilePath().GetString());
RemoveDirectory(ff.GetFilePath());
}
else
{
DeleteFile(ff.GetFilePath());
}
}
ff.Close();
RemoveDirectory(folderFullPath.c_str());
}
std::string ZipTool::FilePathToFolderPath(const std::string &filePath)
{
return filePath.c_str();
}
ZipTool::ZipTool()
{
}