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;