projects
/
libdcp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c27aa60
)
Add write_string_to_file().
v1.8.97
author
Carl Hetherington
<cth@carlh.net>
Sat, 17 Feb 2024 22:49:33 +0000
(23:49 +0100)
committer
Carl Hetherington
<cth@carlh.net>
Sat, 17 Feb 2024 22:49:33 +0000
(23:49 +0100)
src/util.cc
patch
|
blob
|
history
src/util.h
patch
|
blob
|
history
diff --git
a/src/util.cc
b/src/util.cc
index f5a15944ac6447728fffe1e478949cef2d731d22..a920ce0eae0cb717ff78298a45df79284f34cbd6 100644
(file)
--- a/
src/util.cc
+++ b/
src/util.cc
@@
-272,6
+272,15
@@
dcp::file_to_string (boost::filesystem::path p, uintmax_t max_length)
}
}
+void
+dcp::write_string_to_file(string const& string, boost::filesystem::path const& path)
+{
+ File file(path, "w");
+ if (!file) {
+ throw FileError("could not open file", path, errno);
+ }
+
+ file.write(string.c_str(), string.length(), 1);
}
}
diff --git
a/src/util.h
b/src/util.h
index 551eed071eb158b9455136a2aed903a0961ed28c..585166e32a6868d033b19f6f702580cc04437c04 100644
(file)
--- a/
src/util.h
+++ b/
src/util.h
@@
-120,6
+120,7
@@
extern int base64_decode (std::string const & in, unsigned char* out, int out_le
extern boost::optional<boost::filesystem::path> relative_to_root (boost::filesystem::path root, boost::filesystem::path file);
extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length = 1048576);
extern boost::optional<boost::filesystem::path> relative_to_root (boost::filesystem::path root, boost::filesystem::path file);
extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length = 1048576);
+extern void write_string_to_file(std::string const& string, boost::filesystem::path const& path);
/** @param key RSA private key in PEM format (optionally with -----BEGIN... / -----END...)
* @return SHA1 fingerprint of key
/** @param key RSA private key in PEM format (optionally with -----BEGIN... / -----END...)
* @return SHA1 fingerprint of key