diff --git a/libs/openFrameworks/utils/ofFileUtils.cpp b/libs/openFrameworks/utils/ofFileUtils.cpp index 59e34271059..da5fabfd28e 100644 --- a/libs/openFrameworks/utils/ofFileUtils.cpp +++ b/libs/openFrameworks/utils/ofFileUtils.cpp @@ -449,10 +449,16 @@ ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary){ return ofBuffer(f); } + +//-------------------------------------------------- +bool ofSaveBuffer(const ofBuffer& buffer, const std::filesystem::path & path, bool binary) { + ofFile f(path, ofFile::WriteOnly, binary); + return buffer.writeTo(f); +} + //-------------------------------------------------- bool ofBufferToFile(const std::filesystem::path & path, const ofBuffer& buffer, bool binary){ - ofFile f(path, ofFile::WriteOnly, binary); - return buffer.writeTo(f); + return ofSaveBuffer(buffer, path, binary); } //------------------------------------------------------------------------------------------------------------ diff --git a/libs/openFrameworks/utils/ofFileUtils.h b/libs/openFrameworks/utils/ofFileUtils.h index 027f79fe7dc..dab736d5be4 100644 --- a/libs/openFrameworks/utils/ofFileUtils.h +++ b/libs/openFrameworks/utils/ofFileUtils.h @@ -258,6 +258,17 @@ class ofBuffer{ /// split at endline characters automatically ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary=true); +//-------------------------------------------------- +/// Write the contents of a buffer to a file at path. +/// +/// Saves as a text file by default. +/// +/// \param buffer data source to write from +/// \param path file to open +/// \param binary set to false if you are writing a text file & want lines +/// split at endline characters automatically +bool ofSaveBuffer(const ofBuffer& buffer, const std::filesystem::path & path, bool binary=true); + //-------------------------------------------------- /// Write the contents of a buffer to a file at path. /// @@ -267,7 +278,7 @@ ofBuffer ofBufferFromFile(const std::filesystem::path & path, bool binary=true); /// \param buffer data source to write from /// \param binary set to false if you are writing a text file & want lines /// split at endline characters automatically -bool ofBufferToFile(const std::filesystem::path & path, const ofBuffer& buffer, bool binary=true); +OF_DEPRECATED_MSG("Use ofSaveBuffer.", bool ofBufferToFile(const std::filesystem::path & path, const ofBuffer& buffer, bool binary=true)); //-------------------------------------------------- /// \class ofFilePath