jaulib v1.2.0
Jau Support Library (C++, Java, ..)
Classes | Public Member Functions | List of all members
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. More...
 
boolean equals (final Object other)
 
 FileStats (final String path)
 Instantiates a file_stats for the given path. More...
 
 FileStats (final DirItem item)
 Instantiates a file_stats for the given dir_item. More...
 
 FileStats (final int fd)
 Instantiates a file_stats for the given fd file descriptor. More...
 
DirItem item ()
 Returns the dir_item. More...
 
String path ()
 Returns the unix path representation. More...
 
String link_target_path ()
 Returns the stored link-target path this symbolic-link points to if instance is a symbolic-link, otherwise nullptr. More...
 
FileStats link_target ()
 Returns the link-target this symbolic-link points to if instance is a symbolic-link, otherwise nullptr. More...
 
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. More...
 
boolean has (final Field.Type bit)
 Returns true if the given field_t fields were retrieved, otherwise false. More...
 
Field fields ()
 Returns the retrieved field_t fields. More...
 
FMode mode ()
 Returns the FMode, file type and mode. More...
 
FMode prot_mode ()
 Returns the POSIX protection bit portion of fmode_t, i.e. More...
 
FMode type_mode ()
 Returns the type bit portion of fmode_t, i.e. More...
 
int fd ()
 Returns the file descriptor if has_fd(), otherwise -1 for no file descriptor. More...
 
int uid ()
 Returns the user id, owning the element. More...
 
int gid ()
 Returns the group id, owning the element. More...
 
long size ()
 Returns the size in bytes of this element if is_file(), otherwise zero. More...
 
Instant btime ()
 Returns the birth time of this element since Unix Epoch, i.e. More...
 
Instant atime ()
 Returns the last access time of this element since Unix Epoch. More...
 
Instant ctime ()
 Returns the last status change time of this element since Unix Epoch. More...
 
Instant mtime ()
 Returns the last modification time of this element since Unix Epoch. More...
 
int errno_res ()
 Returns the errno value occurred to produce this instance, or zero for no error. More...
 
boolean ok ()
 Returns true if no error occurred. More...
 
boolean has_fd ()
 Returns true if entity has a file descriptor. More...
 
boolean is_socket ()
 Returns true if entity is a socket, might be in combination with is_link(). More...
 
boolean is_block ()
 Returns true if entity is a block device, might be in combination with is_link(). More...
 
boolean is_char ()
 Returns true if entity is a character device, might be in combination with is_link(). More...
 
boolean is_fifo ()
 Returns true if entity is a fifo/pipe, might be in combination with is_link(). More...
 
boolean is_dir ()
 Returns true if entity is a directory, might be in combination with is_link(). More...
 
boolean is_file ()
 Returns true if entity is a file, might be in combination with is_link(). More...
 
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(). More...
 
boolean has_access ()
 Returns true if entity gives no access to user, exclusive bit. More...
 
boolean exists ()
 Returns true if entity does not exist, exclusive bit. More...
 
String toString ()
 

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 call graph for this function:
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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

Member Function Documentation

◆ 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.

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.

Here is the caller graph for this function:

◆ 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.

◆ equals()

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

Definition at line 145 of file FileStats.java.

Here is the call graph for this function:
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.

◆ 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 call graph for this function:
Here is the caller graph for this function:

◆ 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:

◆ fields()

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

Returns the retrieved field_t fields.

Definition at line 312 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 call graph for this function:
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:

◆ 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:

◆ 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 call graph for this function:
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_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.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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 call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call 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 call graph for this function:
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 call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

◆ 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:

◆ 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:

◆ 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.

Here is the caller graph for this function:

◆ 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:

◆ 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:

◆ 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:

◆ 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 call graph for this function:
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.

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:

◆ toString()

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

Definition at line 398 of file FileStats.java.

Here is the call graph for this function:

◆ 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.

◆ 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:

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