Commit eaf0662b authored by Max Kellermann's avatar Max Kellermann

fs/io/FileOutputStream: add static method Create()

parent 6e8ea2a2
......@@ -22,6 +22,18 @@
#include "fs/FileSystem.hxx"
#include "util/Error.hxx"
FileOutputStream *
FileOutputStream::Create(Path path, Error &error)
{
FileOutputStream *f = new FileOutputStream(path, error);
if (!f->IsDefined()) {
delete f;
f = nullptr;
}
return f;
}
#ifdef WIN32
FileOutputStream::FileOutputStream(Path _path, Error &error)
......
......@@ -58,6 +58,7 @@ public:
Cancel();
}
static FileOutputStream *Create(Path path, Error &error);
bool IsDefined() const {
#ifdef WIN32
......
......@@ -167,11 +167,9 @@ RecorderOutput::Open(AudioFormat &audio_format, Error &error)
{
/* create the output file */
file = new FileOutputStream(path, error);
if (!file->IsDefined()) {
delete file;
file = FileOutputStream::Create(path, error);
if (file == nullptr)
return false;
}
/* open the encoder */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment