btw: rm -f
is useful in some case, e.g. we want delete all files but no folder, no prompt.
Thanks.
btw: rm -f
is useful in some case, e.g. we want delete all files but no folder, no prompt.
Thanks.
Refer to FileUtils rm
methods
FileUtils.rm
I see, the Ruby FileUtils.rm_f
equivalent is File.delete?
, there is no equivalent in FileUtil.
I will create a issue to discuss add it.
Don’t think so, File.delete
is only for single file, while Ruby File.rm
can take a file or list of files. So equivalent would be FileUtils.rm
method, which have overloaded methods.
PS: I don’t have any Ruby knowledge, and i’m making my judgement by looking at the doc link you provided.
It’s the same in Crystal, unless I’m missing something:
https://crystal-lang.org/api/1.6.1/FileUtils.html#rm_rf(path%3APath|String)%3ANil-instance-method
You are right, we are missing two methods:
def rm_f(path : Path | String) : Nil # this one is a alias of File.delete
def rm_f(paths : Enumerable(Path | String)) : Nil # this one is missing
#rm_rf
same as command line: rm -rf
#rm_f
same as command line rm -f
-f, --force
ignore nonexistent files and arguments, never prompt
-r, -R, --recursive
remove directories and their contents recursively
rm -rf
is too dangerous for almost all cases.