diff options
Diffstat (limited to 'src/Storage.cpp')
-rw-r--r-- | src/Storage.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Storage.cpp b/src/Storage.cpp index 919044e..745ecfc 100644 --- a/src/Storage.cpp +++ b/src/Storage.cpp @@ -89,13 +89,17 @@ namespace QuickMedia { } int file_get_content(const Path &path, std::string &result) { - assert(get_file_type(path) == FileType::REGULAR); FILE *file = fopen(path.data.c_str(), "rb"); if(!file) return -errno; fseek(file, 0, SEEK_END); - size_t file_size = ftell(file); + long file_size = ftell(file); + if(file_size == -1) { + fprintf(stderr, "Error: attempted to read directory %s as a file\n", path.data.c_str()); + fclose(file); + return -1; + } fseek(file, 0, SEEK_SET); result.resize(file_size); |