public class FatDirectory extends AbstractUsbFile
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes and flushes the file.
|
long |
createdAt()
Returns the time this directory or file was created.
|
FatDirectory |
createDirectory(java.lang.String name)
This methods creates a new directory with the given name and returns it.
|
FatFile |
createFile(java.lang.String name)
This methods creates a new file with the given name and returns it.
|
void |
delete()
Deletes this file or directory from the parent directory.
|
void |
flush()
Forces a write.
|
long |
getLength()
Returns the file length or throws an exception if called on a directory.
|
java.lang.String |
getName() |
UsbFile |
getParent()
Returns the parent directory for the file or directory or null if this is
the root directory.
|
boolean |
isDirectory() |
boolean |
isRoot() |
long |
lastAccessed()
Returns the time this directory or file was last accessed.
|
long |
lastModified()
Returns the time this directory or file was last modified.
|
java.lang.String[] |
list()
Lists all files in the directory.
|
UsbFile[] |
listFiles()
Lists all files in the directory.
|
void |
moveTo(UsbFile destination)
This methods moves THIS item to the destination directory.
|
void |
read(long offset,
java.nio.ByteBuffer destination)
Reads from a file or throws an exception if called on a directory.
|
void |
setLength(long newLength)
Sets the new file length.
|
void |
setName(java.lang.String newName)
Set a new name for this file or directory.
|
void |
write(long offset,
java.nio.ByteBuffer source)
Writes to a file or throws an exception if called on a directory.
|
search
public boolean isRoot()
public FatFile createFile(java.lang.String name) throws java.io.IOException
UsbFile
name
- The name of the new file.java.io.IOException
- If writing to the disk fails or a item with the same name
already exists.public FatDirectory createDirectory(java.lang.String name) throws java.io.IOException
UsbFile
name
- The name of the new directory.java.io.IOException
- If writing to the disk fails or a item with the same name
already exists.public void setLength(long newLength)
UsbFile
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.
newLength
- The file length in bytes.public long getLength()
UsbFile
public boolean isDirectory()
public java.lang.String getName()
public void setName(java.lang.String newName) throws java.io.IOException
UsbFile
newName
- The new name.java.io.IOException
- If new name is already assigned or writing to the file system
fails.public long createdAt()
UsbFile
public long lastModified()
UsbFile
public long lastAccessed()
UsbFile
public UsbFile getParent()
UsbFile
public java.lang.String[] list() throws java.io.IOException
UsbFile
java.io.IOException
- If reading failspublic UsbFile[] listFiles() throws java.io.IOException
UsbFile
java.io.IOException
- If reading failspublic void read(long offset, java.nio.ByteBuffer destination) throws java.io.IOException
UsbFile
offset
- The offset in bytes where reading in the file should be begin.destination
- Buffer the data shall be transferred to.java.io.IOException
- If reading fails.public void write(long offset, java.nio.ByteBuffer source) throws java.io.IOException
UsbFile
offset
- The offset in bytes where writing in the file should be begin.source
- Buffer which contains the data which shall be transferred.java.io.IOException
- If writing fails.public void flush() throws java.io.IOException
UsbFile
java.io.IOException
- If flushing fails.public void close() throws java.io.IOException
UsbFile
java.io.IOException
- If closing fails.public void moveTo(UsbFile destination) throws java.io.IOException
UsbFile
destination
- The directory where this item should be moved.java.io.IOException
- If writing fails, or the operation cannot be done (eg. item
already exists in the destination directory)public void delete() throws java.io.IOException
UsbFile
java.io.IOException
- If operation fails due to write errors.