Permalink
Browse files

Return false from QFS.delete() when FileNotFound. Fixes #18.

  • Loading branch information...
1 parent e326f97 commit 822c854c26d250a95ce23cdd4ed4f14d658c4f6a Jeremy R. Fishman committed Feb 21, 2013
@@ -172,11 +172,18 @@ public boolean rename(Path src, Path dst) throws IOException {
// recursively delete the directory and its contents
public boolean delete(Path path, boolean recursive) throws IOException {
Path absolute = makeAbsolute(path);
+ FileStatus fs;
+ try {
+ fs = qfsImpl.stat(absolute);
+ } catch (FileNotFoundException e) {
+ return false;
+ }
+
String srep = absolute.toUri().getPath();
- if (qfsImpl.isFile(srep))
+ if (!fs.isDir())
return qfsImpl.remove(srep) == 0;
- FileStatus[] dirEntries = listStatus(absolute);
+ FileStatus[] dirEntries = qfsImpl.readdirplus(absolute);
if ((!recursive) && (dirEntries != null) && (dirEntries.length != 0)) {
throw new IOException("Directory " + path.toString() + " is not empty.");
}

0 comments on commit 822c854

Please sign in to comment.