Skip to content

Commit 134b148

Browse files
author
DelphiDabbler
committed
New TAppInfo methods to get config file names. Updated other units to use.
This avoids duplication of code across units.
1 parent 3339fdc commit 134b148

File tree

3 files changed

+23
-8
lines changed

3 files changed

+23
-8
lines changed

Src/FirstRun.UInstallInfo.pas

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2008-2013, Peter Johnson (www.delphidabbler.com).
6+
* Copyright (C) 2008-2016, Peter Johnson (www.delphidabbler.com).
77
*
88
* $Rev$
99
* $Date$
@@ -170,13 +170,12 @@ constructor TInstallInfo.Create;
170170

171171
function TInstallInfo.CurrentCommonConfigFileName: string;
172172
begin
173-
Result := IncludeTrailingPathDelimiter(TAppInfo.CommonAppDir)
174-
+ 'Common.config';
173+
Result := TAppInfo.AppConfigFileName;
175174
end;
176175

177176
class function TInstallInfo.CurrentUserConfigFileName: string;
178177
begin
179-
Result := MakeFullUserPath(UserConfigFileNames[CurrentVersionID]);
178+
Result := TAppInfo.UserConfigFileName;
180179
end;
181180

182181
class function TInstallInfo.CurrentUserDatabaseDir: string;

Src/UAppInfo.pas

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2005-2013, Peter Johnson (www.delphidabbler.com).
6+
* Copyright (C) 2005-2016, Peter Johnson (www.delphidabbler.com).
77
*
88
* $Rev$
99
* $Date$
@@ -97,6 +97,12 @@ TAppInfo = class(TNoConstructObject)
9797
{Returns fully specified name of CodeSnip's help file.
9898
@return Name of help file.
9999
}
100+
class function AppConfigFileName: string;
101+
{Returns fully specified name of application config file.
102+
}
103+
class function UserConfigFileName: string;
104+
{Returns fully specified name of per-user config file.
105+
}
100106
class function ProgramReleaseInfo: string;
101107
{Gets information about the current program release. Includes any special
102108
build information if present in version information.
@@ -146,6 +152,11 @@ implementation
146152

147153
{ TAppInfo }
148154

155+
class function TAppInfo.AppConfigFileName: string;
156+
begin
157+
Result := CommonAppDir + '\Common.config';
158+
end;
159+
149160
class function TAppInfo.AppDataDir: string;
150161
{Returns the directory where CodeSnip stores the "database" files.
151162
@return Full path to database sub directory.
@@ -347,6 +358,11 @@ class function TAppInfo.UserAppDir: string;
347358
{$ENDIF}
348359
end;
349360

361+
class function TAppInfo.UserConfigFileName: string;
362+
begin
363+
Result := UserAppDir + '\User.config';
364+
end;
365+
350366
class function TAppInfo.UserDataDir: string;
351367
{Returns the directory where CodeSnip stores the user's "database" files.
352368
@return Full path to database sub directory.

Src/USettings.pas

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
44
* obtain one at http://mozilla.org/MPL/2.0/
55
*
6-
* Copyright (C) 2006-2013, Peter Johnson (www.delphidabbler.com).
6+
* Copyright (C) 2006-2016, Peter Johnson (www.delphidabbler.com).
77
*
88
* $Rev$
99
* $Date$
@@ -595,9 +595,9 @@ function TIniSettingsBase.StorageName(
595595
begin
596596
case Storage of
597597
ssUser:
598-
Result := TAppInfo.UserAppDir + '\User.config';
598+
Result := TAppInfo.UserConfigFileName;
599599
ssCommon:
600-
Result := TAppInfo.CommonAppDir + '\Common.config';
600+
Result := TAppInfo.AppConfigFileName;
601601
else
602602
raise EBug.Create(ClassName + '.StorageName: unknown storage type');
603603
end;

0 commit comments

Comments
 (0)