Package globus.glmap

Class GLMapStorageFile

java.lang.Object
globus.glmap.GLMapStorageFile
Direct Known Subclasses:
GLMapDocumentTreeStorage.FileInfo, GLMapFileStorage.FileInfo

public abstract class GLMapStorageFile extends Object
Abstract class representing a file in storage.
  • Constructor Details

    • GLMapStorageFile

      public GLMapStorageFile()
  • Method Details

    • findSibling

      public GLMapStorageFile findSibling(@NonNull String name, boolean create)
      Finds a file with the specified name in the same folder.
      Parameters:
      name - the name of the file to find
      create - if true, creates the file if it does not exist
      Returns:
      the file with the specified name, or null if not found and create is false
    • getStorage

      @NonNull public abstract GLMapStorage getStorage()
      Returns the storage that contains this file.
      Returns:
      the storage containing this file
    • isDirectory

      public abstract boolean isDirectory()
      Returns true if this object is a directory
      Returns:
      true if this object is a directory
    • getAsStorage

      @Nullable public abstract GLMapStorage getAsStorage()
      Returns this file as a storage
      Returns:
      storage if this object is a directory, otherwise null
    • delete

      public abstract boolean delete()
      Deletes this file.
      Returns:
      true if the file was successfully deleted, false otherwise
    • truncate

      public boolean truncate()
      Truncates the file to zero length.
      Returns:
      true if the file was successfully truncated, false otherwise
    • getPath

      @Nullable public String getPath()
      Gets the full path of this file.
      Returns:
      the full path of this file, or null if the name is null
    • getName

      @Nullable public abstract String getName()
      Gets the name of this file.
      Returns:
      the name of the file, or null if it has no name
    • setName

      public abstract boolean setName(String newName)
      Sets the name of this file.
      Parameters:
      newName - the new name to set
      Returns:
      true if the name was successfully set, false otherwise
    • getVFSName

      @Nullable public abstract String getVFSName()
      Gets the VFS (Virtual File System) name of this file.
      Returns:
      the VFS name of the file, or null if it has no VFS name
    • openInputStream

      public abstract InputStream openInputStream() throws FileNotFoundException
      Opens an input stream to read from this file.
      Returns:
      an input stream to read from the file
      Throws:
      FileNotFoundException - if the file cannot be found
    • openOutputStream

      public abstract OutputStream openOutputStream() throws FileNotFoundException
      Opens an output stream to write to this file.
      Returns:
      an output stream to write to the file
      Throws:
      FileNotFoundException - if the file cannot be found
    • openForReading

      public abstract int openForReading()
      Opens the file for reading.
      Returns:
      a file descriptor for reading from the file
    • openForWriting

      public abstract int openForWriting(boolean truncate)
      Opens the file for writing.
      Parameters:
      truncate - if true, truncates the file to zero length before writing
      Returns:
      a file descriptor for writing to the file
    • getLength

      public abstract long getLength()
      Returns the size of the file in bytes.
      Returns:
      the size of the file in bytes
    • getLastModified

      public abstract long getLastModified()
      Returns the last modified timestamp of the file.
      Returns:
      the last modified timestamp of the file
    • setLastModified

      public abstract boolean setLastModified(long lastModified)
      Sets the last modified timestamp of the file.
      Parameters:
      lastModified - the new last modified timestamp
      Returns:
      true if the timestamp was successfully set, false otherwise