-
- All Implemented Interfaces:
-
com.github.mjdev.libaums.fs.UsbFile,java.io.Closeable,java.lang.AutoCloseable
public final class FatDirectory extends AbstractUsbFile
This class represents a directory in the FAT32 file system. It can hold other directories and files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public classFatDirectory.Companion
-
Field Summary
Fields Modifier and Type Field Description private final BooleanisRootprivate Longlengthprivate final BooleanisDirectoryprivate Stringnameprivate FatDirectoryparentprivate final StringabsolutePath
-
Method Summary
Modifier and Type Method Description BooleangetIsRoot()LonggetLength()Sets the new file length. UnitsetLength(Long length)Sets the new file length. BooleangetIsDirectory()StringgetName()Set a new name for this file or directory. UnitsetName(String name)Set a new name for this file or directory. FatDirectorygetParent()Null if this is the root directory. UnitsetParent(FatDirectory parent)Null if this is the root directory. StringgetAbsolutePath()Absolute path of a file or directory. Unitwrite(Long offset, ByteBuffer source)Writes to a file or throws an exception if called on a directory. FatFilecreateFile(String name)This methods creates a new file with the given name and returns it. FatDirectorycreateDirectory(String name)This methods creates a new directory with the given name and returns it. LongcreatedAt()Returns the time this directory or file was created. LonglastModified()Returns the time this directory or file was last modified. LonglastAccessed()Returns the time this directory or file was last accessed. Array<String>list()Lists all files in the directory. Array<UsbFile>listFiles()Lists all files in the directory. Unitread(Long offset, ByteBuffer destination)Reads from a file or throws an exception if called on a directory. Unitflush()Forces a write. Unitclose()Closes and flushes the file. UnitmoveTo(UsbFile destination)This methods moves THIS item to the destination directory. Unitdelete()Deletes this file or directory from the parent directory. -
-
Method Detail
-
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.
-
getIsDirectory
Boolean getIsDirectory()
-
setName
Unit setName(String name)
Set a new name for this file or directory.
- Parameters:
name- The new name.
-
getParent
FatDirectory getParent()
Null if this is the root directory.
-
setParent
Unit setParent(FatDirectory parent)
Null if this is the root directory.
-
getAbsolutePath
String getAbsolutePath()
Absolute path of a file or directory.
-
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.
-
createFile
FatFile createFile(String name)
This methods creates a new file with the given name and returns it.
- Parameters:
name- The name of the new file.
-
createDirectory
FatDirectory createDirectory(String name)
This methods creates a new directory with the given name and returns it.
- Parameters:
name- The name of the new directory.
-
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.
-
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.
-
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.
-
-
-
-