This interface will be used to implement external file systems. Anyone wishing to extend TINI's file system must first implement this interface. The class can then be passed to the com.dalsemi.fs.DSFile.mount() method for creation.
Nearly every method in this interface takes either a file name or a file descriptor. File names will be Strings that do not include the name of the mount point itself. For example, if you have a mount point named "mnt", and on the mounted file system there is a directory called test, on TINI you would access a file in that directory by using the String "/mnt/test/myfile". The name would then be passed to the driver as "test/myfile". When accessing mount point itself ("/mnt"), it will be represented by an empty string (""). Methods that use a file descriptor will use the file descriptor returned by the openReadingFD, openWritingFD, and openRandomFD methods. What is contained in the file descriptor is up to developer.
Many methods also use a uid parameter. This is the uid of the person trying to perform the operation. IDs that have the high bit set can be assumed to have administrator privileges.
Method Summary | |
int |
available(byte[] fd)
The number of bytes that can be read without blocking. |
boolean |
canExec(java.lang.String fileName,
byte uid)
Determines if the given file is executable. |
boolean |
canRead(java.lang.String fileName,
byte uid)
Determines if the given file is readable. |
boolean |
canWrite(java.lang.String fileName,
byte uid)
Determines if the given file is writable. |
void |
close(byte[] fd)
Closes the file descriptor's stream and releases any system resources used. |
boolean |
delete(java.lang.String fileName,
byte uid)
Removes the specified file from the mounted file system. |
boolean |
exists(java.lang.String fileName)
Determines if the given file exists on the mounted file system. |
byte[] |
getContents(java.lang.String fileName,
byte uid)
Gets the complete contents of a file on the mounted file system. |
long |
getLength(byte[] fd)
Gets the length of the file represented by the file descriptor. |
long |
getOffset(byte[] fd)
Gets the current offset into the file. |
int |
getOtherPermissions(java.lang.String fileName)
Gets the other (non-owner) permissions for the given file. |
int |
getUser(java.lang.String fileName)
Gets the owner of a file. |
int |
getUserPermissions(java.lang.String fileName)
Gets the user/owner permissions for the given file. |
void |
init(java.lang.String[] args)
This method will be called the first time a mounted file system accessed. |
boolean |
isDirectory(java.lang.String fileName)
Determines if the given name represents a directory. |
boolean |
isFile(java.lang.String fileName)
Determines if the given name represents a file and not a directory. |
long |
lastModified(java.lang.String fileName)
Indicates the time the file was last modified. |
long |
length(java.lang.String fileName)
Gets the length of the file. |
java.lang.String[] |
list(java.lang.String fileName,
byte uid)
Retrieves a listing of the files in the directory specified. |
boolean |
mkdir(java.lang.String fileName,
byte uid)
Creates a directory on the mounted file system. |
byte[] |
openRandomFD(java.lang.String fileName,
byte uid)
Opens the given file for random access. |
byte[] |
openReadingFD(java.lang.String fileName,
byte uid)
Opens the given file for reading. |
byte[] |
openWritingFD(java.lang.String fileName,
boolean append,
byte uid)
Opens the given file for writing. |
int |
readBytes(byte[] fd,
byte[] data,
int start,
int length)
Reads from the file represented by the file descriptor. |
boolean |
rename(java.lang.String srcname,
java.lang.String destname,
byte uid)
Changes the name of a file. |
void |
seek(byte[] fd,
long n)
Moves the file pointer to a given location, measured in bytes from the beginning of the file. |
void |
setOtherPermissions(java.lang.String fileName,
int perms,
byte uid)
Changes the other (non-owner) permissions for the given file. |
void |
setUser(java.lang.String fileName,
byte newUID,
byte uid)
Sets the owner of the given file. |
void |
setUserPermissions(java.lang.String fileName,
int perms,
byte uid)
Changes the user/owner permissions for the given file. |
long |
skipBytes(byte[] fd,
long n)
Skips the next n bytes of data from the stream. |
void |
touch(java.lang.String fileName,
byte uid)
Updates the last modified time on the given file to the current time. |
void |
unmount()
Allows the driver a chance to clean up and release any resources used when a mount point is removed. |
void |
writeBytes(byte[] fd,
byte[] data,
int start,
int length)
Writes the given data to the file represented by the file descriptor. |
Method Detail |
public void init(java.lang.String[] args) throws java.lang.Exception
args
- Any arguments needed to initialize the file system.public boolean exists(java.lang.String fileName)
fileName
- The file.public boolean canWrite(java.lang.String fileName, byte uid)
fileName
- The file.uid
- The user that is trying to access the file.public boolean canRead(java.lang.String fileName, byte uid)
fileName
- The file.uid
- The user that is trying to access the file.public boolean canExec(java.lang.String fileName, byte uid)
fileName
- The file.uid
- The user that is trying to access the file.public boolean isFile(java.lang.String fileName)
fileName
- The file.public boolean isDirectory(java.lang.String fileName)
fileName
- The file.public long lastModified(java.lang.String fileName)
fileName
- The file.public long length(java.lang.String fileName)
fileName
- The file.public boolean mkdir(java.lang.String fileName, byte uid)
fileName
- The name of the directory to create.uid
- The user that is trying to create the directory.public boolean rename(java.lang.String srcname, java.lang.String destname, byte uid)
srcname
- The name of the file to be changed.destname
- The new name for the file.uid
- The user that is trying to rename the file.public java.lang.String[] list(java.lang.String fileName, byte uid)
fileName
- The directory to get a listing from.uid
- The user trying to retreive the list.public boolean delete(java.lang.String fileName, byte uid)
fileName
- The File to delete.uid
- The user trying to delete the file.public void touch(java.lang.String fileName, byte uid) throws java.io.IOException
fileName
- The file to touch.uid
- The user trying to update the file.public void setUserPermissions(java.lang.String fileName, int perms, byte uid) throws java.io.IOException
fileName
- The file.perms
- The new permissions.uid
- The user that is trying to change the file.public void setOtherPermissions(java.lang.String fileName, int perms, byte uid) throws java.io.IOException
fileName
- The file.perms
- The new permissions.uid
- The user that is trying to change the file.public void setUser(java.lang.String fileName, byte newUID, byte uid) throws java.io.IOException
fileName
- The file.newUID
- The new owner.uid
- The user that is trying to change the file.public int getUserPermissions(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- The file.public int getOtherPermissions(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- The file.public int getUser(java.lang.String fileName) throws java.io.FileNotFoundException
fileName
- The file.public byte[] openWritingFD(java.lang.String fileName, boolean append, byte uid) throws java.io.IOException
fileName
- The name of the file to open.append
- If true and the file exists, the file should be
opened and the file pointer set to the end of the file.
If false and the file exists, all contents of the file
should be erased and the file's length set to 0.uid
- The user trying to open the file.public byte[] openReadingFD(java.lang.String fileName, byte uid) throws java.io.FileNotFoundException
fileName
- The name of the file to open.uid
- The user trying to open the file.public byte[] openRandomFD(java.lang.String fileName, byte uid) throws java.io.IOException
fileName
- The name of the file to open.uid
- The user trying to open the file.public void writeBytes(byte[] fd, byte[] data, int start, int length) throws java.io.IOException
fd
- The file descriptor identifying the file to write to.data
- The data to write.start
- The start offset in the data.length
- The number of bytes to write.public int readBytes(byte[] fd, byte[] data, int start, int length) throws java.io.IOException
fd
- The file descriptor identifying the file to read from.data
- A buffer to store the data that is read.start
- The start offset in the buffer.length
- The number of bytes to read.public void seek(byte[] fd, long n) throws java.io.IOException
fd
- The file descriptor identifying the file.n
- The new position for the file pointer.public long skipBytes(byte[] fd, long n) throws java.io.IOException
fd
- The file descriptor identifying the file.n
- The number of bytes to skip.public long getOffset(byte[] fd) throws java.io.IOException
fd
- The file descriptor identifying the file.public long getLength(byte[] fd) throws java.io.IOException
fd
- The file descriptor identifying the file.public int available(byte[] fd) throws java.io.IOException
fd
- The file descriptor identifying the file.public void close(byte[] fd) throws java.io.IOException
fd
- The file descriptor identifying the file.public void unmount()
public byte[] getContents(java.lang.String fileName, byte uid) throws java.io.IOException
fileName
- The file to retreive.uid
- The user trying to execute the file.