jaulib v1.5.0
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
org.jau.fs.FileStats Class Reference

Platform agnostic representation of POSIX ::lstat() and ::stat() for a given pathname. More...

Collaboration diagram for org.jau.fs.FileStats:

Classes

class  Field
 

Public Member Functions

 FileStats ()
 Instantiate an empty file_stats with fmode_t::not_existing set.
 
 FileStats (final DirItem item)
 Instantiates a file_stats for the given dir_item.
 
 FileStats (final int fd)
 Instantiates a file_stats for the given fd file descriptor.
 
 FileStats (final String path)
 Instantiates a file_stats for the given path.
 
Instant atime ()
 Returns the last access time of this element since Unix Epoch.
 
Instant btime ()
 Returns the birth time of this element since Unix Epoch, i.e.
 
Instant ctime ()
 Returns the last status change time of this element since Unix Epoch.
 
boolean equals (final Object other)
 
int errno_res ()
 Returns the errno value occurred to produce this instance, or zero for no error.
 
boolean exists ()
 Returns true if entity does not exist, exclusive bit.
 
int fd ()
 Returns the file descriptor if has_fd(), otherwise -1 for no file descriptor.
 
Field fields ()
 Returns the retrieved field_t fields.
 
FileStats final_target (final long link_count[])
 Returns the final target element, either a pointer to this instance if not a symbolic-link or the final link-target a symbolic-link (chain) points to.
 
int gid ()
 Returns the group id, owning the element.
 
boolean has (final Field.Type bit)
 Returns true if the given field_t fields were retrieved, otherwise false.
 
boolean has_access ()
 Returns true if entity gives no access to user, exclusive bit.
 
boolean has_fd ()
 Returns true if entity has a file descriptor.
 
boolean is_block ()
 Returns true if entity is a block device, might be in combination with is_link().
 
boolean is_char ()
 Returns true if entity is a character device, might be in combination with is_link().
 
boolean is_dir ()
 Returns true if entity is a directory, might be in combination with is_link().
 
boolean is_fifo ()
 Returns true if entity is a fifo/pipe, might be in combination with is_link().
 
boolean is_file ()
 Returns true if entity is a file, might be in combination with is_link().
 
boolean is_link ()
 Returns true if entity is a symbolic link, might be in combination with is_file(), is_dir(), is_fifo(), is_char(), is_block(), is_socket().
 
boolean is_socket ()
 Returns true if entity is a socket, might be in combination with is_link().
 
DirItem item ()
 Returns the dir_item.
 
FileStats link_target ()
 Returns the link-target this symbolic-link points to if instance is a symbolic-link, otherwise nullptr.
 
String link_target_path ()
 Returns the stored link-target path this symbolic-link points to if instance is a symbolic-link, otherwise nullptr.
 
FMode mode ()
 Returns the FMode, file type and mode.
 
Instant mtime ()
 Returns the last modification time of this element since Unix Epoch.
 
boolean ok ()
 Returns true if no error occurred.
 
String path ()
 Returns the unix path representation.
 
FMode prot_mode ()
 Returns the POSIX protection bit portion of fmode_t, i.e.
 
long size ()
 Returns the size in bytes of this element if is_file(), otherwise zero.
 
String toString ()
 
FMode type_mode ()
 Returns the type bit portion of fmode_t, i.e.
 
int uid ()
 Returns the user id, owning the element.
 

Detailed Description

Platform agnostic representation of POSIX ::lstat() and ::stat() for a given pathname.

Implementation follows the symbolic link, i.e. first opens the given pathname with ::lstat() and if identifying as a symbolic link opens it via ::stat() to retrieve the actual properties like size, time and ownership.

Implementation supports named file descriptor, see is_fd().

On GNU/Linux implementation uses ::statx().

Definition at line 41 of file FileStats.java.

Constructor & Destructor Documentation

◆ FileStats() [1/4]

org.jau.fs.FileStats.FileStats ( )

Instantiate an empty file_stats with fmode_t::not_existing set.

Definition at line 123 of file FileStats.java.

Here is the caller graph for this function:

