|
jaulib v1.4.0-2-g788cf73
Jau Support Library (C++, Java, ..)
|
Native file types and functionality. More...
Classes | |
| interface | PathVisitor |
Path visitor for FileUtil#visit(FileStats, TraverseOptions, PathVisitor). More... | |
Static Public Member Functions | |
| static native String | get_cwd () |
| Return the current working directory or empty on failure. | |
| static native String | dirname (final String path) |
Return stripped last component from given path separated by /, excluding the trailing separator /. | |
| static native String | basename (final String path) |
Return stripped leading directory components from given path separated by /. | |
| static native String | to_named_fd (final int fd) |
| Returns platform dependent named file descriptor of given file descriptor, if supported. | |
| static native int | from_named_fd (final String named_fd) |
| Returns the file descriptor from the given named file descriptor. | |
| static native int | from_java_fd (final java.io.FileDescriptor jfd) |
| Returns the file descriptor from the given FileDescriptor instance. | |
| static boolean | mkdir (final String path, final FMode mode) |
| Create directory. | |
| static boolean | mkdir (final String path) |
See mkdir(String, FMode) using FMode#def_dir. | |
| static boolean | touch (final String path, final Instant atime, final Instant mtime, final FMode mode) |
| Touch the file with given atime and mtime and create file if not existing yet. | |
| static boolean | touch (final String path, final FMode mode) |
| Touch the file with current time and create file if not existing yet. | |
| static native List< DirItem > | get_dir_content (final String path) |
Returns a list of directory elements excluding . | |
| static boolean | visit (final String path, final TraverseOptions topts, final PathVisitor visitor) |
| Visit element(s) of a given path, see traverse_options for detailed settings. | |
| static boolean | visit (final FileStats item_stats, final TraverseOptions topts, final PathVisitor visitor) |
| Visit element(s) of a given path, see traverse_options for detailed settings. | |
| static boolean | remove (final String path, final TraverseOptions topts) |
| Remove the given path. | |
| static native boolean | compare (final String source1, final String source2, final boolean verbose) |
| Compare the bytes of both files, denoted by source1 and source2. | |
| static boolean | copy (final String source_path, final String dest_path, final CopyOptions copts) |
| Copy the given source_path to dest_path using copy_options. | |
| static native boolean | rename (final String oldpath, final String newpath) |
Rename oldpath to newpath using POSIX rename(), with the following combinations. | |
| static native void | sync () |
| Synchronizes filesystems, i.e. | |
| static long | mount_image (final String image_path, final String target, final String fs_type, final MountFlags flags, final String fs_options) |
Attach the filesystem image named in image_path to target using an intermediate platform specific filesystem image loop-device. | |
| static long | mount (final String source, final String target, final String fs_type, final MountFlags flags, final String fs_options) |
Attach the filesystem named in source to target using the given filesystem source directly. | |
| static boolean | umount (final long context, final UnmountFlags flags) |
Detach the given mount_ctx context | |
| static boolean | umount (final String target, final UnmountFlags flags) |
Detach the topmost filesystem mounted on target optionally using given umountflags options if supported. | |
Static Public Attributes | |
| static final long | UTIME_NOW = ((1l << 30) - 1l) |
Native file types and functionality.
Definition at line 33 of file FileUtil.java.
|
static |
Return stripped leading directory components from given path separated by /.
If only the root path / is given, return /.
| path | given path |
.
|
static |
Compare the bytes of both files, denoted by source1 and source2.
| source1 | first source file to compare |
| source2 | second source file to compare |
| verbose | defaults to false |
|
static |
Copy the given source_path to dest_path using copy_options.
The behavior is similar like POSIX cp commandline tooling.
The following behavior is being followed regarding dest_path:
Implementation either uses ::sendfile() if running under GNU/Linux, otherwise POSIX ::read() and ::write().
Implementation is most data-race-free (DRF), utilizes following safeguards on recursive directory copy
openat() operations against concurrent mutationSee copy_options for details.
| source_path | |
| dest_path | |
| copts |
Definition at line 356 of file FileUtil.java.
|
static |
Return stripped last component from given path separated by /, excluding the trailing separator /.
If no directory separator / is contained, return ..
If only the root path / is given, return /.
| path | given path |
.
|
static |
Returns the file descriptor from the given FileDescriptor instance.
| jfd | the FileDescriptor instance |
FileStats#has_fd()
|
static |
Returns the file descriptor from the given named file descriptor.
Detected named file descriptors are (d stands for integer)
/dev/fd/d (GNU/Linux, FreeBSD, ..)/proc/self/fd/d (GNU/Linux)| named_fd | the named file descriptor |
FileStats#has_fd()
|
static |
Return the current working directory or empty on failure.
|
static |
Returns a list of directory elements excluding .
and .. for the given path, non recursive.
| path | path to directory |
|
static |
See mkdir(String, FMode) using FMode#def_dir.
Definition at line 118 of file FileUtil.java.
|
static |
Create directory.
| path | full path to new directory |
| mode | fmode_t POSIX protection bits used, defaults to FMode#def_dir |
| verbose | defaults to false |
Definition at line 110 of file FileUtil.java.
|
static |
Attach the filesystem named in source to target using the given filesystem source directly.
This method either requires root permissions
or the following capabilities: cap_sys_admin,cap_setuid, cap_setgid.
| source | filesystem path for device, directory, file or dummy-string which shall be attached |
| target | directory where source filesystem shall be attached to |
| fs_type | type of filesystem, e.g. squashfs, tmpfs, iso9660, etc. |
| flags | mount flags, e.g. MS_LAZYTIME | MS_NOATIME | MS_RDONLY for a read-only lazy-time and no-atime filesystem. |
| fs_options | comma separated options for the filesystem fs_type, see mount(8) for available options for the used filesystem. |
Definition at line 428 of file FileUtil.java.
|
static |
Attach the filesystem image named in image_path to target using an intermediate platform specific filesystem image loop-device.
This method either requires root permissions
or the following capabilities: cap_sys_admin,cap_setuid, cap_setgid.
Unmounting shall be done via umount() with mount_ctx argument to ensure all intermediate resources are released.
| image_path | path of image source file |
| target | directory where image_path filesystem shall be attached to |
| fs_type | type of filesystem, e.g. squashfs, tmpfs, iso9660, etc. |
| flags | filesystem agnostic mount flags, see mountflags_linux. |
| fs_options | comma separated options for the filesystem fs_type, see mount(8) for available options for the used filesystem. |
Definition at line 404 of file FileUtil.java.
|
static |
Remove the given path.
If path represents a director, recursive must be set to true.
The given traverse_options options are handled as follows:
Implementation is most data-race-free (DRF), utilizes following safeguards
openat() and unlinkat() operations against concurrent mutation| path | path to remove |
| topts | given traverse_options for this operation, defaults to traverse_options::none |
Definition at line 304 of file FileUtil.java.
|
static |
Rename oldpath to newpath using POSIX rename(), with the following combinations.
| oldpath | previous path |
| newpath | new path |
|
static |
Synchronizes filesystems, i.e.
all pending modifications to filesystem metadata and cached file data will be written to the underlying filesystems.
|
static |
Returns platform dependent named file descriptor of given file descriptor, if supported.
Implementation returns (d stands for integer):
/dev/fd/d (GNU/Linux, FreeBSD, ..)Currently implementation always returns above pattern, not handling the target OS differences.
| fd | file descriptor. |
|
static |
Touch the file with current time and create file if not existing yet.
| path | full path to file |
| mode | fmode_t POSIX protection bits used, defaults to FMode#def_file |
| verbose | defaults to false |
Definition at line 152 of file FileUtil.java.
|
static |
Touch the file with given atime and mtime and create file if not existing yet.
| path | full path to file |
| atime | new access time |
| mtime | new modification time |
| mode | fmode_t POSIX protection bits used, defaults to FMode#def_file |
| verbose | defaults to false |
Definition at line 131 of file FileUtil.java.
|
static |
Detach the given mount_ctx context
This method either requires root permissions
or the following capabilities: cap_sys_admin,cap_setuid, cap_setgid.
| context | native mount context, previously attached via mount_image() or mount() |
| flags | optional umount options, if supported by the system |
Definition at line 448 of file FileUtil.java.
|
static |
Detach the topmost filesystem mounted on target optionally using given umountflags options if supported.
This method either requires root permissions
or the following capabilities: cap_sys_admin,cap_setuid, cap_setgid.
| target | directory of previously attached filesystem |
| umountflags | optional umount options, if supported by the system |
Definition at line 467 of file FileUtil.java.
|
static |
Visit element(s) of a given path, see traverse_options for detailed settings.
All elements of type fmode_t::file, fmode_t::dir and fmode_t::no_access or fmode_t::not_existing will be visited by the given path_visitor visitor.
Depth passed to path_visitor is the recursive directory depth and starts with 1 for the initial directory.
path_visitor returning false stops traversal in general but TraverseOptions.Bit#dir_check_entry will only skip traversing the denied directory.
| item_stats | pre-fetched file_stats for a given dir_item, used for efficiency |
| topts | given traverse_options for this operation |
| visitor | path_visitor function bool visitor(const file_stats& item_stats, size_t depth). |
false excluding TraverseOptions.Bit#dir_check_entry. Definition at line 222 of file FileUtil.java.
|
static |
Visit element(s) of a given path, see traverse_options for detailed settings.
All elements of type fmode_t::file, fmode_t::dir and fmode_t::no_access or fmode_t::not_existing will be visited by the given path_visitor visitor.
Depth passed to path_visitor is the recursive directory depth and starts with 1 for the initial directory.
path_visitor returning false stops traversal in general but TraverseOptions.Bit#dir_check_entry will only skip traversing the denied directory.
| path | the starting path |
| topts | given traverse_options for this operation |
| visitor | path_visitor function bool visitor(const file_stats& item_stats, size_t depth). |
false excluding TraverseOptions.Bit#dir_check_entry. Definition at line 201 of file FileUtil.java.
|
static |
Definition at line 143 of file FileUtil.java.