diff --git a/AudioFile.h b/AudioFile.h index 36bb41d..e45136d 100644 --- a/AudioFile.h +++ b/AudioFile.h @@ -1158,21 +1158,15 @@ template bool AudioFile::writeDataToFile (const std::vector& 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; } //=============================================================