◆ FileStats() [2/4]

org.jau.fs.FileStats.FileStats ( final String path)

Instantiates a file_stats for the given path.

The dir_item will be constructed without parent_dir

Parameters
paththe path to produce stats for

Definition at line 177 of file FileStats.java.

◆ FileStats() [3/4]

org.jau.fs.FileStats.FileStats ( final DirItem item)

Instantiates a file_stats for the given dir_item.

Parameters
itemthe dir_item to produce stats for

Definition at line 186 of file FileStats.java.

◆ FileStats() [4/4]

org.jau.fs.FileStats.FileStats ( final int fd)

Instantiates a file_stats for the given fd file descriptor.

Parameters
fdfile descriptor of an opened file

Definition at line 195 of file FileStats.java.

Member Function Documentation

◆ equals()

boolean org.jau.fs.FileStats.equals ( final Object other)

Definition at line 145 of file FileStats.java.

◆ item()

DirItem org.jau.fs.FileStats.item ( )

Returns the dir_item.

In case this instance is created by following a symbolic link instance, it represents the resolved path relative to the used symbolic link's dirname.

See also
is_link()
path()

Definition at line 250 of file FileStats.java.

Here is the caller graph for this function:

◆ path()

String org.jau.fs.FileStats.path ( )

Returns the unix path representation.

In case this instance is created by following a symbolic link instance, it represents the resolved path relative to the used symbolic link's dirname.

See also
is_link()
item()

Definition at line 261 of file FileStats.java.

Here is the caller graph for this function:

◆ link_target_path()

String org.jau.fs.FileStats.link_target_path ( )

Returns the stored link-target path this symbolic-link points to if instance is a symbolic-link, otherwise nullptr.

See also
is_link()
link_target()
final_target()

Definition at line 270 of file FileStats.java.

◆ link_target()

FileStats org.jau.fs.FileStats.link_target ( )

Returns the link-target this symbolic-link points to if instance is a symbolic-link, otherwise nullptr.

nullptr is also returned for an erroneous symbolic-links, i.e. non-existing link-targets or recursive loop-errors.

See also
is_link()
link_target_path()
final_target()

Definition at line 281 of file FileStats.java.

Here is the caller graph for this function:

◆ final_target()

FileStats org.jau.fs.FileStats.final_target ( final long link_count[])

Returns the final target element, either a pointer to this instance if not a symbolic-link or the final link-target a symbolic-link (chain) points to.

Parameters
link_countoptional size_t pointer to store the number of symbolic links leading to the final target, excluding the final instance. 0 indicates no symbolic-link;
See also
is_link()
link_target_path()
link_target()

Definition at line 293 of file FileStats.java.

Here is the caller graph for this function:

◆ has()

boolean org.jau.fs.FileStats.has ( final Field.Type bit)

Returns true if the given field_t fields were retrieved, otherwise false.

Definition at line 309 of file FileStats.java.

Here is the caller graph for this function:

◆ fields()

Field org.jau.fs.FileStats.fields ( )

Returns the retrieved field_t fields.

Definition at line 312 of file FileStats.java.

◆ mode()

FMode org.jau.fs.FileStats.mode ( )

Returns the FMode, file type and mode.

Definition at line 315 of file FileStats.java.

Here is the caller graph for this function:

◆ prot_mode()

FMode org.jau.fs.FileStats.prot_mode ( )

Returns the POSIX protection bit portion of fmode_t, i.e.

mode() & FMode.Bit#protection_mask.

Definition at line 318 of file FileStats.java.

◆ type_mode()

FMode org.jau.fs.FileStats.type_mode ( )

Returns the type bit portion of fmode_t, i.e.

mode() & fmode_t::type_mask.

Definition at line 321 of file FileStats.java.

◆ fd()

int org.jau.fs.FileStats.fd ( )

Returns the file descriptor if has_fd(), otherwise -1 for no file descriptor.

See also
has_fd()

Definition at line 328 of file FileStats.java.

Here is the caller graph for this function:

◆ uid()

int org.jau.fs.FileStats.uid ( )

Returns the user id, owning the element.

