Skip to content

Commit

Permalink
Merge pull request #83 from alxarsenault/writeDataToFile
Browse files Browse the repository at this point in the history
Use ofstream::write in writeDataToFile
  • Loading branch information
adamstark authored Nov 7, 2023
2 parents f46a4e4 + 431cc2d commit 4ceb09b
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions AudioFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -1158,21 +1158,15 @@ template <class T>
bool AudioFile<T>::writeDataToFile (const std::vector<uint8_t>& fileData, const std::string& filePath)
{
std::ofstream outputFile (filePath, std::ios::binary);
if (outputFile.is_open())

if (!outputFile.is_open())
{
for (size_t i = 0; i < fileData.size(); i++)
{
char value = (char) fileData[i];
outputFile.write (&value, sizeof (char));
}

outputFile.close();

return true;
return false;
}

return false;

outputFile.write ((const char*)fileData.data(), fileData.size());
outputFile.close();
return true;
}

//=============================================================
Expand Down

0 comments on commit 4ceb09b

Please sign in to comment.