source: trunk/Directories.pas@ 71

Last change on this file since 71 was 64, checked in by chronos, 9 years ago
  • Added: New configuration dialog for selecting interface language.
  • Added: Czech and Deutch language recoded to UTF-8.
File size: 1.8 KB
Line 
1{$INCLUDE Switches.inc}
2unit Directories;
3
4interface
5
6var
7 HomeDir, DataDir: string;
8 LocaleCode: string;
9
10function LocalizedFilePath(const Path: string): string;
11
12
13implementation
14
15uses
16 LCLIntf, LCLType, SysUtils, FileUtil;
17
18var
19 AppDataDir: string;
20 src, dst: TSearchRec;
21
22function DirectoryExists(path: string): boolean;
23var
24 f: TSearchRec;
25begin
26 result := FindFirst(path, faDirectory, f) = 0;
27end;
28
29function LocalizedFilePath(const Path: string): string;
30begin
31 if LocaleCode <> '' then begin
32 Result := HomeDir + 'Localization' + DirectorySeparator + LocaleCode + DirectorySeparator + Path;
33 if not FileExists(Result) then
34 Result := HomeDir + Path;
35 end else Result := HomeDir + Path;
36end;
37
38procedure InitUnit;
39begin
40 LocaleCode := '';
41 HomeDir := ExtractFilePath(ParamStr(0));
42
43 AppDataDir := GetAppConfigDir(False);
44 if AppDataDir = '' then
45 DataDir := HomeDir
46 else
47 begin
48 if not DirectoryExists(AppDataDir) then
49 CreateDir(AppDataDir);
50 DataDir := AppDataDir;
51 end;
52 if not DirectoryExists(DataDir + 'Saved') then
53 CreateDir(DataDir + 'Saved');
54 if not DirectoryExists(DataDir + 'Maps') then
55 CreateDir(DataDir + 'Maps');
56
57 // Copy appdata if not done yet
58 if FindFirst(HomeDir + 'AppData' + DirectorySeparator + 'Saved' + DirectorySeparator + '*.cevo', $21, src) = 0 then
59 repeat
60 if (FindFirst(DataDir + 'Saved' + DirectorySeparator + src.Name, $21, dst) <> 0) or
61 (dst.Time < src.Time) then
62 CopyFile(PChar(HomeDir + 'AppData' + DirectorySeparator + 'Saved' + DirectorySeparator + src.Name),
63 PChar(DataDir + 'Saved' + DirectorySeparator + src.Name), false);
64 until FindNext(src) <> 0;
65end;
66
67initialization
68
69InitUnit;
70
71end.
Note: See TracBrowser for help on using the repository browser.