mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-26 02:42:46 +02:00
LazUtils: better fix for encoding of string returned by GetAppConfigFileUTF8
(Use WideString variant of GetSpecialDir which retruns UTF8: copy/paste error in r43495 #cba214753b) git-svn-id: trunk@43611 -
This commit is contained in:
parent
6ae4e11538
commit
e2f0b20bc8
@ -644,13 +644,13 @@ Var
|
|||||||
WS: WideString;
|
WS: WideString;
|
||||||
Len: SizeInt;
|
Len: SizeInt;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result := '';
|
||||||
if (CFGDLLHandle=0) then
|
if (CFGDLLHandle = 0) then
|
||||||
InitDLL;
|
InitDLL;
|
||||||
If (SHGetFolderPathW<>Nil) then
|
If (SHGetFolderPathW <> Nil) then
|
||||||
begin
|
begin
|
||||||
FillChar(APath, SizeOf(APath), #0);
|
FillChar(APath, SizeOf(APath), #0);
|
||||||
if SHGetFolderPathW(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0])=S_OK then
|
if SHGetFolderPathW(0,ID or CSIDL_FLAG_CREATE,0,0,@APATH[0]) = S_OK then
|
||||||
begin
|
begin
|
||||||
Len := StrLen(APath);
|
Len := StrLen(APath);
|
||||||
SetLength(WS, Len);
|
SetLength(WS, Len);
|
||||||
@ -673,19 +673,19 @@ end;
|
|||||||
function GetAppConfigDirWide(Global: Boolean; Create: boolean = false): string;
|
function GetAppConfigDirWide(Global: Boolean; Create: boolean = false): string;
|
||||||
begin
|
begin
|
||||||
If Global then
|
If Global then
|
||||||
Result:=GetWindowsSpecialDir(CSIDL_COMMON_APPDATA)
|
Result := GetWindowsSpecialDirW(CSIDL_COMMON_APPDATA)
|
||||||
else
|
else
|
||||||
Result:=GetWindowsSpecialDir(CSIDL_LOCAL_APPDATA);
|
Result := GetWindowsSpecialDirW(CSIDL_LOCAL_APPDATA);
|
||||||
If (Result<>'') then
|
If (Result <> '') then
|
||||||
begin
|
begin
|
||||||
if VendorName<>'' then
|
if VendorName <> '' then
|
||||||
Result := AppendPathDelim(Result+VendorName);
|
Result := AppendPathDelim(Result + VendorName);
|
||||||
Result := AppendPathDelim(Result+ApplicationName);
|
Result := AppendPathDelim(Result + ApplicationName);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
Result := AppendPathDelim(DGetAppConfigDir(Global));
|
Result := AppendPathDelim(DGetAppConfigDir(Global));
|
||||||
if Result = '' then exit;
|
if Result = '' then exit;
|
||||||
if Create and not ForceDirectories(Result) then
|
if Create and not ForceDirectoriesUtf8(Result) then
|
||||||
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
|
raise EInOutError.Create(Format(lrsUnableToCreateConfigDirectoryS,[Result]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -694,9 +694,9 @@ function GetAppConfigFileWide(Global: Boolean; SubDir: boolean;
|
|||||||
var
|
var
|
||||||
Dir: string;
|
Dir: string;
|
||||||
begin
|
begin
|
||||||
Result := SysToUTF8(GetAppConfigDirWide(Global));
|
Result := GetAppConfigDirWide(Global);
|
||||||
if SubDir then
|
if SubDir then
|
||||||
Result := AppendPathDelim(Result+'Config');
|
Result := AppendPathDelim(Result + 'Config');
|
||||||
Result := Result + ApplicationName + ConfigExtension;
|
Result := Result + ApplicationName + ConfigExtension;
|
||||||
if not CreateDir then exit;
|
if not CreateDir then exit;
|
||||||
Dir := ExtractFilePath(Result);
|
Dir := ExtractFilePath(Result);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user