LazUtils: Move GetAppConfigDirUTF8 and GetAppConfigFileUTF8 to LazFileUtils (and inline them in FileUtil).

Part of the ongoing restructuring of LazUtils.

git-svn-id: trunk@41589 -
This commit is contained in:
bart 2013-06-08 15:00:18 +00:00
parent 555ede86aa
commit 7ac6639fb4
3 changed files with 27 additions and 14 deletions

View File

@ -198,23 +198,13 @@ end;
function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string; function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string;
begin begin
Result:=SysToUTF8(SysUtils.GetAppConfigDir(Global)); Result := LazFileUtils.GetAppConfigDirUTF8(Global, Create);
if Result='' then exit;
if Create and not ForceDirectoriesUTF8(Result) then
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
end; end;
function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean; function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean;
CreateDir: boolean): string; CreateDir: boolean): string;
var
Dir: string;
begin begin
Result:=SysToUTF8(SysUtils.GetAppConfigFile(Global,SubDir)); Result := LazFileUtils.GetAppConfigFileUTF8(Global, SubDir, CreateDir);
if not CreateDir then exit;
Dir:=ExtractFilePath(Result);
if Dir='' then exit;
if not ForceDirectoriesUTF8(Dir) then
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Dir]));
end; end;
function SysErrorMessageUTF8(ErrorCode: Integer): String; function SysErrorMessageUTF8(ErrorCode: Integer): String;

View File

@ -264,9 +264,9 @@ function FileCreateUTF8(Const FileName : string; Rights: Cardinal) : THandle; ov
function ParamStrUTF8(Param: Integer): string; inline; function ParamStrUTF8(Param: Integer): string; inline;
function GetEnvironmentStringUTF8(Index: Integer): string; inline; function GetEnvironmentStringUTF8(Index: Integer): string; inline;
function GetEnvironmentVariableUTF8(const EnvVar: string): String; inline; function GetEnvironmentVariableUTF8(const EnvVar: string): String; inline;
function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string; function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string; inline;
function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false; function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false;
CreateDir: boolean = false): string; CreateDir: boolean = false): string; inline;
// other // other
function SysErrorMessageUTF8(ErrorCode: Integer): String; inline; function SysErrorMessageUTF8(ErrorCode: Integer): String; inline;

View File

@ -99,6 +99,10 @@ Function FileCreateUtf8(Const FileName : String; ShareMode : Integer; Rights : C
function FileSizeUtf8(const Filename: string): int64; function FileSizeUtf8(const Filename: string): int64;
function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string;
function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean = false;
CreateDir: boolean = false): string;
// UNC paths // UNC paths
function IsUNCPath(const {%H-}Path: String): Boolean; function IsUNCPath(const {%H-}Path: String): Boolean;
@ -884,7 +888,26 @@ begin
end; end;
function GetAppConfigDirUTF8(Global: Boolean; Create: boolean = false): string;
begin
Result:=SysToUTF8(SysUtils.GetAppConfigDir(Global));
if Result='' then exit;
if Create and not ForceDirectoriesUTF8(Result) then
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
end;
function GetAppConfigFileUTF8(Global: Boolean; SubDir: boolean;
CreateDir: boolean): string;
var
Dir: string;
begin
Result:=SysToUTF8(SysUtils.GetAppConfigFile(Global,SubDir));
if not CreateDir then exit;
Dir:=ExtractFilePath(Result);
if Dir='' then exit;
if not ForceDirectoriesUTF8(Dir) then
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Dir]));
end;