Class FileInfo


  • public class FileInfo
    extends Object
    Contains information about a file or a directory.

    Note: This class wraps GoogleCloudStorageItemInfo, adds file system specific information and hides bucket/object specific information. The wrapped type should not be visible to callers of GoogleCloudStorageFileSystem because it exposes non-file system information (eg, buckets).

    • Field Detail

      • ROOT_INFO

        public static final FileInfo ROOT_INFO
    • Method Detail

      • getPath

        public URI getPath()
        Gets the path of this file or directory.
      • isDirectory

        public boolean isDirectory()
        Indicates whether this item is a directory.
      • isInferredDirectory

        public boolean isInferredDirectory()
        Indicates whether this item is an inferred directory.
      • isGlobalRoot

        public boolean isGlobalRoot()
        Indicates whether this instance has information about the unique, shared root of the underlying storage system.
      • getCreationTime

        public long getCreationTime()
        Gets creation time of this item.

        Time is expressed as milliseconds since January 1, 1970 UTC.

      • getSize

        public long getSize()
        Gets the size of this file or directory.

        For files, size is in number of bytes. For directories size is 0. For items that do not exist, size is -1.

      • getModificationTime

        public long getModificationTime()
        Gets the modification time of this file if one is set, otherwise the value of getCreationTime() is returned.

        Time is expressed as milliseconds since January 1, 1970 UTC.

      • getAttributes

        public Map<String,​byte[]> getAttributes()
        Retrieve file attributes for this file.
        Returns:
        A map of file attributes
      • exists

        public boolean exists()
        Indicates whether this file or directory exists.
      • getCrc32cChecksum

        public byte[] getCrc32cChecksum()
        Returns CRC32C checksum of the file or null.
      • getMd5Checksum

        public byte[] getMd5Checksum()
        Returns MD5 checksum of the file or null.
      • toString

        public String toString()
        Gets string representation of this instance.
        Overrides:
        toString in class Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • fromItemInfo

        public static FileInfo fromItemInfo​(GoogleCloudStorageItemInfo itemInfo)
        Handy factory method for constructing a FileInfo from a GoogleCloudStorageItemInfo while potentially returning a singleton instead of really constructing an object for cases like ROOT.