public class FileChecker
extends java.lang.Object
The following codes are implemented:
PRIMARY TYPES
SECONDARY (ADDITIVE) TYPES
One of the main types will always appear, and can also be accompanied by one or more of the secondary types.
In some cases the additive status can only be added to a specific main type Ex: the Progress behavior for hidden attribute -> only hidden file are marked as hidden, hidden directories are only marked as directory.
Because the file system may be different from an OS to another (some filetypes are Unix specific) results may be yielded differently, however this is handled by the native code
Modifier and Type | Field and Description |
---|---|
private static java.lang.Boolean |
consoleRedirected
Cache of console redirection flag for current session.
|
private static int |
DEVICE_TYPE
Status bitfield code for devices
|
private static int |
DIRECTORY_TYPE
Status bitfield code for directory
|
private static int |
ERROR_TYPE
Status code for error
|
private static int |
FILE_TYPE
Status bitfield code for file
|
private static int |
HIDDEN_TYPE
Status bitfield code for hidden
|
private static int |
IS_UNIX
Status code for UNIX
|
private static int |
IS_WINDOWS
Status code for WINDOWS
|
private static int |
PIPE_TYPE
Status bitfield code for pipes
|
private static int |
SYMBOLIC_LINK_TYPE
Status bitfield code for symbolic link
|
private static int |
UNKNOWN_TYPE
Status bitfield code for unknown
|
Constructor and Description |
---|
FileChecker() |
Modifier and Type | Method and Description |
---|---|
static int |
checkFileType(java.lang.String filePath)
Native utility method that will return a bitfield code representing the
status of the file.
|
static long |
getFileCreationTime(java.lang.String filePath)
Native utility method that will return the creation date of a file
represented as milliseconds from year 1970.
|
static java.lang.String |
getFileType(java.lang.String filePath)
This method will call the native code handling the file type detection,
interpret the bitfield result and return the status in Progress format.
|
static boolean |
isConsoleRedirected()
Checks if the current console session is redirected to the file by OS output redirection
command line option(">").
|
static boolean |
isStdoutRedirected()
Checks if the current STDOUT handle is redirected to the file by OS output redirection
command line option(">").
|
private static final int ERROR_TYPE
private static final int UNKNOWN_TYPE
private static final int DIRECTORY_TYPE
private static final int FILE_TYPE
private static final int SYMBOLIC_LINK_TYPE
private static final int DEVICE_TYPE
private static final int PIPE_TYPE
private static final int HIDDEN_TYPE
private static final int IS_UNIX
private static final int IS_WINDOWS
private static java.lang.Boolean consoleRedirected
public static int checkFileType(java.lang.String filePath)
filePath
- The String representing the path of the file for
which we want to calculate the status code.public static long getFileCreationTime(java.lang.String filePath)
filePath
- The String representing the path of the file for
which we want to calculate the creation time.public static java.lang.String getFileType(java.lang.String filePath)
filePath
- The String representing the path of the file for
which we want to calculate the status code.public static boolean isStdoutRedirected()
true
if the current console output is redirected
false
otherwise.public static boolean isConsoleRedirected()
true
if the current console output is redirected
false
otherwise.