Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
onlyoffice_core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
onlyoffice_core
Commits
114050c2
Commit
114050c2
authored
Feb 16, 2017
by
ElenaSubbotina
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug #33849
parent
7eee0755
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
124 additions
and
104 deletions
+124
-104
OfficeUtils/src/OfficeUtils.cpp
OfficeUtils/src/OfficeUtils.cpp
+8
-8
OfficeUtils/src/ZipUtilsCP.cpp
OfficeUtils/src/ZipUtilsCP.cpp
+116
-96
No files found.
OfficeUtils/src/OfficeUtils.cpp
View file @
114050c2
OfficeUtils/src/ZipUtilsCP.cpp
View file @
114050c2
...
...
@@ -477,11 +477,30 @@ namespace ZLibZipUtils
return
false
;
}
/*========================================================================================================*/
int
ZipDir
(
const
WCHAR
*
dir
,
const
WCHAR
*
outputFile
,
const
OnProgressCallback
*
progress
,
int
compressionLevel
)
{
/*========================================================================================================*/
int
oneZipFile
(
zipFile
&
zf
,
zip_fileinfo
&
zi
,
std
::
wstring
&
file_name
,
std
::
wstring
&
zip_file_name
,
int
method
,
int
compressionLevel
)
{
int
err
=
-
1
;
NSFile
::
CFileBinary
oFile
;
if
(
oFile
.
OpenFile
(
file_name
))
{
DWORD
dwSizeRead
;
BYTE
*
pData
=
new
BYTE
[
oFile
.
GetFileSize
()];
if
(
oFile
.
ReadFile
(
pData
,
oFile
.
GetFileSize
(),
dwSizeRead
))
{
std
::
string
zipFileNameA
=
codepage_issue_fixToOEM
(
zip_file_name
);
err
=
zipOpenNewFileInZip
(
zf
,
zipFileNameA
.
c_str
(),
&
zi
,
NULL
,
0
,
NULL
,
0
,
NULL
,
method
,
compressionLevel
);
err
=
zipWriteInFileInZip
(
zf
,
pData
,
dwSizeRead
);
err
=
zipCloseFileInZip
(
zf
);
}
RELEASEARRAYOBJECTS
(
pData
);
}
return
0
;
}
int
ZipDir
(
const
WCHAR
*
dir
,
const
WCHAR
*
outputFile
,
const
OnProgressCallback
*
progress
,
int
compressionLevel
)
{
if
(
(
dir
!=
NULL
)
&&
(
outputFile
!=
NULL
)
)
{
deque
<
wstring
>
StringDeque
;
...
...
@@ -531,6 +550,7 @@ namespace ZLibZipUtils
CArray
<
std
::
wstring
>
aCurFiles
=
NSDirectory
::
GetFiles
(
szText
);
CArray
<
std
::
wstring
>
aCurDirectories
=
NSDirectory
::
GetDirectories
(
szText
);
for
(
int
i
=
0
;
i
<
aCurDirectories
.
GetCount
();
++
i
)
{
std
::
wstring
sCurDirectory
=
aCurDirectories
[
i
];
...
...
@@ -539,47 +559,49 @@ namespace ZLibZipUtils
zipDeque
.
push_back
(
zipDir
+
sDirName
);
}
for
(
int
i
=
0
;
i
<
aCurFiles
.
GetCount
();
++
i
)
for
(
int
i
=
0
;
i
<
aCurFiles
.
GetCount
();
++
i
)
{
std
::
wstring
cFileName
=
NSSystemPath
::
GetFileName
(
aCurFiles
[
i
]);
if
(
std
::
wstring
::
npos
!=
cFileName
.
find
(
L"mimetype"
))
// возможно и полное соответствие
{
std
::
wstring
cFilePath
=
aCurFiles
[
i
];
std
::
wstring
cFileName
=
NSSystemPath
::
GetFileName
(
cFilePath
);
file
=
NSSystemPath
::
Combine
(
szText
,
cFileName
);
zipFileName
=
zipDir
+
cFileName
;
NSFile
::
CFileBinary
oFile
;
if
(
oFile
.
OpenFile
(
file
))
{
DWORD
dwSizeRead
;
BYTE
*
pData
=
new
BYTE
[
oFile
.
GetFileSize
()];
if
(
oFile
.
ReadFile
(
pData
,
oFile
.
GetFileSize
(),
dwSizeRead
))
{
std
::
string
zipFileNameA
=
codepage_issue_fixToOEM
(
zipFileName
);
err
=
zipOpenNewFileInZip
(
zf
,
zipFileNameA
.
c_str
(),
&
zi
,
NULL
,
0
,
NULL
,
0
,
NULL
,
Z_DEFLATED
,
compressionLevel
);
err
=
zipWriteInFileInZip
(
zf
,
pData
,
dwSizeRead
);
err
=
zipCloseFileInZip
(
zf
);
oneZipFile
(
zf
,
zi
,
file
,
zipFileName
,
0
,
compressionLevel
);
aCurFiles
.
RemoveAt
(
i
);
break
;
}
RELEASEARRAYOBJECTS
(
pData
);
}
for
(
int
i
=
0
;
i
<
aCurFiles
.
GetCount
();
++
i
)
{
std
::
wstring
cFilePath
=
aCurFiles
[
i
];
std
::
wstring
cFileName
=
NSSystemPath
::
GetFileName
(
cFilePath
);
file
=
NSSystemPath
::
Combine
(
szText
,
cFileName
);
zipFileName
=
zipDir
+
cFileName
;
oneZipFile
(
zf
,
zi
,
file
,
zipFileName
,
Z_DEFLATED
,
compressionLevel
);
if
(
progress
!=
NULL
)
{
short
cancel
=
0
;
long
progressValue
=
(
1000000
/
filesCount
*
currentFileIndex
);
if
(
NULL
!=
progress
)
(
*
progress
)(
UTILS_ONPROGRESSEVENT_ID
,
progressValue
,
&
cancel
);
if
(
cancel
!=
0
)
{
err
=
zipClose
(
zf
,
NULL
);
return
err
;
zipClose
(
zf
,
NULL
);
}
}
currentFileIndex
++
;
}
}
err
=
zipClose
(
zf
,
NULL
);
zipClose
(
zf
,
NULL
);
if
(
progress
!=
NULL
)
{
...
...
@@ -587,12 +609,10 @@ namespace ZLibZipUtils
long
progressValue
=
1000000
;
if
(
NULL
!=
progress
)
(
*
progress
)(
UTILS_ONPROGRESSEVENT_ID
,
progressValue
,
&
cancel
);
}
}
return
err
;
}
return
0
;
}
/*========================================================================================================*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment