Class MFileOS

  • All Implemented Interfaces:
    Comparable<MFile>, MFile

    @ThreadSafe
    public class MFileOS
    extends Object
    implements MFile
    Implements thredds.inventory.MFile using regular OS files.
    Since:
    Jun 30, 2009
    • Constructor Detail

      • MFileOS

        public MFileOS​(File file)
      • MFileOS

        public MFileOS​(String filename)
    • Method Detail

      • getExistingFile

        @Nullable
        public static MFileOS getExistingFile​(String filename)
        Make MFileOS if file exists, otherwise return null
        Parameters:
        filename - name of the existing file.
        Returns:
        MFileOS or null
      • getLastModified

        public long getLastModified()
        Description copied from interface: MFile
        Get time of last modification at the time the MFile object was created
        Specified by:
        getLastModified in interface MFile
        Returns:
        time of last modification in Unix time (msecs since reference), or -1 if unknown
      • getLength

        public long getLength()
        Description copied from interface: MFile
        Size of file in bytes
        Specified by:
        getLength in interface MFile
        Returns:
        Size of file in bytes or -1 if unknown
      • isDirectory

        public boolean isDirectory()
        Specified by:
        isDirectory in interface MFile
      • isReadable

        public boolean isReadable()
        Specified by:
        isReadable in interface MFile
      • getPath

        public String getPath()
        Description copied from interface: MFile
        Get full path name, replace \\ with /
        Specified by:
        getPath in interface MFile
        Returns:
        full path name
      • getName

        public String getName()
        Description copied from interface: MFile
        The name is the farthest element from the root in the directory hierarchy.
        Specified by:
        getName in interface MFile
        Returns:
        the file name
      • getParent

        @Nullable
        public MFile getParent()
        Description copied from interface: MFile
        Get the parent of this
        Specified by:
        getParent in interface MFile
        Returns:
        the parent or null
      • exists

        public boolean exists()
        Description copied from interface: MFile
        Check if the MFile exists
        Specified by:
        exists in interface MFile
        Returns:
        true if the MFile exists, else false
      • writeToStream

        public void writeToStream​(OutputStream outputStream)
                           throws IOException
        Description copied from interface: MFile
        Write the MFile to an OutputStream
        Specified by:
        writeToStream in interface MFile
        Parameters:
        outputStream - the OutputStream the MFile contents should be written to
        Throws:
        IOException
      • writeToStream

        public void writeToStream​(OutputStream outputStream,
                                  long offset,
                                  long maxBytes)
                           throws IOException
        Description copied from interface: MFile
        Write the MFile to an OutputStream
        Specified by:
        writeToStream in interface MFile
        Parameters:
        outputStream - the OutputStream the MFile contents should be written to
        offset - the index of the first byte to write out
        maxBytes - the maximum number of bytes to copy
        Throws:
        IOException
      • getFile

        public File getFile()
      • getChild

        public MFileOS getChild​(String newFilename)
        Description copied from interface: MFile
        Get child MFile of this MFile
        Specified by:
        getChild in interface MFile
        Parameters:
        newFilename - the relative file path of the new MFile
        Returns:
        the new MFile or null if the file can't be resolved