Procházet zdrojové kódy

+ Patch from Michalis Kamburelis to implement correct config dir, following basedir-spec

git-svn-id: trunk@1719 -
michael před 20 roky
rodič
revize
59d3cd95a8
1 změnil soubory, kde provedl 15 přidání a 4 odebrání
  1. 15 4
      rtl/unix/sysutils.pp

+ 15 - 4
rtl/unix/sysutils.pp

@@ -1083,7 +1083,19 @@ Function GetHomeDir : String;
 begin
   Result:=GetEnvironmentVariable('HOME');
   If (Result<>'') then
-  Result:=IncludeTrailingPathDelimiter(Result);
+    Result:=IncludeTrailingPathDelimiter(Result);
+end;
+
+{ Follows base-dir spec, 
+  see [http://freedesktop.org/Standards/basedir-spec].
+  Always ends with PathDelim. }
+Function XdgConfigHome : String;
+begin
+  Result:=GetEnvironmentVariable('XDG_CONFIG_HOME');
+  if (Result='') then
+    Result:=GetHomeDir + '.config/' 
+  else
+    Result:=IncludeTrailingPathDelimiter(Result);
 end;
 
 Function GetAppConfigDir(Global : Boolean) : String;
@@ -1092,7 +1104,7 @@ begin
   If Global then
     Result:=SysConfigDir
   else
-    Result:=GetHomeDir+ApplicationName;
+    Result:=XdgConfigHome + ApplicationName;
 end;
 
 Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;
@@ -1114,8 +1126,7 @@ begin
       end
     else
       begin
-      Result:=GetHomeDir;
-      Result:=Result+'.'+ApplicationName;
+      Result:=XdgConfigHome + ApplicationName + ConfigExtension;
       end;
     end;
 end;