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:
bart 2013-12-29 15:40:16 +00:00
parent 6ae4e11538
commit e2f0b20bc8

View File

@ -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);