FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

EmptyDirectory: New API to leave top level dir intact

Open FanDjango opened this issue 3 years ago • 1 comments

New function overload (Wiki API will need update) to allow users of DeleteDirectory to optionally make this function leave the top level directory intact.

Using this will prevent use of any highly optimised server side RMDIR functionality on the uppermost level, but that's the price.

Usage:

		/// <summary>
		/// Deletes the specified directory and all its contents.
		/// </summary>
		/// <param name="path">The full or relative path of the directory to delete</param>
		/// <param name="options">Useful to delete hidden files or dot-files.</param>
		/// <param name="deleteFinalDir">Delete the top level dir too</param>
		public void DeleteDirectory(string path, FtpListOption options, bool deleteFinalDir = true)

The default for deleteFinalDir is true, which is the normal behaviour right now.

FanDjango avatar Sep 20 '22 14:09 FanDjango

Looks fantastic! Thanks again for your wonderful work. Added some comments.

robinrodricks avatar Sep 21 '22 09:09 robinrodricks

I will rebase so we can see the net changes

FanDjango avatar Sep 21 '22 17:09 FanDjango

Yes, the rebase removed all the reference to the serverhandlers and so on, because now with the new API function, things are a whole lot less complicated (instead of the insane overloading). Thanks @robinrodricks

FanDjango avatar Sep 21 '22 17:09 FanDjango

If you want this to be a separate .cs, can you do that?

FanDjango avatar Sep 21 '22 19:09 FanDjango

I would have merged this PR and changed it myself, but since its a draft I cannot. (EDIT: I did it!)

Anyway, can you please rename the API to EmptyDirectory as DeleteDirectoryContents is much too long, and I don't bother much with API discoverability. I prefer short names ("TransferFile" rather than "FXPTransferFile" and so on). I like ClearDirectory too, however it is very similar in meaning to DeleteDirectory so I can see some users getting confused about it.


As you can see I try to use the shortest name possible, ideally in this format <verb> <term>

  • DirectoryExists
  • CreateDirectory
  • DeleteDirectory
  • EmptyDirectory
  • MoveDirectory

robinrodricks avatar Sep 22 '22 09:09 robinrodricks

Oh wait I got it.

robinrodricks avatar Sep 22 '22 09:09 robinrodricks

I'll change it, thanks a lot for this.

robinrodricks avatar Sep 22 '22 09:09 robinrodricks

I have just tested it, and it still works. Sorry I forgot about adding the interface definitions. I shall do the Wiki addition, in the next few days and I ask you to review that then...

FanDjango avatar Sep 22 '22 17:09 FanDjango

Released!

https://www.nuget.org/packages/FluentFTP/41.0.0

robinrodricks avatar Oct 02 '22 08:10 robinrodricks