From a0f1e0e9db4b0edee45018c47a08761916af0ce6 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 7 Jun 2008 20:40:48 +0200 Subject: Revised UTF-8 filenames support --- USearch.pas | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'USearch.pas') diff --git a/USearch.pas b/USearch.pas index 4cd49f1..a451fb6 100644 --- a/USearch.pas +++ b/USearch.pas @@ -591,8 +591,8 @@ begin AEngine := TLocalTreeEngine.Create; b := True; end; - if b then FMain.EditViewFileInternal(Self, string(PDataItem(FileList.Selected.AsPointer(0))^.AName), AEngine, True, False) - else Application.MessageBox(Format(LANGCannotLoadFile, [ANSIToUTF8(string(PDataItem(FileList.Selected.AsPointer(0))^.AName))]), [mbOK], mbError, mbNone, mbOK); + if b then FMain.EditViewFileInternal(Self, string(PDataItem(FileList.Selected.AsPointer(0))^.FDisplayName), AEngine, True, False) + else Application.MessageBox(Format(LANGCannotLoadFile, [string(PDataItem(FileList.Selected.AsPointer(0))^.FDisplayName)]), [mbOK], mbError, mbNone, mbOK); if AEngine is TVFSEngine then (AEngine as TVFSEngine).VFSClose; AEngine.Free; end; @@ -600,7 +600,7 @@ end; procedure TFSearch.GoToFileButtonClick(Sender: TObject); begin if not (Assigned(FileList.Selected) and Assigned(FileList.Selected.AsPointer(0))) then Exit; - GoToFile := string(PDataItem(FileList.Selected.AsPointer(0))^.AName); + GoToFile := string(PDataItem(FileList.Selected.AsPointer(0))^.FDisplayName); if Assigned(PDataItem(FileList.Selected.AsPointer(0))^.LnkPointTo) then GoToFileArchive := string(PDataItem(FileList.Selected.AsPointer(0))^.LnkPointTo); ModalResult := mbApply; @@ -683,9 +683,9 @@ begin // Set the parameters FSearchThread := TSearchThread.Create(Engine); with FSearchThread do begin - FStartPath := UTF8ToANSI(SearchInEntry.Text); - FFileMask := UTF8ToANSI(FileMaskEntry.Entry.Text); - FStringFind := UTF8ToANSI(FindTextEntry.Text); + FStartPath := UTF8ToStr(SearchInEntry.Text); + FFileMask := UTF8ToStr(FileMaskEntry.Entry.Text); + FStringFind := FindTextEntry.Text; FDontLeaveFS := not StayCurrentFSCheckButton.Checked; FCaseSensitiveMask := CaseSensitiveMatchCheckButton.Checked; FCaseSensitiveStrings := CaseSensitiveCheckButton.Checked; @@ -745,7 +745,7 @@ begin Sleep(ConstInternalProgressTimer); FSearchThread.GUIMutex.Acquire; - StatusLabel.Caption := Format('%s %s', [LANGSearch_SearchInProgress, FSearchThread.CurrentDir]); + StatusLabel.Caption := Format('%s %s', [LANGSearch_SearchInProgress, StrToUTF8(FSearchThread.CurrentDir)]); FSearchThread.GUIMutex.Release; StatusLabel.UseMarkup := True; @@ -758,8 +758,8 @@ begin ListItem := FileList.Items.Add; ListItem.SetValue(0, FSearchThread.FList[i]); if PDataItem(FSearchThread.FList[i])^.LnkPointTo <> nil - then ListItem.SetValue(1, Format('%s%s%s', [string(PDataItem(FSearchThread.FList[i])^.LnkPointTo), ConstPathDelim, string(PDataItem(FSearchThread.FList[i])^.AName)])) - else ListItem.SetValue(1, string(PDataItem(FSearchThread.FList[i])^.AName)); + then ListItem.SetValue(1, Format('%s%s%s', [StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.LnkPointTo)), ConstPathDelim, StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.FDisplayName))])) + else ListItem.SetValue(1, StrToUTF8(string(PDataItem(FSearchThread.FList[i])^.FDisplayName))); if i mod 30 = 0 then Application.ProcessMessages; // Refresh UI only after some amount of items added end; LastItems := FSearchThread.FList.Count; @@ -883,7 +883,7 @@ begin Data := LocalList[i]; // DebugMsg([' --- found ', Data^.AName]); - FileName := Data^.AName; + FileName := Data^.FName; Matches := True; // Test if the file is on the same FS @@ -924,8 +924,8 @@ begin if Matches then begin GUIMutex.Acquire; FList.Add(LocalList[i]); - Libc.free(Data^.AName); - PDataItem(LocalList[i])^.AName := strdup(PChar(StartDir + FileName)); + Libc.free(Data^.FDisplayName); + PDataItem(LocalList[i])^.FDisplayName := strdup(PChar(StartDir + FileName)); if Assigned(PDataItem(LocalList[i])^.LnkPointTo) then begin Libc.free(PDataItem(LocalList[i])^.LnkPointTo); PDataItem(LocalList[i])^.LnkPointTo := nil; @@ -940,14 +940,14 @@ begin // Handle archives if (not Data^.IsDir) and FSearchArchives and (not (FEngine is TVFSEngine)) then begin b := False; - s := ANSIUpperCase(Trim(Copy(FileName, LastDelimiter('.', FileName) + 1, Length(FileName) - LastDelimiter('.', FileName)))); + s := WideUpperCase(Trim(Copy(FileName, LastDelimiter('.', FileName) + 1, Length(FileName) - LastDelimiter('.', FileName)))); if (Length(s) > 1) and (s[1] = '.') then Delete(s, 1, 1); if PluginList.Count > 0 then for k := 0 to PluginList.Count - 1 do begin Plugin := TVFSPlugin(PluginList[k]); if Length(Plugin.Extensions) > 0 then for j := 0 to Length(Plugin.Extensions) - 1 do - if AnsiCompareText(Plugin.Extensions[j], s) = 0 then begin + if WideCompareText(Plugin.Extensions[j], s) = 0 then begin b := True; Break; end; -- cgit v1.2.3