Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
fa0a5141
Commit
fa0a5141
authored
Feb 13, 2013
by
Antia Puentes
Committed by
jean-pierre charras
Feb 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eeschema: force file ext in"Sheet Save As" command (Bug #1122212 )
parent
330b8bff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
50 deletions
+47
-50
files-io.cpp
eeschema/files-io.cpp
+47
-50
No files found.
eeschema/files-io.cpp
View file @
fa0a5141
...
...
@@ -48,8 +48,9 @@
bool
SCH_EDIT_FRAME
::
SaveEEFile
(
SCH_SCREEN
*
aScreen
,
bool
aSaveUnderNewName
,
bool
aCreateBackupFile
)
{
wxString
msg
;
wxFileName
schematicFileName
,
backupFileName
;
wxFileName
schematicFileName
;
FILE
*
f
;
bool
success
;
if
(
aScreen
==
NULL
)
aScreen
=
GetScreen
();
...
...
@@ -58,56 +59,53 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
if
(
aScreen
->
GetFileName
().
IsEmpty
()
)
aSaveUnderNewName
=
true
;
if
(
aSaveUnderNewName
==
false
)
{
schematicFileName
=
aScreen
->
GetFileName
();
/* Construct the name of the file to be saved */
schematicFileName
=
aScreen
->
GetFileName
();
// 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.
if
(
schematicFileName
.
GetPath
().
IsEmpty
()
)
schematicFileName
.
Assign
(
wxFileName
::
GetCwd
(),
schematicFileName
.
GetFullName
()
);
if
(
aSaveUnderNewName
)
{
wxFileDialog
dlg
(
this
,
_
(
"Schematic Files"
),
wxGetCwd
(),
schematicFileName
.
GetFullName
(),
SchematicFileWildcard
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
if
(
aCreateBackupFile
)
{
backupFileName
=
schematicFileName
;
if
(
dlg
.
ShowModal
()
==
wxID_CANCEL
)
return
false
;
if
(
!
IsWritable
(
schematicFileName
)
)
return
false
;
schematicFileName
=
dlg
.
GetPath
();
/* Rename the old file to a '.bak' one: */
if
(
schematicFileName
.
FileExists
()
)
{
backupFileName
.
SetExt
(
SchematicBackupFileExtension
);
if
(
backupFileName
.
FileExists
()
)
wxRemoveFile
(
backupFileName
.
GetFullPath
()
);
if
(
!
wxRenameFile
(
schematicFileName
.
GetFullPath
(),
backupFileName
.
GetFullPath
()
)
)
{
msg
.
Printf
(
_
(
"Could not save backup of file <%s>"
),
GetChars
(
schematicFileName
.
GetFullPath
()
)
);
DisplayError
(
this
,
msg
);
}
}
}
if
(
schematicFileName
.
GetExt
()
!=
SchematicFileExtension
)
schematicFileName
.
SetExt
(
SchematicFileExtension
);
}
else
{
schematicFileName
=
aScreen
->
GetFileName
();
// 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.
if
(
schematicFileName
.
GetPath
().
IsEmpty
()
)
schematicFileName
.
Assign
(
wxFileName
::
GetCwd
(),
schematicFileName
.
GetFullName
()
);
}
wxFileDialog
dlg
(
this
,
_
(
"Schematic Files"
),
wxGetCwd
(),
schematicFileName
.
GetFullName
(),
SchematicFileWildcard
,
wxFD_SAVE
|
wxFD_OVERWRITE_PROMPT
);
if
(
!
IsWritable
(
schematicFileName
)
)
return
false
;
if
(
dlg
.
ShowModal
()
==
wxID_CANCEL
)
return
false
;
/* Create backup if requested */
if
(
aCreateBackupFile
&&
schematicFileName
.
FileExists
()
)
{
wxFileName
backupFileName
=
schematicFileName
;
aScreen
->
SetFileName
(
dlg
.
GetPath
()
);
schematicFileName
=
dlg
.
GetPath
();
/* Rename the old file to a '.bak' one: */
backupFileName
.
SetExt
(
SchematicBackupFileExtension
);
if
(
backupFileName
.
FileExists
()
)
wxRemoveFile
(
backupFileName
.
GetFullPath
()
);
if
(
!
IsWritable
(
schematicFileName
)
)
return
false
;
if
(
!
wxRenameFile
(
schematicFileName
.
GetFullPath
(),
backupFileName
.
GetFullPath
()
)
)
{
msg
.
Printf
(
_
(
"Could not save backup of file <%s>"
),
GetChars
(
schematicFileName
.
GetFullPath
()
)
);
DisplayError
(
this
,
msg
);
}
}
/* Save */
wxLogTrace
(
traceAutoSave
,
wxT
(
"Saving file <"
)
+
schematicFileName
.
GetFullPath
()
+
wxT
(
">"
)
);
...
...
@@ -119,18 +117,11 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
return
false
;
}
if
(
aSaveUnderNewName
)
aScreen
->
SetFileName
(
schematicFileName
.
GetFullPath
()
);
success
=
aScreen
->
Save
(
f
);
bool
success
=
aScreen
->
Save
(
f
);
if
(
!
success
)
{
DisplayError
(
this
,
_
(
"File write operation failed."
)
);
}
else
if
(
success
)
{
// Delete auto save file
on successful save
.
// Delete auto save file.
wxFileName
autoSaveFileName
=
schematicFileName
;
autoSaveFileName
.
SetName
(
wxT
(
"$"
)
+
schematicFileName
.
GetName
()
);
...
...
@@ -143,13 +134,19 @@ bool SCH_EDIT_FRAME::SaveEEFile( SCH_SCREEN* aScreen, bool aSaveUnderNewName, bo
wxRemoveFile
(
autoSaveFileName
.
GetFullPath
()
);
}
// Update the screen and frame info.
if
(
aSaveUnderNewName
)
aScreen
->
SetFileName
(
schematicFileName
.
GetFullPath
()
);
aScreen
->
ClrSave
();
aScreen
->
ClrModify
();
wxString
msg
;
msg
.
Printf
(
_
(
"File %s saved"
),
GetChars
(
aScreen
->
GetFileName
()
)
);
SetStatusText
(
msg
,
0
);
}
else
{
DisplayError
(
this
,
_
(
"File write operation failed."
)
);
}
fclose
(
f
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment