[CLJ-1159] clojure.java.io/delete-file doesn't return the status of the deletion(true/false) Created: 10/Feb/13 Updated: 10/Feb/13
|Affects Version/s:||Release 1.5|
|Labels:||delete-file, evil, or|
initially reported it here(somehow):
Basically clojure.java.io/delete-file doesn't ever return false (even when silently is true, it returns the value of silently), it's due to how it's implemented - but it's obvious from the code, so I'll stop here.
PS: this is what I'm using as my current workaround:
I'm sure you guys can find a better way, but as a clojure newbie(really!) that's what I have.
|Comment by AtKaaZ [ 10/Feb/13 2:01 PM ]|
I kinda just realized it affects all versions since and including 1.2, because it appears that its implementation was the same since then.
If it's not meant to return the result of the delete, maybe it should specifically return nil and/or the doc say something?
|Comment by Sean Corfield [ 10/Feb/13 2:21 PM ]|
As noted in a thread on the Clojure ML, you can pass a known value in the second argument position to detect a delete that failed:
(clojure.java.io/delete-file some-file :not-deleted)
This returns true on success and :not-deleted on failure.
However the docstring could be better worded to make that intention clear. Perhaps:
Delete file f. Return true if it succeeds. If silently is nil or false, raise an exception if it fails, else return the value of silently.