Przeglądaj źródła

* ide makes use of %APPDATA% if available to store configuration files, same logic as on unix, resolves #20870

git-svn-id: trunk@19929 -
florian 13 lat temu
rodzic
commit
25e38983cf
2 zmienionych plików z 30 dodań i 3 usunięć
  1. 28 1
      ide/fpini.pas
  2. 2 2
      ide/fpvars.pas

+ 28 - 1
ide/fpini.pas

@@ -31,7 +31,7 @@ procedure SetPrinterDevice(const Device: string);
 
 implementation
 
-uses 
+uses
   Dos,Objects,Drivers,
   FVConsts,
   Version,
@@ -151,6 +151,24 @@ begin
   StartupDir:=CompleteDir(FExpand('.'));
 {$ifndef unix}
   IDEDir:=CompleteDir(DirOf(system.Paramstr(0)));
+{$ifdef WINDOWS}
+  SystemIDEDir:=IDEDir;
+  if GetEnv('APPDATA')<>'' then
+    begin
+      IDEdir:=CompleteDir(FExpand(GetEnv('APPDATA')+'/fp'));
+      If Not ExistsDir(IDEdir) Then
+        begin
+          IDEDir:=SystemIDEDir;
+          if Not ExistsDir(IDEDir) then
+            begin
+              if DirOf(system.paramstr(0))<>'' then
+                IDEDir:=CompleteDir(DirOf(system.ParamStr(0)))
+              else
+                IDEDir:=StartupDir;
+            end;
+        end;
+   end;
+{$endif WINDOWS}
 {$else}
   SystemIDEDir:=FExpand(DirOf(system.paramstr(0))+'../lib/fpc/'+version_string+'/ide/text');
   If Not ExistsDir(SystemIDEdir) Then
@@ -560,6 +578,15 @@ begin
         MkDir(FExpand('~/.fp'));
    end;
 {$endif Unix}
+{$ifdef WINDOWS}
+  if not FromSaveAs and (DirOf(IniFileName)=DirOf(SystemIDEDir)) and
+    (GetEnv('APPDATA')<>'') then
+    begin
+      IniFileName:=FExpand(GetEnv('APPDATA')+'/fp/'+IniName);
+      If not ExistsDir(DirOf(IniFileName)) then
+        MkDir(FExpand(GetEnv('APPDATA')+'/fp'));
+   end;
+{$endif WINDOWS}
   New(INIFile, Init(IniFileName));
   { Files }
   { avoid keeping old files }

+ 2 - 2
ide/fpvars.pas

@@ -90,9 +90,9 @@ const ClipboardWindow  : PClipboardWindow = nil;
       ShowStatusOnError: boolean = true;
       StartupDir       : string = '.'+DirSep;
       IDEDir           : string = '.'+DirSep;
-{$ifdef Unix}
+{$if defined(WINDOWS) or defined(Unix)}
       SystemIDEDir     : string = '';
-{$endif Unix}
+{$endif defined(WINDOWS) or defined(Unix)}
       INIFileName      : string = ININame;
       SwitchesPath     : string = SwitchesName;
       CtrlMouseAction  : integer = acTopicSearch;