Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
c236c3d7
Commit
c236c3d7
authored
4 years ago
by
Aline Gondim Santos
Committed by
Aline Gondim Santos
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: MacOS < 10.15 does not support filesystem functions
Change-Id: Ia116cb9315be18fd5ff54c1777b38fc20849ad06
parent
ea8a3b3b
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/archiver.cpp
+17
-11
17 additions, 11 deletions
src/archiver.cpp
with
17 additions
and
11 deletions
src/archiver.cpp
+
17
−
11
View file @
c236c3d7
...
...
@@ -40,7 +40,6 @@ extern "C" {
#include
<mz_strm_os.h>
#include
<mz_zip.h>
#include
<mz_zip_rw.h>
#include
<filesystem>
#else
#include
<archive.h>
#include
<archive_entry.h>
...
...
@@ -289,18 +288,22 @@ uncompressArchive(const std::string& archivePath, const std::string& dir, const
const
auto
&
fileMatchPair
=
f
(
filename
);
if
(
fileMatchPair
.
first
)
{
auto
filePath
=
dir
+
DIR_SEPARATOR_STR
+
fileMatchPair
.
second
;
std
::
filesystem
::
path
directory
(
filePath
);
directory
=
directory
.
remove_filename
();
if
(
!
std
::
filesystem
::
exists
(
directory
))
std
::
string
directory
(
filePath
);
directory
=
directory
.
substr
(
0
,
directory
.
find_last_of
(
DIR_SEPARATOR_CH
));
fileutils
::
check_dir
(
directory
.
c_str
());
mz_zip_reader_entry_open
(
zip_handle
);
void
*
buffStream
=
NULL
;
buffStream
=
mz_stream_os_create
(
&
buffStream
);
if
(
mz_stream_os_open
(
buffStream
,
filePath
.
c_str
(),
MZ_OPEN_MODE_WRITE
|
MZ_OPEN_MODE_CREATE
)
==
MZ_OK
)
{
if
(
mz_stream_os_open
(
buffStream
,
filePath
.
c_str
(),
MZ_OPEN_MODE_WRITE
|
MZ_OPEN_MODE_CREATE
)
==
MZ_OK
)
{
int
chunkSize
=
8192
;
std
::
vector
<
uint8_t
>
fileContent
;
fileContent
.
resize
(
chunkSize
);
while
(
auto
ret
=
mz_zip_reader_entry_read
(
zip_handle
,
(
void
*
)
fileContent
.
data
(),
chunkSize
))
{
while
(
auto
ret
=
mz_zip_reader_entry_read
(
zip_handle
,
(
void
*
)
fileContent
.
data
(),
chunkSize
))
{
ret
=
mz_stream_os_write
(
buffStream
,
(
void
*
)
fileContent
.
data
(),
ret
);
if
(
ret
<
0
)
{
fileutils
::
removeAll
(
dir
,
true
);
...
...
@@ -351,7 +354,8 @@ uncompressArchive(const std::string& archivePath, const std::string& dir, const
break
;
}
if
(
r
!=
ARCHIVE_OK
&&
r
!=
ARCHIVE_WARN
)
{
throw
std
::
runtime_error
(
"Error reading archive: "
s
+
archive_error_string
(
archiveReader
.
get
()));
throw
std
::
runtime_error
(
"Error reading archive: "
s
+
archive_error_string
(
archiveReader
.
get
()));
}
std
::
string_view
fileEntry
(
archive_entry_pathname
(
entry
));
...
...
@@ -420,7 +424,9 @@ readFileFromArchive(const std::string& archivePath, const std::string& fileRelat
if
(
filename
==
fileRelativePathName
)
{
mz_zip_reader_entry_open
(
zip_handle
);
fileContent
.
resize
(
info
->
uncompressed_size
);
mz_zip_reader_entry_read
(
zip_handle
,
(
void
*
)
fileContent
.
data
(),
info
->
uncompressed_size
);
mz_zip_reader_entry_read
(
zip_handle
,
(
void
*
)
fileContent
.
data
(),
info
->
uncompressed_size
);
mz_zip_reader_entry_close
(
zip_handle
);
status
=
-
1
;
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment