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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
8d8da12a
Commit
8d8da12a
authored
5 years ago
by
Adrien Béraud
Browse files
Options
Downloads
Patches
Plain Diff
fileutils: add way to save file from any raw data
Change-Id: I6b778ec237ab4f517a710f1a827d55a264341e07
parent
dfdc0b61
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/fileutils.cpp
+2
-2
2 additions, 2 deletions
src/fileutils.cpp
src/fileutils.h
+4
-1
4 additions, 1 deletion
src/fileutils.h
with
6 additions
and
3 deletions
src/fileutils.cpp
+
2
−
2
View file @
8d8da12a
...
...
@@ -378,7 +378,7 @@ loadFile(const std::string& path, const std::string& default_dir)
void
saveFile
(
const
std
::
string
&
path
,
const
std
::
vector
<
uint8_t
>&
data
,
const
uint8_t
*
data
,
size_t
data_size
,
mode_t
UNUSED
mode
)
{
std
::
ofstream
file
=
fileutils
::
ofstream
(
path
,
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
...
...
@@ -386,7 +386,7 @@ saveFile(const std::string& path,
JAMI_ERR
(
"Could not write data to %s"
,
path
.
c_str
());
return
;
}
file
.
write
((
char
*
)
data
.
data
()
,
data
.
size
()
);
file
.
write
((
char
*
)
data
,
data
_
size
);
#ifndef _WIN32
if
(
chmod
(
path
.
c_str
(),
mode
)
<
0
)
JAMI_WARN
(
"fileutils::saveFile(): chmod() failed on '%s', %s"
,
path
.
c_str
(),
strerror
(
errno
));
...
...
This diff is collapsed.
Click to expand it.
src/fileutils.h
+
4
−
1
View file @
8d8da12a
...
...
@@ -108,7 +108,10 @@ namespace jami { namespace fileutils {
* If path is relative, it is appended to default_dir.
*/
std
::
vector
<
uint8_t
>
loadFile
(
const
std
::
string
&
path
,
const
std
::
string
&
default_dir
=
{});
void
saveFile
(
const
std
::
string
&
path
,
const
std
::
vector
<
uint8_t
>&
data
,
mode_t
mode
=
0644
);
void
saveFile
(
const
std
::
string
&
path
,
const
uint8_t
*
data
,
size_t
data_size
,
mode_t
mode
=
0644
);
inline
void
saveFile
(
const
std
::
string
&
path
,
const
std
::
vector
<
uint8_t
>&
data
,
mode_t
mode
=
0644
)
{
saveFile
(
path
,
data
.
data
(),
data
.
size
(),
mode
);
}
std
::
vector
<
uint8_t
>
readArchive
(
const
std
::
string
&
path
,
const
std
::
string
&
password
=
{});
void
writeArchive
(
const
std
::
string
&
data
,
const
std
::
string
&
path
,
const
std
::
string
&
password
=
{});
...
...
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