Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in / Register
Toggle navigation
J
jami-daemon
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
118
Issues
118
List
Boards
Labels
Milestones
Security & Compliance
Security & Compliance
Dependency List
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
savoirfairelinux
jami-daemon
Commits
4f673529
Commit
4f673529
authored
Mar 22, 2015
by
Adrien Béraud
Committed by
Guillaume Roguez
Mar 23, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ringaccount: use loadFile, saveFile from fileutils
Refs #67228 Change-Id: Ic13ea4d0b27de7fe7829f2b5b43171eba68e5d0c
parent
755f8694
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
31 deletions
+2
-31
src/ringdht/ringaccount.cpp
src/ringdht/ringaccount.cpp
+2
-31
No files found.
src/ringdht/ringaccount.cpp
View file @
4f673529
...
...
@@ -423,35 +423,6 @@ RingAccount::checkIdentityPath()
loadIdentity
();
}
std
::
vector
<
uint8_t
>
loadFile
(
const
std
::
string
&
path
)
{
std
::
vector
<
uint8_t
>
buffer
;
std
::
ifstream
file
(
path
,
std
::
ios
::
binary
);
if
(
!
file
)
throw
std
::
runtime_error
(
"Can't read file: "
+
path
);
file
.
seekg
(
0
,
std
::
ios
::
end
);
std
::
streamsize
size
=
file
.
tellg
();
if
(
size
>
std
::
numeric_limits
<
unsigned
>::
max
())
throw
std
::
runtime_error
(
"File is too big: "
+
path
);
buffer
.
resize
(
size
);
file
.
seekg
(
0
,
std
::
ios
::
beg
);
if
(
!
file
.
read
((
char
*
)
buffer
.
data
(),
size
))
throw
std
::
runtime_error
(
"Can't load file: "
+
path
);
return
buffer
;
}
void
saveFile
(
const
std
::
string
&
path
,
const
std
::
vector
<
uint8_t
>&
data
)
{
std
::
ofstream
file
(
path
,
std
::
ios
::
trunc
|
std
::
ios
::
binary
);
if
(
!
file
.
is_open
())
{
RING_ERR
(
"Could not write data to %s"
,
path
.
c_str
());
return
;
}
file
.
write
((
char
*
)
data
.
data
(),
data
.
size
());
}
std
::
pair
<
std
::
shared_ptr
<
dht
::
crypto
::
Certificate
>
,
dht
::
crypto
::
Identity
>
RingAccount
::
loadIdentity
()
{
...
...
@@ -877,7 +848,7 @@ void RingAccount::doUnregister(std::function<void(bool)> released_cb)
void
RingAccount
::
registerCA
(
const
dht
::
crypto
::
Certificate
&
crt
)
{
saveFile
(
caPath_
+
DIR_SEPARATOR_STR
+
crt
.
getPublicKey
().
getId
().
toString
(),
crt
.
getPacked
());
fileutils
::
saveFile
(
caPath_
+
DIR_SEPARATOR_STR
+
crt
.
getPublicKey
().
getId
().
toString
(),
crt
.
getPacked
());
}
bool
...
...
@@ -887,7 +858,7 @@ RingAccount::unregisterCA(const dht::InfoHash& crt_id)
bool
deleted
=
false
;
for
(
const
auto
&
ca_path
:
cas
)
{
try
{
dht
::
crypto
::
Certificate
tmp_crt
(
loadFile
(
ca_path
));
dht
::
crypto
::
Certificate
tmp_crt
(
fileutils
::
loadFile
(
ca_path
));
if
(
tmp_crt
.
getPublicKey
().
getId
()
==
crt_id
)
deleted
&=
remove
(
ca_path
.
c_str
())
==
0
;
}
catch
(
const
std
::
exception
&
)
{}
...
...
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