Bug in FsRenMovFileW?

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: Hacker, petermad, Stefan2, white

User avatar
Dalai
Power Member
Power Member
Posts: 9999
Joined: 2005-01-28, 22:17 UTC
Location: Meiningen (Südthüringen)

Re: Bug in FsRenMovFileW?

Post by *Dalai »

2Kelimion
Sorry, I confused moving files on local and remote locations. For some reason I thought that FsRenMovFile is called even when moving files from WFX to local FS, but that's done via FsGetFile. Moving a file from WFX to local FS is not supported by TC, so you can ignore that.

Here's what I do in my Startups plugin: If old and new names are different, the plugin checks if the new name already exists in the WFX. It's necessary to have some kind of data structure that holds all objects to be able to do that. If the new name exists, a call to RequestProc is done to ask the user whether or not to overwrite the file. Only if that returns true (the user wants to overwrite), the existing file is deleted and the operation continues.

The explanation in (Delphi) code:

Code: Select all

if (Lnew <> Lold.Name) then begin
    { Try to get the startup with the new name, in case it already exists }
    Lidx:= Glob_StartupMgr.GetStartupIndexByDisplayName(Lnew + '.' + Lold.Extension);
    Lexists:= Lidx > -1;
    Loverwrite:= False;

    { Display a confirmation dialog in case a startup with the new name
      already exists. It's a pity that TC doesn't handle this
      situation by itself, see this topic in offical TC forum:
      [BUG?] WFX. FsRenMovFile. FS_FILE_EXISTS
      http://ghisler.ch/board/viewtopic.php?t=19444 }
    if Lexists then begin
        with LangFile do begin
          Lmsg:= TranslateStartupLocationToStr(Lold.Location);
          Lmsg:= Format(Translate(LANGCOMMONSECTION, DLG_OVERWRITE, DLG_CONFIRM_MOVE), [Lnew, Lmsg]);
        end;
        Loverwrite:= PluginShowConfirmation(PLUGINNAME, Lmsg); { call to RequestProc }
        { Delete the existing startup }
        if Loverwrite then
            Glob_StartupMgr.DeleteStartup(Lidx);
    end;
    { Rename the startup if overwrite or no startup with the new name exists }
    if NOT Lexists or Loverwrite then
        Lold.Name:= Lnew;
end;
Result:= FS_FILE_OK;
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64

Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Kelimion
Junior Member
Junior Member
Posts: 11
Joined: 2022-06-21, 11:54 UTC

Re: Bug in FsRenMovFileW?

Post by *Kelimion »

Dalai wrote: 2025-05-04, 15:02 UTC 2Kelimion
Sorry, I confused moving files on local and remote locations. For some reason I thought that FsRenMovFile is called even when moving files from WFX to local FS, but that's done via FsGetFile.
Ah, that makes sense. And I can see why you'd do what you did for your plugin.
Dalai wrote: 2025-05-04, 15:02 UTC Moving a file from WFX to local FS is not supported by TC, so you can ignore that.
It is supported, and I do. FsGetFile will set "FS_COPYFLAGS_MOVE: The plugin needs to delete the remote file after uploading".
User avatar
AntonyD
Power Member
Power Member
Posts: 1636
Joined: 2006-11-04, 15:30 UTC
Location: Russian Federation

Re: Bug in FsRenMovFileW?

Post by *AntonyD »

That is, no matter how We look at this situation - but there is clearly a very useful reason to revise what has been done
and re-write the code. At least within the framework of some new beta version of the plugin engine...
#146217 personal license
Post Reply