Package 

Class FatFile

  • All Implemented Interfaces:
    com.github.mjdev.libaums.fs.UsbFile , java.io.Closeable , java.lang.AutoCloseable

    
    public final class FatFile
    extends AbstractUsbFile
                        

    Constructs a new file with the given information.

    • Constructor Detail

    • Method Detail

      • getName

         String getName()

        Set a new name for this file or directory.

      • setName

         Unit setName(String name)

        Set a new name for this file or directory.

        Parameters:
        name - The new name.
      • getLength

         Long getLength()

        Sets the new file length. This can sometimes be more efficient if all needed place for a file is allocated on the disk at once and before writing to it.

        If the space is not allocated before writing the space must be exceeded every time a new write occurs. This can sometimes be less efficient.

      • setLength

         Unit setLength(Long length)

        Sets the new file length. This can sometimes be more efficient if all needed place for a file is allocated on the disk at once and before writing to it.

        If the space is not allocated before writing the space must be exceeded every time a new write occurs. This can sometimes be less efficient.

        Parameters:
        length - The file length in bytes.
      • createdAt

         Long createdAt()

        Returns the time this directory or file was created.

      • lastModified

         Long lastModified()

        Returns the time this directory or file was last modified.

      • lastAccessed

         Long lastAccessed()

        Returns the time this directory or file was last accessed.

      • list

         Array<String> list()

        Lists all files in the directory. Throws an exception if called on a file.

      • listFiles

         Array<UsbFile> listFiles()

        Lists all files in the directory. Throws an exception if called on a file.

      • read

         Unit read(Long offset, ByteBuffer destination)

        Reads from a file or throws an exception if called on a directory.

        Parameters:
        offset - The offset in bytes where reading in the file should be begin.
        destination - Buffer the data shall be transferred to.
      • write

         Unit write(Long offset, ByteBuffer source)

        Writes to a file or throws an exception if called on a directory.

        Parameters:
        offset - The offset in bytes where writing in the file should be begin.
        source - Buffer which contains the data which shall be transferred.
      • flush

         Unit flush()

        Forces a write. Every change to the file is then committed to the disk. Throws an exception if called on directories.

      • close

         Unit close()

        Closes and flushes the file. It is essential to close a file after making changes to it! Throws an exception if called on directories.

      • createDirectory

         UsbFile createDirectory(String name)

        This methods creates a new directory with the given name and returns it.

        Parameters:
        name - The name of the new directory.
      • createFile

         UsbFile createFile(String name)

        This methods creates a new file with the given name and returns it.

        Parameters:
        name - The name of the new file.
      • moveTo

         Unit moveTo(UsbFile destination)

        This methods moves THIS item to the destination directory. Make sure that the destination is a directory, otherwise an exception will be thrown. Make also sure that both items are on the same logical device (disk, partition, file system). Moving between different file systems is currently not supported. If you want to do this, you have to manually copy the content and delete the old item.

        Parameters:
        destination - The directory where this item should be moved.
      • delete

         Unit delete()

        Deletes this file or directory from the parent directory.