nandlabs / go-commons

A common collection of utilities for Go programming language
Apache License 2.0
2 stars 2 forks source link

VFile Create new DeleteAll Fn #77

Closed nandagopalan closed 1 year ago

nandagopalan commented 1 year ago

The current VFile interface defines a function Delete() that is supposed to delete file or directory. However this is confusing to use.

  1. Define a new function named DeleteAll in the VFile interface. This function will delete a file or directory with all its contents.
  2. Update the defn of Delete() fn to just delete file and throw error in case of directory
  3. Update the DeleteMatching() fn to check if the vFile object resolved by the filter is a directory ?
    1. If it s a directory call the resolvedFile.DeleteAll()
      1. If its a File call resolvedFile.Delete()
neo7337 commented 1 year ago

Can we do like call the Delete() fnc and inside that if we check whether the location is a directory or not?

If it's a directory then invoke DeleteAll() and delete the directory Otherwise delete the file