Ignore:
Timestamp:
Feb 19, 2025, 9:43:42 AM (3 days ago)
Author:
chronos
Message:
  • Fixed: Tribes were not propertly detected in usr/share/c-evo directory.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Packages/CevoComponents/Directories.pas

    r647 r648  
    1515function GetSoundsDir: string;
    1616function GetAiDir: string;
    17 function GetAppShareDir(Dir: string): string;
    18 function GetAppShareFile(FileName: string): string;
     17function GetAppSharePath(Path: string): string;
    1918
    2019
     
    2423  FileUtil, LCLIntf, LCLType, LCLProc, LazUTF8, SysUtils, LazFileUtils, Forms;
    2524
    26 function GetAppShareDir(Dir: string): string;
     25function GetAppSharePath(Path: string): string;
    2726{$IFDEF UNIX}
    2827var
    29   NewDir: string;
     28  NewPath: string;
    3029{$ENDIF}
    3130begin
    32   Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Dir;
     31  Result := ExtractFileDir(Application.ExeName) + DirectorySeparator + Path;
    3332  {$IFDEF UNIX}
    3433  // If installed in Linux system then try to use different installation directory
    3534  if not DirectoryExists(Result) then begin
    36     NewDir := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
     35    NewPath := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
    3736      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;
    4042  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
    5343  if not FileExists(Result) then begin
    54     NewFile := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
     44    NewPath := ExtractFileDir(Application.ExeName) + DirectorySeparator + '..' +
    5545      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;
    5851  end;
    5952  {$ENDIF}
     
    9487
    9588  if LocaleCode <> 'en' then begin
    96     Result := GetAppShareFile('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path);
     89    Result := GetAppSharePath('Localization' + DirectorySeparator + LocaleCodeDir + DirectorySeparator + Path);
    9790    if not DirectoryExists(Result) and not FileExists(Result) then
    98       Result := GetAppShareFile(Path);
    99   end else Result := GetAppShareFile(Path);
     91      Result := GetAppSharePath(Path);
     92  end else Result := GetAppSharePath(Path);
    10093end;
    10194
     
    131124
    132125  AppDataDir := GetAppConfigDir(False);
    133   if AppDataDir = '' then DataDir := GetAppShareDir('')
     126  if AppDataDir = '' then DataDir := GetAppSharePath('')
    134127  else begin
    135128    if not DirectoryExists(AppDataDir) then ForceDirectories(AppDataDir);
     
    141134function GetSavedDir(Home: Boolean = False): string;
    142135begin
    143   if Home then Result := GetAppShareDir('Saved')
     136  if Home then Result := GetAppSharePath('Saved')
    144137    else Result := DataDir + 'Saved';
    145138end;
     
    147140function GetMapsDir(Home: Boolean = False): string;
    148141begin
    149   if Home then Result := GetAppShareDir('Maps')
     142  if Home then Result := GetAppSharePath('Maps')
    150143    else Result := DataDir + 'Maps';
    151144end;
     
    153146function GetGraphicsDir: string;
    154147begin
    155   Result := GetAppShareDir('Graphics');
     148  Result := GetAppSharePath('Graphics');
    156149end;
    157150
    158151function GetSoundsDir: string;
    159152begin
    160   Result := GetAppShareDir('Sounds');
     153  Result := GetAppSharePath('Sounds');
    161154end;
    162155
    163156function GetAiDir: string;
    164157begin
    165   Result := GetAppShareDir('AI');
     158  Result := GetAppSharePath('AI');
    166159end;
    167160
Note: See TracChangeset for help on using the changeset viewer.