Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions libs/openFrameworks/utils/ofFileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//------------------------------------------------------------------------------------------------------------
Expand Down
13 changes: 12 additions & 1 deletion libs/openFrameworks/utils/ofFileUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand All @@ -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
Expand Down