Browse Source

Avoid CopyFile over itself fp.cfg after copying fp.ini, thus avoiding misleading ErrorBox

git-svn-id: trunk@29476 -
pierre 10 years ago
parent
commit
c9f73354af
1 changed files with 12 additions and 4 deletions
  1. 12 4
      ide/fpini.pas

+ 12 - 4
ide/fpini.pas

@@ -32,6 +32,7 @@ procedure SetPrinterDevice(const Device: string);
 implementation
 implementation
 
 
 uses
 uses
+  sysutils, { used for SameFileName function }
   Dos,Objects,Drivers,
   Dos,Objects,Drivers,
   FVConsts,
   FVConsts,
   Version,
   Version,
@@ -233,10 +234,17 @@ begin
                ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+IniName),nil)
                ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+IniName),nil)
              else
              else
                IniFileName:=CurDir+IniName;
                IniFileName:=CurDir+IniName;
-             if CopyFile(SwitchesPath,CurDir+SwitchesName)=false then
-               ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+SwitchesName),nil)
-             else
-               SwitchesPath:=CurDir+SwitchesName;
+             { copy also SwitchesPath to current dir, but only if
+               1) SwitchesPath exists
+               2) SwitchesPath is different from CurDir+SwitchesName }
+             if ExistsFile(SwitchesPath) and
+                not SameFileName(SwitchesPath,CurDir+SwitchesName) then
+               begin
+                 if CopyFile(SwitchesPath,CurDir+SwitchesName)=false then
+                   ErrorBox(FormatStrStr(msg_errorwritingfile,CurDir+SwitchesName),nil)
+                 else
+                   SwitchesPath:=CurDir+SwitchesName;
+               end;
            end;
            end;
        end
        end
      else
      else