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); } }
int ImportNetlist (char *filename) { FILE *fp; char buf[16]; int i; char* p; if (!filename) return (1); /* nothing to do */ fp = fopen (filename, "r"); if (!fp) return (1); /* bad filename */ i = fread (buf, 1, sizeof(buf)-1, fp); fclose(fp); buf[i] = '\0'; p=buf; while ( *p ) { *p = tolower ((int) *p); p++; } p = strstr (buf, "edif"); if (!p) return ReadNetlist (filename); else return ReadEdifNetlist (filename); }