Configtool: enforce correct configuration file names.

Previously one could save a board or printer configuration with
a name which wouldn't allow to load it again.
This commit is contained in:
jbernardis 2015-02-07 23:38:12 -05:00 committed by Markus Hitter
parent 706ccf0637
commit 73f7e43227
2 changed files with 16 additions and 0 deletions

View File

@ -422,6 +422,14 @@ class BoardPanel(wx.Panel):
dlg.Destroy()
return False
if not os.path.basename(path).startswith("board."):
dlg = wx.MessageDialog(self, "Illegal file name: %s.\n"
"File name must begin with \"board.\"" % path,
"Illegal file name", wx.OK + wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return False
ext = os.path.splitext(os.path.basename(path))[1]
self.dir = os.path.dirname(path)

View File

@ -301,6 +301,14 @@ class PrinterPanel(wx.Panel):
dlg.Destroy()
return False
if not os.path.basename(path).startswith("printer."):
dlg = wx.MessageDialog(self, "Illegal file name: %s.\n"
"File name must begin with \"printer.\"" % path,
"Illegal file name", wx.OK + wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return False
ext = os.path.splitext(os.path.basename(path))[1]
self.dir = os.path.dirname(path)