Changeset 184 for trunk/Core.pas


Ignore:
Timestamp:
Jan 14, 2025, 11:19:27 AM (10 days ago)
Author:
chronos
Message:
  • Fixed: Data directories detection on Linux.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r181 r184  
    3838    procedure TargetMessageExecute(Text: string);
    3939  public
    40     DataDir: string;
     40    BaseDir: string;
     41    ExamplesDir: string;
    4142    Project: TProject;
    4243    Targets: TTargets;
     
    6566  Core: TCore;
    6667
     68const
     69  ExamplesDirName = 'Examples';
     70  LanguagesDirName = 'Languages';
     71
    6772
    6873implementation
     
    9499{$IFDEF UNIX}
    95100const
    96   LinuxDataDir = '/usr/share/LazFuck';
    97   LinuxLanguagesDir = LinuxDataDir + '/Languages';
     101  LinuxDataDir = '../share/LazFuck';
     102var
     103  NewDir: string;
    98104{$ENDIF}
    99105begin
    100   DataDir := '';
     106  BaseDir := ExcludeTrailingPathDelimiter(ExtractFilePath(ParamStr(0)));
     107  Translator.POFilesFolder := BaseDir + DirectorySeparator + LanguagesDirName;
     108  ExamplesDir := BaseDir + DirectorySeparator + ExamplesDirName;
     109
    101110  {$IFDEF UNIX}
    102   // If installed in Linux system then use installation shared game directory for data files
    103   if DirectoryExists(LinuxDataDir) then
    104     DataDir := LinuxDataDir
    105     else DataDir := GetCurrentDir;
    106111  // If installed in Linux system then use installation directory for po files
    107   if not DirectoryExists(Translator.POFilesFolder) and DirectoryExists(LinuxLanguagesDir) then
    108     Translator.POFilesFolder := LinuxLanguagesDir;
     112  NewDir := ExpandFileName(BaseDir + DirectorySeparator + LinuxDataDir +
     113    DirectorySeparator + LanguagesDirName);
     114  if not DirectoryExists(Translator.POFilesFolder) and DirectoryExists(NewDir) then
     115    Translator.POFilesFolder := NewDir;
     116
     117  // If installed in Linux system then use installation directory for po files
     118  NewDir := ExpandFileName(BaseDir + DirectorySeparator + LinuxDataDir +
     119    DirectorySeparator + ExamplesDirName);
     120  if not DirectoryExists(ExamplesDir) and DirectoryExists(NewDir) then
     121    ExamplesDir := NewDir;
    109122  {$ENDIF}
    110123
Note: See TracChangeset for help on using the changeset viewer.