View Issue Details

IDProjectCategoryView StatusLast Update
0035271FPCUtilitiespublic2019-04-11 18:03
ReporterBart BroersmaAssigned ToMarco van de Voort 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindowsOS Version10
Product Version3.3.1Product Buildr41788 
Target VersionFixed in Version3.3.1 
Summary0035271: fpcmkcfg tool kills fpc.cfg if commandline parameter equals -o fpc.cfg
DescriptionIf you already have an fpc.cfg file and you run
fpcmkcfg.exe -o fpc.cfg
(in the folder where your fpc.cfg resides) your fpc.cfg is removed (actually a backup is created) and no new fpc.cfg is created (fpcmkcfg errors out).
Steps To ReproduceC:\pp\bin\i386-win32>dir fpc.cfg
...
24-03-2019 00:31 7.572 fpc.cfg

C:\pp\bin\i386-win32>fpcmkcfg -o fpc.cfg
Saved old "fpc.cfg" to "fpc.bak"
Error: Directory of file "fpc.cfg" does not exists. User -p to force creation.

C:\pp\bin\i386-win32>dir fpc.cfg
...
Directory of C:\pp\bin\i386-win32
File Not Found

It just killed my fpc.cfg!
(Yes there is a backup)

This works however:
fpcmkcfg -o .\fpc.cfg
Additional InformationThis works however:
fpcmkcfg -o .\fpc.cfg

I would say that fpc.cfg as commandline parameter should point to the
same file as .\fpc.cfg (as it would do in almost any other program).

I tried to add -v (verbose) to the parameterlist, but unfortunately fpcmkcfg does not tell me which directory does not exist.
TagsNo tags attached.
Fixed in Revision41860
FPCOldBugId
FPCTarget
Attached Files
  • fpcmkcfg.diff (703 bytes)
    Index: utils/fpcmkcfg/fpcmkcfg.pp
    ===================================================================
    --- utils/fpcmkcfg/fpcmkcfg.pp	(revision 41788)
    +++ utils/fpcmkcfg/fpcmkcfg.pp	(working copy)
    @@ -499,7 +499,7 @@
     
     Var
       Fout : Text;
    -  S,BFN : String;
    +  S,BFN,ODir : String;
       I : Integer;
     
     begin
    @@ -527,7 +527,8 @@
         else
           Writeln(Format(SBackupCreated,[ExtractFileName(OutputFileName),ExtractFileName(BFN)]));
         end;
    -  if (OutputFileName<>'') and not DirectoryExists(ExtractFilePath(OutputFileName)) then
    +  ODir:=ExtractFilePath(OutputFileName);
    +  if (OutputFileName<>'') and (ODir<>'') and not DirectoryExists(ODir) then
         begin
         if CreateDir then
           begin
    
    fpcmkcfg.diff (703 bytes)

Activities

Bart Broersma

2019-03-25 11:15

reporter   ~0115035

Last edited: 2019-03-25 11:15

View 2 revisions

Line 530 of fpcmkcfg.pp:

if (OutputFileName<>'') and not DirectoryExists(ExtractFilePath(OutputFileName)) then

ExtractFilePath(OutputFileName) where OutputFileName='fpc.cfg' will return an empty string.
Therefore DirectoryExists will return False.

Somewhere an ExpandFilename(OutputFileName) is needed (or allow ExtractFilePath(OutputFileName) to be empty).

Probably the installer will supply fpcmkcfg with a fully qualified filename for that parameter, but when you build fpc from sources you manually have to invoke fpcmkcfg and then current behaviour makes no sense to me.

Bart Broersma

2019-03-25 11:28

reporter   ~0115037

Furhtermore it would be nice if it would not delete outputfile before it checked if output directory actually existed.

Joost van der Sluis

2019-03-25 11:39

manager   ~0115038

It should just continue when ExtractFilePath(OutputFileName) is empty. Can you write a patch for it?

Bart Broersma

2019-03-27 16:00

reporter  

fpcmkcfg.diff (703 bytes)
Index: utils/fpcmkcfg/fpcmkcfg.pp
===================================================================
--- utils/fpcmkcfg/fpcmkcfg.pp	(revision 41788)
+++ utils/fpcmkcfg/fpcmkcfg.pp	(working copy)
@@ -499,7 +499,7 @@
 
 Var
   Fout : Text;
-  S,BFN : String;
+  S,BFN,ODir : String;
   I : Integer;
 
 begin
@@ -527,7 +527,8 @@
     else
       Writeln(Format(SBackupCreated,[ExtractFileName(OutputFileName),ExtractFileName(BFN)]));
     end;
-  if (OutputFileName<>'') and not DirectoryExists(ExtractFilePath(OutputFileName)) then
+  ODir:=ExtractFilePath(OutputFileName);
+  if (OutputFileName<>'') and (ODir<>'') and not DirectoryExists(ODir) then
     begin
     if CreateDir then
       begin
fpcmkcfg.diff (703 bytes)

Bart Broersma

2019-03-27 16:00

reporter   ~0115082

Last edited: 2019-04-10 17:16

View 2 revisions

Possible patch attached.

Bart Broersma

2019-04-10 17:16

reporter   ~0115397

Bump?

Marco van de Voort

2019-04-11 10:03

manager   ~0115421

Applied, thanks

Issue History

Date Modified Username Field Change
2019-03-25 10:58 Bart Broersma New Issue
2019-03-25 11:15 Bart Broersma Note Added: 0115035
2019-03-25 11:15 Bart Broersma Note Edited: 0115035 View Revisions
2019-03-25 11:28 Bart Broersma Note Added: 0115037
2019-03-25 11:39 Joost van der Sluis Note Added: 0115038
2019-03-27 16:00 Bart Broersma File Added: fpcmkcfg.diff
2019-03-27 16:00 Bart Broersma Note Added: 0115082
2019-04-10 17:16 Bart Broersma Note Edited: 0115082 View Revisions
2019-04-10 17:16 Bart Broersma Note Added: 0115397
2019-04-11 10:03 Marco van de Voort Fixed in Revision => 41860
2019-04-11 10:03 Marco van de Voort Note Added: 0115421
2019-04-11 10:03 Marco van de Voort Status new => resolved
2019-04-11 10:03 Marco van de Voort Fixed in Version => 3.3.1
2019-04-11 10:03 Marco van de Voort Resolution open => fixed
2019-04-11 10:03 Marco van de Voort Assigned To => Marco van de Voort
2019-04-11 18:03 Bart Broersma Status resolved => closed