Commit b19ef4a2 authored by Stefan Westerfeld's avatar Stefan Westerfeld

Error handling for fopen() on raw streams.

Signed-off-by: Stefan Westerfeld's avatarStefan Westerfeld <stefan@space.twc.de>
parent 07fd22c6
......@@ -2,6 +2,7 @@
#include "rawconverter.hh"
#include <assert.h>
#include <string.h>
using std::string;
using std::vector;
......@@ -53,11 +54,9 @@ RawInputStream::open (const string& filename, const RawFormat& format)
return Error ("RawInputStream: input format: missing sample rate");
Error err = Error::Code::NONE;
RawConverter *rc = RawConverter::create (format, err);
m_raw_converter.reset (RawConverter::create (format, err));
if (err)
return err;
assert (rc);
m_raw_converter.reset (rc);
if (filename == "-")
{
......@@ -67,6 +66,9 @@ RawInputStream::open (const string& filename, const RawFormat& format)
else
{
m_input_file = fopen (filename.c_str(), "r");
if (!m_input_file)
return Error (strerror (errno));
m_close_file = true;
}
......
#include "rawoutputstream.hh"
#include <assert.h>
#include <string.h>
using std::string;
using std::vector;
......@@ -23,11 +24,9 @@ RawOutputStream::open (const string& filename, const RawFormat& format)
return Error ("RawOutputStream: output format: missing sample rate");
Error err = Error::Code::NONE;
RawConverter *rc = RawConverter::create (format, err);
m_raw_converter.reset (RawConverter::create (format, err));
if (err)
return err;
assert (rc);
m_raw_converter.reset (rc);
if (filename == "-")
{
......@@ -37,6 +36,9 @@ RawOutputStream::open (const string& filename, const RawFormat& format)
else
{
m_output_file = fopen (filename.c_str(), "w");
if (!m_output_file)
return Error (strerror (errno));
m_close_file = true;
}
......
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