diff --git a/src/basicio.cpp b/src/basicio.cpp index 9692fb31..e6165435 100644 --- a/src/basicio.cpp +++ b/src/basicio.cpp @@ -614,4 +614,13 @@ namespace Exiv2 { return buf; } + long writeFile(const DataBuf& buf, const std::string& path) + { + FileIo file(path); + if (file.open("wb") != 0) { + throw Error(10, path, "wb", strError()); + } + return file.write(buf.pData_, buf.size_); + } + } // namespace Exiv2 diff --git a/src/basicio.hpp b/src/basicio.hpp index 60f8ae27..af4b1545 100644 --- a/src/basicio.hpp +++ b/src/basicio.hpp @@ -683,6 +683,9 @@ namespace Exiv2 { //! Read file \em path into a DataBuf, which is returned. DataBuf readFile(const std::string& path); + //! Write DataBuf \em buf to file \em path. Return the number of bytes written. + long writeFile(const DataBuf& buf, const std::string& path); + } // namespace Exiv2 #endif // #ifndef BASICIO_HPP_