From 2bf0b1a5c792a7fd5cbdd7a460583b5569a93d85 Mon Sep 17 00:00:00 2001 From: Mike Walters Date: Sat, 23 Apr 2016 13:58:21 +0100 Subject: [PATCH] input: Print fopen error --- inputsource.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inputsource.cpp b/inputsource.cpp index af9f49a..6cc6049 100644 --- a/inputsource.cpp +++ b/inputsource.cpp @@ -20,6 +20,7 @@ #include "inputsource.h" +#include #include #include #include @@ -137,9 +138,13 @@ void InputSource::openFile(const char *filename) sampleAdapter = std::unique_ptr(new ComplexF32SampleAdapter()); } + errno = 0; FILE *file = fopen(filename, "rb"); - if (file == nullptr) - throw std::runtime_error("Error opening file"); + if (file == nullptr) { + std::stringstream ss; + ss << "Error opening file: " << strerror(errno) << " (" << errno << ")"; + throw std::runtime_error(ss.str()); + } struct stat sb; if (fstat(fileno(file), &sb) != 0)