Commit 009e5bb1 authored by Nick Korovaiko's avatar Nick Korovaiko Committed by Scott Cyphers

check if file exists in mnist_loader (#1127)

parent 88aa9e9c
...@@ -80,6 +80,12 @@ void MNistLoader::open() ...@@ -80,6 +80,12 @@ void MNistLoader::open()
throw std::logic_error("Loader already open"); throw std::logic_error("Loader already open");
} }
m_file = fopen(m_filename.c_str(), "rb"); m_file = fopen(m_filename.c_str(), "rb");
if (m_file == nullptr)
{
throw std::runtime_error(std::string("File") + m_filename +
"couldn't be opened. Make sure the file "
"exists in the current directory");
}
read_header(); read_header();
fgetpos(m_file, &m_data_pos); fgetpos(m_file, &m_data_pos);
} }
......
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