MCPcopy Create free account
hub / github.com/bruderstein/nppPluginManager / unzip

Method unzip

libinstall/src/Decompress.cpp:31–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29using namespace std;
30
31BOOL Decompress::unzip(const tstring &zipFile, const tstring &destDir)
32{
33
34 zlib_filefunc_def filefunc;
35 fill_win32_filefunc(&filefunc);
36 unzFile hZip = unzOpen2(zipFile.c_str(), &filefunc);
37
38 if (unzGoToFirstFile(hZip) != UNZ_OK)
39 {
40 unzClose(hZip);
41 return FALSE;
42 }
43
44 int nextFileResult;
45
46 do {
47 if (unzOpenCurrentFile(hZip) != UNZ_OK)
48 {
49 unzClose(hZip);
50 return FALSE;
51 }
52
53 char filename[MAX_PATH];
54
55 if (unzGetCurrentFileInfo(hZip, NULL, filename, MAX_PATH, NULL, 0, NULL, 0) != UNZ_OK)
56 {
57 unzClose(hZip);
58 return FALSE;
59 }
60
61 std::shared_ptr<TCHAR> tFilename = WcharMbcsConverter::char2tchar(filename);
62
63
64 if ((tFilename.get())[_tcslen(tFilename.get()) - 1] == _T('/'))
65 {
66 tstring outputDir(destDir);
67
68 outputDir.append(tFilename.get());
69 outputDir.erase(outputDir.size() - 1);
70 ::CreateDirectory(outputDir.c_str(), NULL);
71 unzCloseCurrentFile(hZip);
72 }
73 else
74 {
75
76 FILE *fp = NULL;
77 tstring outputFilename (destDir);
78
79 outputFilename.append(tFilename.get());
80
81 tstring::size_type pos = outputFilename.find_first_of(_T('/'));
82 // Replace all the forward slashes with backward ones
83 while (pos != string::npos)
84 {
85
86 outputFilename.replace(pos, 1, 1, _T('\\'));
87 pos = outputFilename.find_first_of(_T('/'), pos);
88 }

Callers

nothing calls this directly

Calls 11

fill_win32_filefuncFunction · 0.85
unzOpen2Function · 0.85
unzGoToFirstFileFunction · 0.85
unzCloseFunction · 0.85
unzOpenCurrentFileFunction · 0.85
unzGetCurrentFileInfoFunction · 0.85
unzCloseCurrentFileFunction · 0.85
unzReadCurrentFileFunction · 0.85
unzGoToNextFileFunction · 0.85
c_strMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected