Add isOpen() function
MatthieuHernandez opened this issue · 1 comments
MatthieuHernandez commented
Maybe add a function isOpen() to know if the file has been correctly opened like std::basic_fstream::is_open.
Or thrown exception inside load() is the file cannot be load but when I am wrong in the file name just all value are 0, no way of knowing that the file is not loading.
For the moment I have to do this:
AudioFile<float> audioFile;
audioFile.load(fileName);
if(audioFile.getNumSamplesPerChannel() == 0)
throw std::runtime_error("Cannot open " + fileName + ".");
But it is not very clean.
adamstark commented
The load()
function returns a boolean which lets you know whether or not the file was opened correctly or not. Does this achieve what you are looking for?