Class FileSystemUtils


  • public final class FileSystemUtils
    extends Object
    Native file system API.
    • Constructor Detail

      • FileSystemUtils

        public FileSystemUtils()
    • Method Detail

      • checkSupported

        public static void checkSupported()
      • getFileSystemBlockSize

        public static int getFileSystemBlockSize​(Path path)
        Parameters:
        path - File system path.
        Returns:
        File system block size or negative value if not supported.
      • getFileSystemBlockSize

        public static int getFileSystemBlockSize​(int fd)
        Parameters:
        fd - Native file descriptor.
        Returns:
        File system block size or negative value if not supported.
      • getSparseFileSize

        public static long getSparseFileSize​(int fd)
        !!! Use with caution. May produce unexpected results. Known to work correctly on Linux EXT4 and Btrfs, while on XSF it returns meaningful result only after file reopening.
        Parameters:
        fd - Native file descriptor.
        Returns:
        Approximate system dependent size of the sparse file or negative value if not supported.
      • punchHole

        public static long punchHole​(int fd,
                                     long off,
                                     long len,
                                     int fsBlockSize)
        Parameters:
        fd - Native file descriptor.
        off - Offset of the hole.
        len - Length of the hole.
        fsBlockSize - File system block size.
        Returns:
        Actual punched hole size.