Definition at line 331 of file FileStats.java.

Here is the caller graph for this function:

◆ gid()

int org.jau.fs.FileStats.gid ( )

Returns the group id, owning the element.

Definition at line 334 of file FileStats.java.

Here is the caller graph for this function:

◆ size()

long org.jau.fs.FileStats.size ( )

Returns the size in bytes of this element if is_file(), otherwise zero.

If the element also is_link(), the linked target size is returned.

Definition at line 341 of file FileStats.java.

Here is the caller graph for this function:

◆ btime()

Instant org.jau.fs.FileStats.btime ( )

Returns the birth time of this element since Unix Epoch, i.e.

its creation time.

Definition at line 344 of file FileStats.java.

◆ atime()

Instant org.jau.fs.FileStats.atime ( )

Returns the last access time of this element since Unix Epoch.

Definition at line 346 of file FileStats.java.

◆ ctime()

Instant org.jau.fs.FileStats.ctime ( )

Returns the last status change time of this element since Unix Epoch.

Definition at line 348 of file FileStats.java.

◆ mtime()

Instant org.jau.fs.FileStats.mtime ( )

Returns the last modification time of this element since Unix Epoch.

Definition at line 350 of file FileStats.java.

Here is the caller graph for this function:

◆ errno_res()

int org.jau.fs.FileStats.errno_res ( )

Returns the errno value occurred to produce this instance, or zero for no error.

Definition at line 353 of file FileStats.java.

◆ ok()

boolean org.jau.fs.FileStats.ok ( )

Returns true if no error occurred.

Definition at line 356 of file FileStats.java.

Here is the caller graph for this function:

◆ has_fd()

boolean org.jau.fs.FileStats.has_fd ( )

Returns true if entity has a file descriptor.

Detected named file descriptors are (d stands for integer)

  • /dev/fd/d (GNU/Linux, FreeBSD, ..)
  • /proc/self/fd/d (GNU/Linux)
See also
fd()
FileUtil.to_named_fd(int)

Definition at line 368 of file FileStats.java.

◆ is_socket()

boolean org.jau.fs.FileStats.is_socket ( )

Returns true if entity is a socket, might be in combination with is_link().

Definition at line 371 of file FileStats.java.

◆ is_block()

boolean org.jau.fs.FileStats.is_block ( )

Returns true if entity is a block device, might be in combination with is_link().

Definition at line 374 of file FileStats.java.

◆ is_char()

boolean org.jau.fs.FileStats.is_char ( )

Returns true if entity is a character device, might be in combination with is_link().

Definition at line 377 of file FileStats.java.

◆ is_fifo()

boolean org.jau.fs.FileStats.is_fifo ( )

Returns true if entity is a fifo/pipe, might be in combination with is_link().

Definition at line 380 of file FileStats.java.

◆ is_dir()

boolean org.jau.fs.FileStats.is_dir ( )

Returns true if entity is a directory, might be in combination with is_link().

Definition at line 383 of file FileStats.java.

Here is the caller graph for this function:

◆ is_file()

boolean org.jau.fs.FileStats.is_file ( )

Returns true if entity is a file, might be in combination with is_link().

Definition at line 386 of file FileStats.java.

Here is the caller graph for this function:

◆ is_link()

boolean org.jau.fs.FileStats.is_link ( )

Returns true if entity is a symbolic link, might be in combination with is_file(), is_dir(), is_fifo(), is_char(), is_block(), is_socket().

Definition at line 389 of file FileStats.java.

Here is the caller graph for this function:

◆ has_access()

boolean org.jau.fs.FileStats.has_access ( )

Returns true if entity gives no access to user, exclusive bit.

Definition at line 392 of file FileStats.java.

Here is the caller graph for this function:

◆ exists()

boolean org.jau.fs.FileStats.exists ( )

Returns true if entity does not exist, exclusive bit.

Definition at line 395 of file FileStats.java.

Here is the caller graph for this function:

◆ toString()

String org.jau.fs.FileStats.toString ( )

Definition at line 398 of file FileStats.java.


The documentation for this class was generated from the following file: