FileHandle open_file_with_exception(const string& filename, const string& mode) { FileHandle f(open_file_raw(filename, mode), fclose); if (!f) throw runtime_error("Cannot open " + filename); return f; }
FILE* FileSourceFS::OpenWriteStream(const std::string &path, int flags) { const std::string fullpath = JoinPathBelow(GetRoot(), path); return open_file_raw(fullpath, (flags & WRITE_TEXT) ? L"w" : L"wb"); }
FILE* FileSourceFS::OpenReadStream(const std::string &path) { const std::string fullpath = JoinPathBelow(GetRoot(), path); return open_file_raw(fullpath, L"rb"); }
FileHandle open_file(const string& filename, const string& mode) { return FileHandle(open_file_raw(filename, mode), fclose); }