Loading eeschema/files-io.cpp +47 −50 Original line number Original line Diff line number Diff line Loading @@ -48,8 +48,9 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bool aCreateBackupFile ) bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bool aCreateBackupFile ) { { wxString msg; wxString msg; wxFileName schematicFileName, backupFileName; wxFileName schematicFileName; FILE* f; FILE* f; bool success; if( aScreen == NULL ) if( aScreen == NULL ) aScreen = GetScreen(); aScreen = GetScreen(); Loading @@ -58,25 +59,40 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo if( aScreen->GetFileName().IsEmpty() ) if( aScreen->GetFileName().IsEmpty() ) aSaveUnderNewName = true; aSaveUnderNewName = true; if( aSaveUnderNewName == false ) /* Construct the name of the file to be saved */ { schematicFileName = aScreen->GetFileName(); schematicFileName = aScreen->GetFileName(); if( aSaveUnderNewName ) { wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(), schematicFileName.GetFullName(), SchematicFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return false; schematicFileName = dlg.GetPath(); if( schematicFileName.GetExt() != SchematicFileExtension ) schematicFileName.SetExt( SchematicFileExtension ); } else { // Sheet file names are relative to the root sheet path which is the current // Sheet file names are relative to the root sheet path which is the current // working directory. The IsWritable funtion expects the path to be set. // working directory. The IsWritable funtion expects the path to be set. if( schematicFileName.GetPath().IsEmpty() ) if( schematicFileName.GetPath().IsEmpty() ) schematicFileName.Assign( wxFileName::GetCwd(), schematicFileName.GetFullName() ); schematicFileName.Assign( wxFileName::GetCwd(), schematicFileName.GetFullName() ); } if( aCreateBackupFile ) { backupFileName = schematicFileName; if( !IsWritable( schematicFileName ) ) if( !IsWritable( schematicFileName ) ) return false; return false; /* Rename the old file to a '.bak' one: */ /* Create backup if requested */ if( schematicFileName.FileExists() ) if( aCreateBackupFile && schematicFileName.FileExists() ) { { wxFileName backupFileName = schematicFileName; /* Rename the old file to a '.bak' one: */ backupFileName.SetExt( SchematicBackupFileExtension ); backupFileName.SetExt( SchematicBackupFileExtension ); if( backupFileName.FileExists() ) if( backupFileName.FileExists() ) wxRemoveFile( backupFileName.GetFullPath() ); wxRemoveFile( backupFileName.GetFullPath() ); Loading @@ -88,26 +104,8 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo DisplayError( this, msg ); DisplayError( this, msg ); } } } } } } else { schematicFileName = aScreen->GetFileName(); wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(), schematicFileName.GetFullName(), SchematicFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return false; aScreen->SetFileName( dlg.GetPath() ); schematicFileName = dlg.GetPath(); if( !IsWritable( schematicFileName ) ) return false; } /* Save */ wxLogTrace( traceAutoSave, wxLogTrace( traceAutoSave, wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) ); wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) ); Loading @@ -119,18 +117,11 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo return false; return false; } } if( aSaveUnderNewName ) success = aScreen->Save( f ); aScreen->SetFileName( schematicFileName.GetFullPath() ); bool success = aScreen->Save( f ); if( !success ) if( success ) { DisplayError( this, _( "File write operation failed." ) ); } else { { // Delete auto save file on successful save. // Delete auto save file. wxFileName autoSaveFileName = schematicFileName; wxFileName autoSaveFileName = schematicFileName; autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() ); autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() ); Loading @@ -143,13 +134,19 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo wxRemoveFile( autoSaveFileName.GetFullPath() ); wxRemoveFile( autoSaveFileName.GetFullPath() ); } } // Update the screen and frame info. if( aSaveUnderNewName ) aScreen->SetFileName( schematicFileName.GetFullPath() ); aScreen->ClrSave(); aScreen->ClrSave(); aScreen->ClrModify(); aScreen->ClrModify(); wxString msg; msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) ); msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) ); SetStatusText( msg, 0 ); SetStatusText( msg, 0 ); } } else { DisplayError( this, _( "File write operation failed." ) ); } fclose( f ); fclose( f ); Loading Loading
eeschema/files-io.cpp +47 −50 Original line number Original line Diff line number Diff line Loading @@ -48,8 +48,9 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bool aCreateBackupFile ) bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bool aCreateBackupFile ) { { wxString msg; wxString msg; wxFileName schematicFileName, backupFileName; wxFileName schematicFileName; FILE* f; FILE* f; bool success; if( aScreen == NULL ) if( aScreen == NULL ) aScreen = GetScreen(); aScreen = GetScreen(); Loading @@ -58,25 +59,40 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo if( aScreen->GetFileName().IsEmpty() ) if( aScreen->GetFileName().IsEmpty() ) aSaveUnderNewName = true; aSaveUnderNewName = true; if( aSaveUnderNewName == false ) /* Construct the name of the file to be saved */ { schematicFileName = aScreen->GetFileName(); schematicFileName = aScreen->GetFileName(); if( aSaveUnderNewName ) { wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(), schematicFileName.GetFullName(), SchematicFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return false; schematicFileName = dlg.GetPath(); if( schematicFileName.GetExt() != SchematicFileExtension ) schematicFileName.SetExt( SchematicFileExtension ); } else { // Sheet file names are relative to the root sheet path which is the current // Sheet file names are relative to the root sheet path which is the current // working directory. The IsWritable funtion expects the path to be set. // working directory. The IsWritable funtion expects the path to be set. if( schematicFileName.GetPath().IsEmpty() ) if( schematicFileName.GetPath().IsEmpty() ) schematicFileName.Assign( wxFileName::GetCwd(), schematicFileName.GetFullName() ); schematicFileName.Assign( wxFileName::GetCwd(), schematicFileName.GetFullName() ); } if( aCreateBackupFile ) { backupFileName = schematicFileName; if( !IsWritable( schematicFileName ) ) if( !IsWritable( schematicFileName ) ) return false; return false; /* Rename the old file to a '.bak' one: */ /* Create backup if requested */ if( schematicFileName.FileExists() ) if( aCreateBackupFile && schematicFileName.FileExists() ) { { wxFileName backupFileName = schematicFileName; /* Rename the old file to a '.bak' one: */ backupFileName.SetExt( SchematicBackupFileExtension ); backupFileName.SetExt( SchematicBackupFileExtension ); if( backupFileName.FileExists() ) if( backupFileName.FileExists() ) wxRemoveFile( backupFileName.GetFullPath() ); wxRemoveFile( backupFileName.GetFullPath() ); Loading @@ -88,26 +104,8 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo DisplayError( this, msg ); DisplayError( this, msg ); } } } } } } else { schematicFileName = aScreen->GetFileName(); wxFileDialog dlg( this, _( "Schematic Files" ), wxGetCwd(), schematicFileName.GetFullName(), SchematicFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); if( dlg.ShowModal() == wxID_CANCEL ) return false; aScreen->SetFileName( dlg.GetPath() ); schematicFileName = dlg.GetPath(); if( !IsWritable( schematicFileName ) ) return false; } /* Save */ wxLogTrace( traceAutoSave, wxLogTrace( traceAutoSave, wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) ); wxT( "Saving file <" ) + schematicFileName.GetFullPath() + wxT( ">" ) ); Loading @@ -119,18 +117,11 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo return false; return false; } } if( aSaveUnderNewName ) success = aScreen->Save( f ); aScreen->SetFileName( schematicFileName.GetFullPath() ); bool success = aScreen->Save( f ); if( !success ) if( success ) { DisplayError( this, _( "File write operation failed." ) ); } else { { // Delete auto save file on successful save. // Delete auto save file. wxFileName autoSaveFileName = schematicFileName; wxFileName autoSaveFileName = schematicFileName; autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() ); autoSaveFileName.SetName( wxT( "$" ) + schematicFileName.GetName() ); Loading @@ -143,13 +134,19 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo wxRemoveFile( autoSaveFileName.GetFullPath() ); wxRemoveFile( autoSaveFileName.GetFullPath() ); } } // Update the screen and frame info. if( aSaveUnderNewName ) aScreen->SetFileName( schematicFileName.GetFullPath() ); aScreen->ClrSave(); aScreen->ClrSave(); aScreen->ClrModify(); aScreen->ClrModify(); wxString msg; msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) ); msg.Printf( _( "File %s saved" ), GetChars( aScreen->GetFileName() ) ); SetStatusText( msg, 0 ); SetStatusText( msg, 0 ); } } else { DisplayError( this, _( "File write operation failed." ) ); } fclose( f ); fclose( f ); Loading