Using the JNotify library, how can you tell if a deleted file was a file or a directory?
Posted
by
Moeri
on Stack Overflow
See other posts from Stack Overflow
or by Moeri
Published on 2011-11-25T17:42:28Z
Indexed on
2011/11/25
17:50 UTC
Read the original article
Hit count: 209
For those unfamiliar with JNotify, this is a library which provides an easy way to monitor events in a directory.
For instance, when a file gets deleted in the selected folder, the method "fileDeleted" gets called, along with a few parameters. Here's an example of the fileDeleted method:
public void fileDeleted(int wd, String rootPath, String name) {
print("deleted " + rootPath + " : " + name);
}
Now, I would like to know if the deleted file was a file or directory. My usual approach is to create a new File object with the given path, and use the methods isFile() and isDirectory()
However, since this file is already deleted, these methods always return false.
So here's my concrete question: I have the path to a deleted file or directory, how can I tell wether it was a file or a directory? Is there a workaround to this? What's the best practice to do here?
Thank you in advance.
© Stack Overflow or respective owner