void LibTau::initPath(const std::string &model) { if ( _model != model ) { if ( _initialized ) { tabout(&_handle); _initialized = false; } } else if ( _initialized ) return; std::string tablePath = Environment::Instance()->shareDir() + "/ttt/" + model; // Fill the handle structure with zeros memset(&_handle, 0, sizeof(_handle)); int err = tabin(&_handle, tablePath.c_str()); if ( err ) { std::ostringstream errmsg; errmsg << tablePath << ".hed and " << tablePath << ".tbl"; throw FileNotFoundError(errmsg.str()); } _initialized = true; brnset(&_handle, "all"); _model = model; }
FileHandle(const std::string& filename, const std::string& permissions) { _file = fopen(filename.c_str(), permissions.c_str()); if (_file == 0) { throw FileNotFoundError(filename); } }
FileHandle(const char *filename, const char *permissions) { _file = fopen(filename, permissions); if (_file == 0) { throw FileNotFoundError(filename); } }
mrb_value ScriptEngine::loadPath(std::string path) { FILE *fp = fopen(path.c_str(), "r"); if(! fp) { throw FileNotFoundError(path); } mrb_value v = mrb_load_file(mrb.get(), fp); fclose(fp); return v; }
ZipArchive::FileID ZipArchive::findFile(const char* fileName) { /* Read the archive's central directory: */ for(DirectoryIterator dIt=readDirectory();dIt.isValid();getNextEntry(dIt)) { /* Check if the file was found: */ if(strcmp(dIt.getFileName(),fileName)==0) return dIt; } /* File was not found; throw exception: */ throw FileNotFoundError(fileName); }