mirror of
https://github.com/ONLYOFFICE/desktop-apps.git
synced 2026-04-07 14:09:22 +08:00
Merge branch 'hotfix/v8.0.1' into develop
This commit is contained in:
@ -77,7 +77,7 @@ int main(int argc, char *argv[])
|
||||
"New document",
|
||||
"New spreadsheet",
|
||||
"New presentation",
|
||||
"New form template"
|
||||
"New PDF form"
|
||||
};
|
||||
CreateJumpList(_cmdArgs.size() > MIN_TASK_NUM ? _cmdArgs.mid(1) : defaultTitles);
|
||||
return 0;
|
||||
|
||||
@ -52,6 +52,12 @@ core_debug:DESTDIR = $$DESTDIR/build/debug
|
||||
DESTDIR = $$DESTDIR/$$CORE_BUILDS_PLATFORM_PREFIX
|
||||
|
||||
core_windows {
|
||||
ZLIB_DIR = $$CORE_ROOT_DIR/OfficeUtils/src/zlib-1.2.11
|
||||
MINIZIP_DIR = $$ZLIB_DIR/contrib/minizip
|
||||
INCLUDEPATH += $$ZLIB_DIR \
|
||||
$$ZLIB_DIR/../../src \
|
||||
$$MINIZIP_DIR
|
||||
|
||||
HEADERS += $$PWD/src/platform_win/utils.h \
|
||||
$$PWD/src/platform_win/resource.h \
|
||||
$$PWD/src/platform_win/svccontrol.h \
|
||||
@ -68,6 +74,27 @@ core_windows {
|
||||
$$PWD/src/classes/platform_win/cdownloader.cpp \
|
||||
$$PWD/src/classes/platform_win/ctimer.cpp
|
||||
|
||||
SOURCES += $$ZLIB_DIR/../../src/zlib_addon.c \
|
||||
$$ZLIB_DIR/adler32.c \
|
||||
$$ZLIB_DIR/crc32.c \
|
||||
$$ZLIB_DIR/inffast.c \
|
||||
$$ZLIB_DIR/inflate.c \
|
||||
$$ZLIB_DIR/inftrees.c \
|
||||
$$ZLIB_DIR/zutil.c \
|
||||
$$MINIZIP_DIR/ioapi.c \
|
||||
$$MINIZIP_DIR/iowin32.c \
|
||||
$$MINIZIP_DIR/unzip.c
|
||||
|
||||
HEADERS += $$ZLIB_DIR/../../src/zlib_addon.h \
|
||||
$$ZLIB_DIR/crc32.h \
|
||||
$$ZLIB_DIR/inffast.h \
|
||||
$$ZLIB_DIR/inflate.h \
|
||||
$$ZLIB_DIR/inftrees.h \
|
||||
$$ZLIB_DIR/zutil.h \
|
||||
$$MINIZIP_DIR/ioapi.h \
|
||||
$$MINIZIP_DIR/iowin32.h \
|
||||
$$MINIZIP_DIR/unzip.h
|
||||
|
||||
OTHER_FILES += $$PWD/res/version.rc \
|
||||
$$PWD/res/manifest/updatesvc.exe.manifest
|
||||
|
||||
|
||||
@ -32,6 +32,7 @@
|
||||
|
||||
#include "cunzip.h"
|
||||
#include "platform_win/utils.h"
|
||||
#ifdef USE_NATIVE_UNZIP
|
||||
#include <atlbase.h>
|
||||
#include <Shldisp.h>
|
||||
|
||||
@ -176,18 +177,92 @@ public:
|
||||
CoUninitialize();
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
#include <Windows.h>
|
||||
#include <codecvt>
|
||||
#include "unzip.h"
|
||||
|
||||
FnVoidInt complete_callback = nullptr,
|
||||
progress_callback = nullptr;
|
||||
std::atomic_bool run;
|
||||
std::future<void> future;
|
||||
int curr_count = 0,
|
||||
total_count = 0,
|
||||
prev_percent = -1;
|
||||
};
|
||||
#define MAX_PATH_LEN 512
|
||||
#define BLOCK_SIZE 8192
|
||||
|
||||
CUnzip::CUnzip() :
|
||||
pimpl(new CUnzipPrivate)
|
||||
|
||||
int unzipArchive(const wstring &zipFilePath, const wstring &folderPath, std::atomic_bool &run)
|
||||
{
|
||||
if (!NS_File::fileExists(zipFilePath) || !NS_File::dirExists(folderPath))
|
||||
return UNZIP_ERROR;
|
||||
|
||||
std::wstring_convert<std::codecvt_utf8<wchar_t>> utf8_conv;
|
||||
std::string utf8ZipFilePath = utf8_conv.to_bytes(NS_File::fromNativeSeparators(zipFilePath));
|
||||
std::string utf8FolderPath = utf8_conv.to_bytes(NS_File::fromNativeSeparators(folderPath));
|
||||
|
||||
unzFile hzf = unzOpen(utf8ZipFilePath.c_str());
|
||||
if (!hzf)
|
||||
return UNZIP_ERROR;
|
||||
|
||||
unz_global_info g_info;
|
||||
if (unzGetGlobalInfo(hzf, &g_info) != UNZ_OK) {
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
|
||||
uLong total_count = g_info.number_entry;
|
||||
for (uLong i = 0; i < total_count; ++i) {
|
||||
if (!run) {
|
||||
unzClose(hzf);
|
||||
return UNZIP_ABORT;
|
||||
}
|
||||
unz_file_info file_info;
|
||||
char entry_name[MAX_PATH_LEN];
|
||||
if (unzGetCurrentFileInfo(hzf, &file_info, entry_name, MAX_PATH_LEN, NULL, 0, NULL, 0) != UNZ_OK) {
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
|
||||
char out_path[MAX_PATH_LEN];
|
||||
snprintf(out_path, MAX_PATH_LEN, "%s/%s", utf8FolderPath.c_str(), entry_name);
|
||||
if (entry_name[strlen(entry_name) - 1] == '/') {
|
||||
if (::CreateDirectoryA(out_path, NULL) == 0)
|
||||
return UNZIP_ERROR;
|
||||
|
||||
} else {
|
||||
if (unzOpenCurrentFile(hzf) != UNZ_OK) {
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
|
||||
FILE *hFile = fopen(out_path, "wb");
|
||||
if (!hFile) {
|
||||
unzCloseCurrentFile(hzf);
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
|
||||
int bytes_read = 0;
|
||||
do {
|
||||
char buff[BLOCK_SIZE] = {0};
|
||||
bytes_read = unzReadCurrentFile(hzf, buff, BLOCK_SIZE);
|
||||
if (bytes_read < 0 || (bytes_read > 0 && fwrite(buff, bytes_read, 1, hFile) != 1)) {
|
||||
fclose(hFile);
|
||||
unzCloseCurrentFile(hzf);
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
} while (bytes_read > 0);
|
||||
fclose(hFile);
|
||||
unzCloseCurrentFile(hzf);
|
||||
}
|
||||
|
||||
if ((i + 1) < total_count && unzGoToNextFile(hzf) != UNZ_OK) {
|
||||
unzClose(hzf);
|
||||
return UNZIP_ERROR;
|
||||
}
|
||||
}
|
||||
unzClose(hzf);
|
||||
return UNZIP_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
CUnzip::CUnzip()
|
||||
{
|
||||
pimpl->run = false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user