Changeset 648 for trunk/Packages/CevoComponents/Directories.pas
- Timestamp:
- Feb 19, 2025, 9:43:42 AM (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Packages/CevoComponents/Directories.pas
r647 r648 15 15 function GetSoundsDir: string; 16 16 function GetAiDir: string; 17 function GetAppShareDir(Dir: string): string; 18 function GetAppShareFile(FileName: string): string; 17 function GetAppSharePath(Path: string): string; 19 18 20 19 … … 24 23 FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils, LazFileUtils, Forms; 25 24 26 function GetAppShare Dir(Dir: string): string;25 function GetAppSharePath(Path: string): string; 27 26 {$IFDEF UNIX} 28 27 var 29 New Dir: string;28 NewPath: string; 30 29 {$ENDIF} 31 30 begin 32 Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Dir;31 Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Path; 33 32 {$IFDEF UNIX} 34 33 // If installed in Linux system then try to use different installation directory 35 34 if not DirectoryExists(Result) then begin 36 New Dir:= ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +35 NewPath := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' + 37 36 DirectorySeparator + 'share' + DirectorySeparator + 38 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Dir; 39 if DirectoryExists(NewDir) then Result := NewDir; 37 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Path; 38 if DirectoryExists(NewPath) then begin 39 Result := NewPath; 40 Exit; 41 end; 40 42 end; 41 {$ENDIF}42 end;43 44 function GetAppShareFile(FileName: string): string;45 {$IFDEF UNIX}46 var47 NewFile: string;48 {$ENDIF}49 begin50 Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + FileName;51 {$IFDEF UNIX}52 // If installed in Linux system then try to use different installation directory53 43 if not FileExists(Result) then begin 54 New File:= ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +44 NewPath := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' + 55 45 DirectorySeparator + 'share' + DirectorySeparator + 56 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + FileName; 57 if FileExists(NewFile) then Result := NewFile; 46 ExtractFileNameOnly(Application.ExeName) + DirectorySeparator + Path; 47 if FileExists(NewPath) then begin 48 Result := NewPath; 49 Exit; 50 end; 58 51 end; 59 52 {$ENDIF} … … 94 87 95 88 if LocaleCode <> 'en' then begin 96 Result := GetAppShare File('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path);89 Result := GetAppSharePath('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path); 97 90 if not DirectoryExists(Result) and not FileExists(Result) then 98 Result := GetAppShare File(Path);99 end else Result := GetAppShare File(Path);91 Result := GetAppSharePath(Path); 92 end else Result := GetAppSharePath(Path); 100 93 end; 101 94 … … 131 124 132 125 AppDataDir := GetAppConfigDir(False); 133 if AppDataDir = '' then DataDir := GetAppShare Dir('')126 if AppDataDir = '' then DataDir := GetAppSharePath('') 134 127 else begin 135 128 if not DirectoryExists(AppDataDir) then ForceDirectories(AppDataDir); … … 141 134 function GetSavedDir(Home: Boolean = False): string; 142 135 begin 143 if Home then Result := GetAppShare Dir('Saved')136 if Home then Result := GetAppSharePath('Saved') 144 137 else Result := DataDir + 'Saved'; 145 138 end; … … 147 140 function GetMapsDir(Home: Boolean = False): string; 148 141 begin 149 if Home then Result := GetAppShare Dir('Maps')142 if Home then Result := GetAppSharePath('Maps') 150 143 else Result := DataDir + 'Maps'; 151 144 end; … … 153 146 function GetGraphicsDir: string; 154 147 begin 155 Result := GetAppShare Dir('Graphics');148 Result := GetAppSharePath('Graphics'); 156 149 end; 157 150 158 151 function GetSoundsDir: string; 159 152 begin 160 Result := GetAppShare Dir('Sounds');153 Result := GetAppSharePath('Sounds'); 161 154 end; 162 155 163 156 function GetAiDir: string; 164 157 begin 165 Result := GetAppShare Dir('AI');158 Result := GetAppSharePath('AI'); 166 159 end; 167 160
Note:
See TracChangeset
for help on using the changeset viewer.