// Build up and save an index into the poetry data file, for // rapid random access bool Compile(void) { FILE *file; int j; int ch; wxChar buf[100]; if (data_filename) wxSprintf(buf, wxT("%s.dat"), data_filename); file = wxFopen(buf, wxT("rb")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry data file %s not found\n"), buf); PoetryError(error_buf); return false; } nitems = 0; // Do first one (?) poem_index[nitems] = 0; nitems ++; // Do rest do { ch = getc(file); if (ch == '#') { ch = getc(file); long data; data = ftell(file); poem_index[nitems] = data; nitems ++; } } while (ch != EOF); fclose(file); if (index_filename) wxSprintf(buf, wxT("%s.idx"), index_filename); file = wxFopen(buf, wxT("w")); if (! (data_filename && file)) { wxSprintf(error_buf, wxT("Poetry index file %s cannot be created\n"), buf); PoetryError(error_buf); return false; } wxFprintf(file, wxT("%ld\n\n"), nitems); for (j = 0; j < nitems; j++) wxFprintf(file, wxT("%ld\n"), poem_index[j]); fclose(file); PoetryNotify(wxT("Poetry index compiled.")); return true; }
/** * Function start_plot * Write GERBER header to file * initialize global variable g_Plot_PlotOutputFile * @param aFile: an opened file to write to */ bool GERBER_PLOTTER::start_plot( FILE* aFile ) { wxASSERT( !output_file ); final_file = aFile; // Create a temporary filename to store gerber file // note tmpfile() does not work under Vista and W7 in user mode m_workFilename = filename + wxT(".tmp"); work_file = wxFopen( m_workFilename, wxT( "wt" )); output_file = work_file; wxASSERT( output_file ); if( output_file == NULL ) return false; wxString Title = creator + wxT( " " ) + GetBuildVersion(); fprintf( output_file, "G04 (created by %s) date %s*\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) ); // Specify linear interpol (G01), unit = INCH (G70), abs format (G90): fputs( "G01*\nG70*\nG90*\n", output_file ); fputs( "%MOIN*%\n", output_file ); // set unites = INCHES /* Set gerber format to 3.4 */ fputs( "G04 Gerber Fmt 3.4, Leading zero omitted, Abs format*\n%FSLAX34Y34*%\n", output_file ); fputs( "G04 APERTURE LIST*\n", output_file ); /* Select the default aperture */ set_current_line_width( -1 ); return true; }
bool RecreateCmpFile( BOARD * aBrd, const wxString& aFullCmpFileName ) { FILE* cmpFile; cmpFile = wxFopen( aFullCmpFileName, wxT( "wt" ) ); if( cmpFile == NULL ) return false; fprintf( cmpFile, "Cmp-Mod V01 Created by PcbNew date = %s\n", TO_UTF8( DateAndTime() ) ); MODULE* module = aBrd->m_Modules; for( ; module != NULL; module = module->Next() ) { fprintf( cmpFile, "\nBeginCmp\n" ); fprintf( cmpFile, "TimeStamp = %8.8lX\n", (unsigned long)module->GetTimeStamp() ); fprintf( cmpFile, "Path = %s\n", TO_UTF8( module->GetPath() ) ); fprintf( cmpFile, "Reference = %s;\n", !module->GetReference().IsEmpty() ? TO_UTF8( module->GetReference() ) : "[NoRef]" ); fprintf( cmpFile, "ValeurCmp = %s;\n", !module->GetValue().IsEmpty() ? TO_UTF8( module->GetValue() ) : "[NoVal]" ); fprintf( cmpFile, "IdModule = %s;\n", module->GetFPID().Format().c_str() ); fprintf( cmpFile, "EndCmp\n" ); } fprintf( cmpFile, "\nEndListe\n" ); fclose( cmpFile ); return true; }
bool CMPCInfo::ReadMetaData(CSongMetaData & MetaData) const { StreamInfo info; FILE *fp = wxFopen( MetaData.Filename.GetFullPath(), wxT("rb") ); if (!fp) return false; Reader_file reader(fp); if (info.ReadStreamInfo(&reader) != ERROR_CODE_OK) { return false; } MetaData.nBitrate = (int)(info.simple.AverageBitrate / 1024.0); MetaData.nFilesize = info.simple.TotalFileLength; MetaData.nDuration_ms = info.simple.PCMSamples * 1000 / info.simple.SampleFreq; CSimpleTagReader tr; CSimpleTagReader::CFile trf(fp,false); tr.ReadTags(trf,ConvToUTF8(MetaData.Filename.GetFullPath())); MetaData.Album = tr.TagValue(SIMPLETAG_FIELD_ALBUM); MetaData.Title = tr.TagValue(SIMPLETAG_FIELD_TITLE); MetaData.Notes = tr.TagValue(SIMPLETAG_FIELD_NOTES); MetaData.Artist = tr.TagValue(SIMPLETAG_FIELD_ARTIST); MetaData.Year = tr.TagValue(SIMPLETAG_FIELD_YEAR); MetaData.Genre = tr.TagValue(SIMPLETAG_FIELD_GENRE); char* track = tr.TagValue(SIMPLETAG_FIELD_TRACK); MetaData.nTracknum = track ? atoi(track) : 0; return true; }
int WinEDA_ModuleEditFrame::Create_Librairie(const wxString & LibName) /**********************************************************************/ { FILE * lib_module; wxString msg; if ( wxFileExists(LibName) ) { msg = _("Library exists ") + LibName; DisplayError(this, msg); return(0); } if ((lib_module = wxFopen(LibName, wxT("wt") )) == NULL ) { msg = _("Unable to create ") + LibName; DisplayError(this, msg); return(-1); } /* Ecriture de l'entete de la nouvelle librairie */ if( fprintf(lib_module,ENTETE_LIBRAIRIE) == 0) { msg = _("Create error ") + LibName; DisplayError(this, msg); fclose(lib_module) ; return(-1); } fprintf(lib_module," %s\n", DateAndTime(cbuf)); fputs("$INDEX\n",lib_module); fputs("$EndINDEX\n",lib_module); fclose(lib_module) ; return(1); }
void rc2wxr::Convert(wxString wxrfile, wxString rcfile) { m_rc.Open(rcfile); m_filesize=m_rc.Length(); if( (m_wxr = wxFopen( wxrfile, _T("wt") )) == NULL ) { return; } wxString tok,prevtok; while (!m_done) { tok=GetToken(); if (tok==_T("DIALOG")) { ParseDialog(prevtok); } if (tok==_T("MENU")) { ParseMenu(prevtok); } prevtok=tok; } fclose(m_wxr); m_rc.Close(); }
static void read_surface( const wxChar *filename ) { FILE *f = wxFopen(filename,_T("r")); if (!f) { wxString msg = _T("Couldn't read "); msg += filename; wxMessageBox(msg); return; } numverts = 0; while (!feof(f) && numverts<MAXVERTS) { fscanf( f, "%f %f %f %f %f %f", &verts[numverts][0], &verts[numverts][1], &verts[numverts][2], &norms[numverts][0], &norms[numverts][1], &norms[numverts][2] ); numverts++; } numverts--; wxPrintf(_T("%d vertices, %d triangles\n"), numverts, numverts-2); fclose(f); }
bool GERBER_PLOTTER::EndPlot() { char line[1024]; wxString msg; wxASSERT( outputFile ); /* Outfile is actually a temporary file i.e. workFile */ fputs( "M02*\n", outputFile ); fflush( outputFile ); fclose( workFile ); workFile = wxFopen( m_workFilename, wxT( "rt" )); wxASSERT( workFile ); outputFile = finalFile; // Placement of apertures in RS274X while( fgets( line, 1024, workFile ) ) { fputs( line, outputFile ); if( strcmp( strtok( line, "\n\r" ), "G04 APERTURE LIST*" ) == 0 ) { writeApertureList(); fputs( "G04 APERTURE END LIST*\n", outputFile ); } } fclose( workFile ); fclose( finalFile ); ::wxRemoveFile( m_workFilename ); outputFile = 0; return true; }
FILE* fcFileOpener::try_open(const wxString &path, const wxString &name, wxString &filepath) { wxString fullpath ( path + FC_PATH_SEP + name ); wxFileName fn(fullpath); fullpath = fn.GetFullPath(); FILE *fp = wxFopen(fullpath, "rb"); if ( fp ) { _scannedfiles.insert( name ); wxString pathPart = fn.GetPath(); for(size_t i=0; i<_excludePaths.size(); ++i) { if ( pathPart.StartsWith(_excludePaths.at(i) ) ) { ::fclose( fp ); return NULL; } } _matchedfiles.insert( fullpath ); filepath = fullpath; return fp; } return NULL; }
// Load index file int LoadIndex(const wxChar *file_name) { long data; FILE *index_file; wxChar buf[100]; if (file_name == NULL) return 0; wxSprintf(buf, wxT("%s.idx"), file_name); index_file = wxFopen(buf, wxT("r")); if (index_file == NULL) return 0; wxFscanf(index_file, wxT("%ld"), &nitems); for (int i = 0; i < nitems; i++) { wxFscanf(index_file, wxT("%ld"), &data); poem_index[i] = data; } fclose(index_file); return 1; }
int WinEDA_CvpcbFrame::SaveNetList(void) /****************************************/ /* Sauvegarde des fichiers netliste et cmp Le nom complet du fichier Netliste doit etre dans FFileName. Le nom du fichier cmp en est deduit */ { if( savecmp() == 0 ) { DisplayError(this, _("Unable to create component file (.cmp)") ); return(0); } dest = wxFopen(FFileName, wxT("wt") ); if( dest == 0 ) { DisplayError(this, _("Unable to create netlist file") ); return(0); } switch ( output_type ) { default: case 0: case 1: genorcad() ; break; } return(1); }
bool VRML1_MODEL_PARSER::Load( const wxString& aFilename ) { char text[BUFLINE_SIZE]; wxLogTrace( traceVrmlV1Parser, wxT( "Loading: %s" ), GetChars( aFilename ) ); m_file = wxFopen( aFilename, wxT( "rt" ) ); if( m_file == NULL ) return false; // Switch the locale to standard C (needed to print floating point numbers) LOCALE_IO toggle; m_ModelParser->childs.clear(); while( GetNextTag( m_file, text, sizeof(text) ) ) { if( ( *text == '}' ) || ( *text == ']' ) ) { continue; } if( strcmp( text, "Separator" ) == 0 ) { m_model.reset( new S3D_MESH() ); m_ModelParser->childs.push_back( m_model ); read_separator(); } } fclose( m_file ); return true; }
void WinEDA_ModuleEditFrame::Export_Module(MODULE* ptmod, bool createlib) /************************************************************************/ /* Genere 1 fichier type Empreinte a partir de la description du module sur PCB */ { wxString FullFileName, Mask( wxT("*") ); char Line[1025]; FILE * dest; wxString msg, path; if ( ptmod == NULL ) return; ptmod->m_LibRef = ptmod->m_Reference->m_Text; FullFileName = ptmod->m_LibRef; FullFileName += createlib ? LibExtBuffer : EXT_CMP; Mask += createlib ? LibExtBuffer : EXT_CMP; if ( createlib ) path = g_RealLibDirBuffer; FullFileName = EDA_FileSelector( createlib ? _("Create lib") : _("Export Module:"), path, /* Chemin par defaut */ FullFileName, /* nom fichier par defaut */ createlib ? LibExtBuffer : EXT_CMP, /* extension par defaut */ Mask, /* Masque d'affichage */ this, wxSAVE, TRUE ); if ( FullFileName.IsEmpty() ) return; if ( createlib && wxFileExists(FullFileName) ) { msg.Printf( _("File %s exists, OK to replace ?"), FullFileName.GetData()); if( ! IsOK(this, msg) ) return; } /* Generation du fichier Empreinte */ if ( (dest = wxFopen(FullFileName, wxT("wt")) ) == NULL ) { msg.Printf( _("Unable to create <%s>"),FullFileName.GetData()) ; DisplayError(this, msg) ; return ; } fprintf(dest,"%s %s\n", ENTETE_LIBRAIRIE, DateAndTime(Line)); fputs("$INDEX\n",dest); fprintf(dest,"%s\n", CONV_TO_UTF8(ptmod->m_LibRef) ); fputs("$EndINDEX\n",dest); m_Pcb->m_Modules->WriteDescr(dest); fputs("$EndLIBRARY\n",dest); fclose(dest) ; msg.Printf( _("Module exported in file <%s>"),FullFileName.GetData()) ; DisplayInfo(this, msg) ; }
void WriteNetList(WinEDA_DrawFrame * frame, const wxString & FileNameNL, bool use_netnames) /*******************************************************************/ /* Create the netlist file ( Format is given by g_NetFormat ) bool use_netnames is used only for Spice netlist */ { FILE *f = NULL; if ( g_NetFormat < NET_TYPE_CUSTOM1 ) { if ((f = wxFopen(FileNameNL, wxT("wt"))) == NULL) { wxString msg = _("Failed to create file ") + FileNameNL; DisplayError(frame, msg); return; } } wxBusyCursor Busy; switch ( g_NetFormat ) { case NET_TYPE_PCBNEW : WriteNetListPCBNEW(frame, f, TRUE); fclose(f); break; case NET_TYPE_ORCADPCB2 : WriteNetListPCBNEW(frame, f, FALSE); fclose(f); break; case NET_TYPE_CADSTAR : WriteNetListCADSTAR(frame, f); fclose(f); break; case NET_TYPE_SPICE : WriteNetListPspice(frame, f, use_netnames); fclose(f); break; case NET_TYPE_CUSTOM1 : case NET_TYPE_CUSTOM2 : case NET_TYPE_CUSTOM3 : case NET_TYPE_CUSTOM4 : case NET_TYPE_CUSTOM5 : case NET_TYPE_CUSTOM6 : case NET_TYPE_CUSTOM7 : case NET_TYPE_CUSTOM8 : Write_GENERIC_NetList(frame, FileNameNL); break; default: DisplayError(frame, wxT("WriteNetList() err: Unknown Netlist Format")); break; } }
void DIALOG_DRC_CONTROL::OnStartdrcClick( wxCommandEvent& event ) { wxString reportName; if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt { reportName = m_RptFilenameCtrl->GetValue(); if( reportName.IsEmpty() ) { wxCommandEvent junk; OnButtonBrowseRptFileClick( junk ); } reportName = m_RptFilenameCtrl->GetValue(); } SetDrcParmeters(); m_tester->SetSettings( true, // Pad to pad DRC test enabled true, // unconnected pdas DRC test enabled true, // DRC test for zones enabled true, // DRC test for keepout areas enabled reportName, m_CreateRptCtrl->IsChecked() ); DelDRCMarkers(); wxBeginBusyCursor(); // run all the tests, with no UI at this time. m_Messages->Clear(); wxSafeYield(); // Allows time slice to refresh the m_Messages window m_tester->m_pcb->m_Status_Pcb = 0; // Force full connectivity and ratsnest recalculations m_tester->RunTests(m_Messages); m_Notebook->ChangeSelection( 0 ); // display the 1at tab "...Markers ..." // Generate the report if( !reportName.IsEmpty() ) { FILE* fp = wxFopen( reportName, wxT( "w" ) ); writeReport( fp ); fclose( fp ); wxString msg; msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) ); wxString caption( _( "Disk File Report Completed" ) ); wxMessageDialog popupWindow( this, msg, caption ); popupWindow.ShowModal(); } wxEndBusyCursor(); RedrawDrawPanel(); }
bool GERBER_PLOTTER::StartPlot() { wxASSERT( outputFile ); finalFile = outputFile; // the actual gerber file will be created later // Create a temporary filename to store gerber file // note tmpfile() does not work under Vista and W7 in user mode m_workFilename = filename + wxT(".tmp"); workFile = wxFopen( m_workFilename, wxT( "wt" )); outputFile = workFile; wxASSERT( outputFile ); if( outputFile == NULL ) return false; for( unsigned ii = 0; ii < m_headerExtraLines.GetCount(); ii++ ) { if( ! m_headerExtraLines[ii].IsEmpty() ) fprintf( outputFile, "%s\n", TO_UTF8( m_headerExtraLines[ii] ) ); } // Set coordinate format to 3.6 or 4.5 absolute, leading zero omitted // the number of digits for the integer part of coordintes is needed // in gerber format, but is not very important when omitting leading zeros // It is fixed here to 3 (inch) or 4 (mm), but is not actually used int leadingDigitCount = m_gerberUnitInch ? 3 : 4; fprintf( outputFile, "%%FSLAX%d%dY%d%d*%%\n", leadingDigitCount, m_gerberUnitFmt, leadingDigitCount, m_gerberUnitFmt ); fprintf( outputFile, "G04 Gerber Fmt %d.%d, Leading zero omitted, Abs format (unit %s)*\n", leadingDigitCount, m_gerberUnitFmt, m_gerberUnitInch ? "inch" : "mm" ); wxString Title = creator + wxT( " " ) + GetBuildVersion(); fprintf( outputFile, "G04 Created by KiCad (%s) date %s*\n", TO_UTF8( Title ), TO_UTF8( DateAndTime() ) ); /* Mass parameter: unit = INCHES/MM */ if( m_gerberUnitInch ) fputs( "%MOIN*%\n", outputFile ); else fputs( "%MOMM*%\n", outputFile ); // Be sure the usual dark polarity is selected: fputs( "%LPD*%\n", outputFile ); // Specify linear interpol (G01): fputs( "G01*\n", outputFile ); fputs( "G04 APERTURE LIST*\n", outputFile ); return true; }
bool GBR_TO_PCB_EXPORTER::ExportPcb( LAYER_NUM* LayerLookUpTable, int aCopperLayers ) { m_fp = wxFopen( m_pcb_file_name, wxT( "wt" ) ); if( m_fp == NULL ) { wxString msg; msg.Printf( _( "Cannot create file <%s>" ), GetChars( m_pcb_file_name ) ); DisplayError( m_gerbview_frame, msg ); return false; } m_pcbCopperLayersCount = aCopperLayers; writePcbHeader(); // create an image of gerber data // First: non copper layers: GERBER_DRAW_ITEM* gerb_item = m_gerbview_frame->GetItemsList(); for( ; gerb_item; gerb_item = gerb_item->Next() ) { LAYER_NUM layer = gerb_item->GetLayer(); LAYER_NUM pcb_layer_number = LayerLookUpTable[layer]; if( !IsPcbLayer( pcb_layer_number ) ) continue; if( pcb_layer_number > LAST_COPPER_LAYER ) export_non_copper_item( gerb_item, pcb_layer_number ); } // Copper layers fprintf( m_fp, "$TRACK\n" ); gerb_item = m_gerbview_frame->GetItemsList(); for( ; gerb_item; gerb_item = gerb_item->Next() ) { LAYER_NUM layer = gerb_item->GetLayer(); LAYER_NUM pcb_layer_number = LayerLookUpTable[layer]; if( pcb_layer_number < 0 || pcb_layer_number > LAST_COPPER_LAYER ) continue; else export_copper_item( gerb_item, pcb_layer_number ); } fprintf( m_fp, "$EndTRACK\n" ); fprintf( m_fp, "$EndBOARD\n" ); fclose( m_fp ); m_fp = NULL; return true; }
void DIALOG_DRC_CONTROL::OnListUnconnectedClick( wxCommandEvent& event ) { wxString reportName; if( m_CreateRptCtrl->IsChecked() ) // Create a file rpt { reportName = m_RptFilenameCtrl->GetValue(); if( reportName.IsEmpty() ) { wxCommandEvent junk; OnButtonBrowseRptFileClick( junk ); } reportName = m_RptFilenameCtrl->GetValue(); } SetDrcParmeters(); m_tester->SetSettings( true, // Pad to pad DRC test enabled true, // unconnected pdas DRC test enabled true, // DRC test for zones enabled true, // DRC test for keepout areas enabled reportName, m_CreateRptCtrl->IsChecked() ); DelDRCMarkers(); wxBeginBusyCursor(); m_Messages->Clear(); m_tester->ListUnconnectedPads(); m_Notebook->ChangeSelection( 1 ); // display the 2nd tab "Unconnected..." // Generate the report if( !reportName.IsEmpty() ) { FILE* fp = wxFopen( reportName, wxT( "w" ) ); writeReport( fp ); fclose( fp ); wxString msg; msg.Printf( _( "Report file \"%s\" created" ), GetChars( reportName ) ); wxString caption( _( "Disk File Report Completed" ) ); wxMessageDialog popupWindow( this, msg, caption ); popupWindow.ShowModal(); } wxEndBusyCursor(); /* there is currently nothing visible on the DrawPanel for unconnected pads * RedrawDrawPanel(); */ }
void ElfObject::readFile() { int rsize = 0; FILE *f = wxFopen( filename, "rb" ); if (f == NULL) throw Exception::FileNotFound( filename ); fseek(f, 0, SEEK_SET); rsize = fread(data.GetPtr(), 1, data.GetSizeInBytes(), f); fclose( f ); if (rsize < data.GetSizeInBytes()) throw Exception::EndOfStream(filename); }
int WinEDA_FindFrame::ExploreAllLibraries(const wxString & wildmask, wxString & FindList) /****************************************************************************************/ { wxString FullFileName; FILE * file; int nbitems = 0, LineNum = 0; char Line[2048], *name; FullFileName = MakeFileName(g_RealLibDirBuffer, wxT("*"), g_LibExtBuffer); FullFileName = wxFindFirstFile(FullFileName); while ( ! FullFileName.IsEmpty() ) { file = wxFopen(FullFileName, wxT("rt")); if (file == NULL) continue; while (GetLine(file, Line, &LineNum, sizeof(Line)) ) { if (strnicmp(Line, "DEF", 3) == 0) { /* Read one DEF part from library: DEF 74LS00 U 0 30 Y Y 4 0 N */ strtok(Line, " \t\r\n"); name = strtok(NULL, " \t\r\n"); wxString st_name = CONV_FROM_UTF8(name); if( WildCompareString(wildmask, st_name, FALSE) ) { nbitems ++; if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); FindList << _("Found ") << CONV_FROM_UTF8(name) << _(" in lib ") << FullFileName; } } else if (strnicmp(Line, "ALIAS", 5) == 0) { /* Read one ALIAS part from library: ALIAS 74HC00 74HCT00 7400 74LS37 */ strtok(Line, " \t\r\n"); while ( (name = strtok(NULL, " \t\r\n")) != NULL ) { wxString st_name = CONV_FROM_UTF8(name); if( WildCompareString( wildmask, st_name, FALSE) ) { nbitems ++; if ( ! FindList.IsEmpty() ) FindList += wxT("\n"); FindList << _("Found ") << CONV_FROM_UTF8(name) << _(" in lib ") << FullFileName; } } } } fclose(file); FullFileName = wxFindNextFile(); } return nbitems; }
static void ReadDocLib(const wxString & ModLibName ) /***************************************************/ /* Routine de lecture du fichier Doc associe a la librairie ModLibName. Cree en memoire la chaine liste des docs pointee par MList ModLibName = full file Name de la librairie Modules */ { ModList * NewMod; char Line[1024]; FILE * LibDoc; wxString FullModLibName = ModLibName; ChangeFileNameExt(FullModLibName, EXT_DOC); if( (LibDoc = wxFopen(FullModLibName, wxT("rt"))) == NULL ) return; GetLine(LibDoc, Line, NULL, sizeof(Line) -1); if(strnicmp( Line,ENTETE_LIBDOC, L_ENTETE_LIB) != 0) return; /* Lecture de la librairie */ while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) { if( Line[0] != '$' ) continue; if( Line[1] == 'E' ) break;; if( Line[1] == 'M' ) /* Debut decription 1 module */ { NewMod = new ModList(); NewMod->Next = MList; MList = NewMod; while( GetLine(LibDoc,Line, NULL, sizeof(Line) -1) ) { if( Line[0] == '$' ) /* $EndMODULE */ break; switch( Line[0] ) { case 'L': /* LibName */ NewMod->m_Name = CONV_FROM_UTF8(StrPurge(Line+3) ); break; case 'K': /* KeyWords */ NewMod->m_KeyWord = CONV_FROM_UTF8(StrPurge(Line+3) ); break; case 'C': /* Doc */ NewMod->m_Doc = CONV_FROM_UTF8(StrPurge(Line+3) ); break; } } } /* lecture 1 descr module */ } /* Fin lecture librairie */ fclose(LibDoc); }
// Inits the new (or existing) input recording file bool InputRecordingFile::Open(const wxString path, bool fNewOpen, bool fromSaveState) { Close(); wxString mode = L"rb+"; if (fNewOpen) { mode = L"wb+"; MaxFrame = 0; UndoCount = 0; header.Init(); } recordingFile = wxFopen(path, mode); if ( recordingFile == NULL ) { recordingConLog(wxString::Format("[REC]: Movie file opening failed. Error - %s\n", strerror(errno))); return false; } filename = path; if (fNewOpen) { if (fromSaveState) { savestate.fromSavestate = true; FILE* ssFileCheck = wxFopen(path + "_SaveState.p2s", "r"); if (ssFileCheck != NULL) { wxCopyFile(path + "_SaveState.p2s", path + "_SaveState.p2s.bak", false); fclose(ssFileCheck); } StateCopy_SaveToFile(path + "_SaveState.p2s"); } else { sApp.SysExecute(); } } return true; }
/***************************************************************************** * Routine to load the given library name. FullLibName should hold full path * * of file name to open, while LibName should hold only its name. * * IF library already exists, it is NOT reloaded. * * return: new lib or NULL * *****************************************************************************/ LibraryStruct * LoadLibraryName(WinEDA_DrawFrame * frame, const wxString & FullLibName, const wxString & LibName) { int NumOfParts; FILE *f; LibraryStruct *NewLib; PriorQue *Entries; wxString FullFileName; if ( (NewLib = FindLibrary(LibName)) != NULL) { if ( NewLib->m_FullFileName == FullLibName ) return NewLib; FreeCmpLibrary(frame, LibName); } NewLib = NULL; f = wxFopen(FullLibName, wxT("rt") ); if (f == NULL) { wxString msg; msg.Printf( _("Library <%s> not found"), FullLibName.GetData()); DisplayError(frame, msg); return NULL; } NewLib = new LibraryStruct(LIBRARY_TYPE_EESCHEMA, LibName, FullLibName); Entries = LoadLibraryAux(frame, NewLib, f, &NumOfParts); if ( Entries != NULL) { NewLib->m_Entries = Entries; NewLib->m_NumOfParts = NumOfParts; if ( g_LibraryList == NULL ) g_LibraryList = NewLib; else { LibraryStruct *tmplib = g_LibraryList; while ( tmplib->m_Pnext ) tmplib = tmplib->m_Pnext; tmplib->m_Pnext = NewLib; } FullFileName = FullLibName; ChangeFileNameExt(FullFileName, DOC_EXT); LoadDocLib(frame, FullFileName, NewLib->m_Name); } else delete NewLib; fclose(f); return NewLib; }
static bool WriteDiagnosticERC(const wxString & FullFileName) /*********************************************************/ /* Genere le fichier des diagnostics */ { SCH_SCREEN * Window; EDA_BaseStruct * DrawStruct; DrawMarkerStruct * Marker; char Line[256]; static FILE * OutErc; DrawSheetStruct * Sheet; wxString msg; if( (OutErc = wxFopen( FullFileName, wxT("wt"))) == NULL ) return FALSE; DateAndTime(Line); msg = _("ERC control"); fprintf( OutErc, "%s (%s)\n", CONV_TO_UTF8(msg), Line); for( Window = ScreenSch; Window != NULL; Window = (SCH_SCREEN*)Window->Pnext ) { Sheet = (DrawSheetStruct *) Window->m_Parent; msg.Printf( _("\n***** Sheet %d (%s)\n"), Window->m_SheetNumber, Sheet ? Sheet->m_Field[VALUE].m_Text.GetData() : _("Root")); fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); DrawStruct = Window->EEDrawList; for ( ; DrawStruct != NULL; DrawStruct = DrawStruct->Pnext) { if(DrawStruct->m_StructType != DRAW_MARKER_STRUCT_TYPE ) continue; /* Marqueur trouve */ Marker = (DrawMarkerStruct * ) DrawStruct; if( Marker->m_Type != MARQ_ERC ) continue; /* Write diag marqueur */ msg.Printf( _("ERC: %s (X= %2.3f inches, Y= %2.3f inches\n"), Marker->GetComment().GetData(), (float)Marker->m_Pos.x / 1000, (float)Marker->m_Pos.y / 1000); fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); } } msg.Printf( _("\n >> Errors ERC: %d\n"), g_EESchemaVar.NbErrorErc); fprintf( OutErc, "%s", CONV_TO_UTF8(msg)); fclose ( OutErc ); return TRUE; }
int Struct3D_Master:: ReadData(void) /************************************/ { char line[1024], *text; wxString fullfilename; FILE * file; int LineNum = 0; if ( m_Shape3DName.IsEmpty() ) { return 1; } fullfilename = g_RealLibDirBuffer + LIB3D_PATH; fullfilename += m_Shape3DName; #if defined (__WINDOWS__) fullfilename.Replace(UNIX_STRING_DIR_SEP,WIN_STRING_DIR_SEP); #else #if defined (__UNIX__) fullfilename.Replace(WIN_STRING_DIR_SEP,UNIX_STRING_DIR_SEP); #endif #endif file = wxFopen( fullfilename, wxT("rt") ); if ( file == NULL ) { return -1; } while ( GetLine(file, line, &LineNum, 512) ) { text = strtok(line, " \t\n\r"); if ( stricmp (text, "DEF" ) == 0 ) { while ( GetLine(file, line, &LineNum, 512) ) { text = strtok(line, " \t\n\r"); if ( text == NULL ) continue; if ( * text == '}' ) break; if ( stricmp (text, "children") == 0 ) { ReadChildren(file, &LineNum); } } } } fclose (file); return 0; }
/* * Open or create the plot file aFullFilename * return true if success, false if the file cannot be created/opened * * Opens the PDF file in binary mode */ bool PDF_PLOTTER::OpenFile( const wxString& aFullFilename ) { filename = aFullFilename; wxASSERT( !outputFile ); // Open the PDF file in binary mode outputFile = wxFopen( filename, wxT( "wb" ) ); if( outputFile == NULL ) return false ; return true; }
bool SHGToMap(wxChar *filename, wxChar *defaultFile) { // Test the SHG parser HotSpot *hotspots = NULL; int n = ParseSHG(filename, &hotspots); if (n == 0) return false; wxChar buf[100]; wxSnprintf(buf, sizeof(buf), _T("Converting .SHG file to HTML map file: there are %d hotspots in %s."), n, filename); OnInform(buf); wxChar outBuf[256]; wxStrcpy(outBuf, filename); StripExtension(outBuf); wxStrcat(outBuf, _T(".map")); FILE *fd = wxFopen(outBuf, _T("w")); if (!fd) { OnError(_T("Could not open .map file for writing.")); delete[] hotspots; return false; } wxFprintf(fd, _T("default %s\n"), defaultFile); for (int i = 0; i < n; i++) { wxChar *refFilename = _T("??"); TexRef *texRef = FindReference(hotspots[i].szHlpTopic_Macro); if (texRef) refFilename = texRef->refFile; else { wxChar buf[300]; wxSnprintf(buf, sizeof(buf), _T("Warning: could not find hotspot reference %s"), hotspots[i].szHlpTopic_Macro); OnInform(buf); } wxFprintf(fd, _T("rect %s %d %d %d %d\n"), refFilename, (int)hotspots[i].left, (int)hotspots[i].top, (int)hotspots[i].right, (int)hotspots[i].bottom); } wxFprintf(fd, _T("\n")); fclose(fd); delete[] hotspots; return true; }
FILE_OUTPUTFORMATTER::FILE_OUTPUTFORMATTER( const wxString& aFileName, const wxChar* aMode, char aQuoteChar ) throw( IO_ERROR ) : OUTPUTFORMATTER( OUTPUTFMTBUFZ, aQuoteChar ), m_filename( aFileName ) { m_fp = wxFopen( aFileName, aMode ); if( !m_fp ) { wxString msg = wxString::Format( _( "cannot open or save file '%s'" ), m_filename.GetData() ); THROW_IO_ERROR( msg ); } }
bool PLOTTER::OpenFile( const wxString& aFullFilename ) { filename = aFullFilename; wxASSERT( !outputFile ); // Open the file in text mode (not suitable for all plotters // but only for most of them outputFile = wxFopen( filename, wxT( "wt" ) ); if( outputFile == NULL ) return false ; return true; }
bool WriteDiagnosticERC( const wxString& aFullFileName ) { SCH_ITEM* item; SCH_MARKER* marker; static FILE* file; SCH_SHEET_PATH* sheet; wxString msg; int count = 0; if( ( file = wxFopen( aFullFileName, wxT( "wt" ) ) ) == NULL ) return false; msg = _( "ERC report" ); fprintf( file, "%s (%s)\n", TO_UTF8( msg ), TO_UTF8( DateAndTime() ) ); SCH_SHEET_LIST sheetList; for( sheet = sheetList.GetFirst(); sheet != NULL; sheet = sheetList.GetNext() ) { msg.Printf( _( "\n***** Sheet %s\n" ), GetChars( sheet->PathHumanReadable() ) ); fprintf( file, "%s", TO_UTF8( msg ) ); for( item = sheet->LastDrawList(); item != NULL; item = item->Next() ) { if( item->Type() != SCH_MARKER_T ) continue; marker = (SCH_MARKER*) item; if( marker->GetMarkerType() != MARK_ERC ) continue; if( marker->GetMarkerType() == ERR ) count++; msg = marker->GetReporter().ShowReport(); fprintf( file, "%s", TO_UTF8( msg ) ); } } msg.Printf( _( "\n >> Errors ERC: %d\n" ), count ); fprintf( file, "%s", TO_UTF8( msg ) ); fclose( file ); return true; }