Added writeFile() convenience function.

This commit is contained in:
Andreas Huggel 2007-12-09 08:00:26 +00:00
parent 8a7604fb58
commit 358adfce04
2 changed files with 12 additions and 0 deletions

View File

@ -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

View File

@ -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_