I have a special use case where I need to verify if a file is a special block file (only if my java program is run on Linux). My code can already detect if it's ran on Windows or Linux, so if it's windows I simply invalidate the verification.
For Linux, I was reading about the different FileAttributeView interfaces; and the first thing that popped up was to use the PosixFileAttributeView (since block and char device files are Linux-specific), but after looking further into its Javadoc, it only gives access to the different RWX (read, write, execute permissions relative to the owner, group and others) but nothing about special block files or other file attributes. On the other hand, the BasicFileAttributeView is supported by all filesystems and has an instance method called isOther()
, this could work but there has to be some other way that's more specific than just knowing that a file is not a regular file, directory or symlink. Knowing that it's something other
is just too vague.. Any help is deeply appreciated.