Changeset 647 for trunk/Packages/CevoComponents/Directories.pas
- Timestamp:
- Feb 19, 2025, 9:18:32 AM (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/Directories.pas
r447 r647 4 4 5 5 var 6 HomeDir: string;7 6 DataDir: string; 8 7 LocaleCode: string = ''; … … 16 15 function GetSoundsDir: string; 17 16 function GetAiDir: string; 17 function GetAppShareDir(Dir: string): string; 18 function GetAppShareFile(FileName: string): string; 18 19 19 20 … … 21 22 22 23 uses 23 FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils; 24 FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils, LazFileUtils, Forms; 25 26 function GetAppShareDir(Dir: string): string; 27 {$IFDEF UNIX} 28 var 29 NewDir: string; 30 {$ENDIF} 31 begin 32 Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Dir; 33 {$IFDEF UNIX} 34 // If installed in Linux system then try to use different installation directory 35 if not DirectoryExists(Result) then begin 36 NewDir := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' + 37 DirectorySeparator + 'share' + DirectorySeparator + 38 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Dir; 39 if DirectoryExists(NewDir) then Result := NewDir; 40 end; 41 {$ENDIF} 42 end; 43 44 function GetAppShareFile(FileName: string): string; 45 {$IFDEF UNIX} 46 var 47 NewFile: string; 48 {$ENDIF} 49 begin 50 Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + FileName; 51 {$IFDEF UNIX} 52 // If installed in Linux system then try to use different installation directory 53 if not FileExists(Result) then begin 54 NewFile := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' + 55 DirectorySeparator + 'share' + DirectorySeparator + 56 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + FileName; 57 if FileExists(NewFile) then Result := NewFile; 58 end; 59 {$ENDIF} 60 end; 24 61 25 62 function GetLocale: string; … … 57 94 58 95 if LocaleCode <> 'en' then begin 59 Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path;96 Result := GetAppShareFile('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path); 60 97 if not DirectoryExists(Result) and not FileExists(Result) then 61 Result := HomeDir + Path;62 end else Result := HomeDir + Path;98 Result := GetAppShareFile(Path); 99 end else Result := GetAppShareFile(Path); 63 100 end; 64 101 … … 92 129 begin 93 130 LocaleCode := ''; 94 HomeDir := ExtractFilePath(ParamStr(0));95 131 96 132 AppDataDir := GetAppConfigDir(False); 97 if AppDataDir = '' then DataDir := HomeDir133 if AppDataDir = '' then DataDir := GetAppShareDir('') 98 134 else begin 99 135 if not DirectoryExists(AppDataDir) then ForceDirectories(AppDataDir); … … 105 141 function GetSavedDir(Home: Boolean = False): string; 106 142 begin 107 if Home then Result := HomeDir + 'Saved'143 if Home then Result := GetAppShareDir('Saved') 108 144 else Result := DataDir + 'Saved'; 109 145 end; … … 111 147 function GetMapsDir(Home: Boolean = False): string; 112 148 begin 113 if Home then Result := HomeDir + 'Maps'149 if Home then Result := GetAppShareDir('Maps') 114 150 else Result := DataDir + 'Maps'; 115 151 end; … … 117 153 function GetGraphicsDir: string; 118 154 begin 119 Result := HomeDir + 'Graphics';155 Result := GetAppShareDir('Graphics'); 120 156 end; 121 157 122 158 function GetSoundsDir: string; 123 159 begin 124 Result := HomeDir + 'Sounds';160 Result := GetAppShareDir('Sounds'); 125 161 end; 126 162 127 163 function GetAiDir: string; 128 164 begin 129 Result := HomeDir + 'AI';165 Result := GetAppShareDir('AI'); 130 166 end; 131 167
Note:
See TracChangeset
for help on using the changeset viewer.