CodecInstance* syImgReaderPlugin::OpenFile(const syString& filename) { CodecInstance* result = 0; if (CanReadFile(filename)) { result = new syImgReaderCodec(this, filename); if(result && !result->OpenInput()) { delete result; result = 0; // Couldn't read! } } return result; }
void SCCircuitDocument::OpenSomething ( const JCharacter* fileName ) { JString fullName; if (fileName != NULL && fileName[0] != '\0') { if (JFileExists(fileName)) { fullName = fileName; } else { return; } } else if (!(JGetChooseSaveFile())->ChooseFile("File to open:", NULL, &fullName)) { return; } std::ifstream input(fullName); const FileStatus status = CanReadFile(input); JXFileDocument* doc; if (status == kFileReadable && !(JXGetDocumentManager())->FileDocumentIsOpen(fullName, &doc) && OKToClose()) { CloseAllWindows(); FileChanged(fullName, kJTrue); ReadFile(input); } else if (status == kNeedNewerVersion) { (JGetUserNotification())->ReportError( "This notebook was created by a newer version of Symcir. " "You need the newest version in order to open it."); } else if (status == kNotMyFile && OKToClose()) { input.close(); CloseAllWindows(); ReadNetlist(fullName); } }
void Security::ReadFile(const string& file) { if(!CanReadFile(file)) throw SecurityViolationError("Security::ReadFile(const string&)","access denied: '"+file+"'"); }