Browse Source

* Reading the fppkg-settings should not depend on the global
OnGetApplicationName event

git-svn-id: trunk@35701 -

joost 8 years ago
parent
commit
3b58c328c7

+ 3 - 3
packages/fppkg/src/pkgfppkg.pp

@@ -169,16 +169,16 @@ begin
   else
     begin
       // Now try if a local config-file exists
-      cfgfile:=GetAppConfigFile(False,False);
+      cfgfile:=GetFppkgConfigFile(False,False);
       if not FileExists(cfgfile) then
         begin
           // If not, try to find a global configuration file
-          cfgfile:=GetAppConfigFile(True,False);
+          cfgfile:=GetFppkgConfigFile(True,False);
           if not FileExists(cfgfile) then
             begin
               // Create a new configuration file
               if not IsSuperUser then // Make a local, not global, configuration file
-                cfgfile:=GetAppConfigFile(False,False);
+                cfgfile:=GetFppkgConfigFile(False,False);
               ForceDirectories(ExtractFilePath(cfgfile));
               FOptions.SaveToFile(cfgfile);
               GeneratedConfig:=true;

+ 38 - 3
packages/fppkg/src/pkgglobals.pp

@@ -96,6 +96,10 @@ var
   LogHandler: TLogProc;
   ErrorHandler: TPkgErrorProc;
 
+function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
+function GetFppkgConfigDir(Global : Boolean): string;
+
+
 Implementation
 
 // define use_shell to use sysutils.executeprocess
@@ -420,11 +424,42 @@ begin
   end;
 end;
 
+function GetFppkgConfigFile(Global : Boolean; SubDir : Boolean): string;
+var
+  StoredOnGetApplicationName: TGetAppNameEvent;
+  StoredOnGetVendorName: TGetVendorNameEvent;
+begin
+  StoredOnGetApplicationName := OnGetApplicationName;
+  StoredOnGetVendorName := OnGetVendorName;
+  try
+    OnGetApplicationName := @FPPkgGetApplicationName;
+    OnGetVendorName := @FPPkgGetVendorName;
+    result := GetAppConfigFile(Global, SubDir);
+  finally
+    OnGetApplicationName := StoredOnGetApplicationName;
+    OnGetVendorName := StoredOnGetVendorName;
+  end;
+end;
+
+function GetFppkgConfigDir(Global : Boolean): string;
+var
+  StoredOnGetApplicationName: TGetAppNameEvent;
+  StoredOnGetVendorName: TGetVendorNameEvent;
+begin
+  StoredOnGetApplicationName := OnGetApplicationName;
+  StoredOnGetVendorName := OnGetVendorName;
+  try
+    OnGetApplicationName := @FPPkgGetApplicationName;
+    OnGetVendorName := @FPPkgGetVendorName;
+    result := GetAppConfigDir(Global);
+  finally
+    OnGetApplicationName := StoredOnGetApplicationName;
+    OnGetVendorName := StoredOnGetVendorName;
+  end;
+end;
+
 
 initialization
-  OnGetVendorName:=@FPPkgGetVendorName;
-  OnGetApplicationName:=@FPPkgGetApplicationName;
   LogHandler := @LogCmd;
   ErrorHandler := @ErrorCmd;
-
 end.

+ 3 - 3
packages/fppkg/src/pkgoptions.pp

@@ -614,7 +614,7 @@ begin
     LocalRepository:='{UserDir}.fppkg/';
 {$else}
   if IsSuperUser then
-    LocalRepository:=IncludeTrailingPathDelimiter(GetAppConfigDir(true))
+    LocalRepository:=IncludeTrailingPathDelimiter(GetFppkgConfigDir(true))
   else
     LocalRepository:='{AppConfigDir}';
 {$endif}
@@ -754,7 +754,7 @@ end;
 constructor TFppkgOptions.Create;
 begin
   FOptionParser := TTemplateParser.Create;
-  FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
+  FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
   FOptionParser.Values['UserDir'] := GetUserDir;
 
   FSectionList := TFppkgOptionSectionList.Create;
@@ -899,7 +899,7 @@ end;
 constructor TCompilerOptions.Create;
 begin
   FOptionParser := TTemplateParser.Create;
-  FOptionParser.Values['AppConfigDir'] := GetAppConfigDir(false);
+  FOptionParser.Values['AppConfigDir'] := GetFppkgConfigDir(false);
   FOptionParser.Values['UserDir'] := GetUserDir;
   {$ifdef unix}
   FLocalInstallDir:='{LocalPrefix}'+'lib'+PathDelim+'fpc'+PathDelim+'{CompilerVersion}'+PathDelim;