uk.me.parabola.imgfmt.fs
Interface FileSystem

All Superinterfaces:
java.io.Closeable
All Known Implementing Classes:
ImgFS

public interface FileSystem
extends java.io.Closeable

File system operations.

Author:
Steve Ratcliffe

Method Summary
 void close()
          Close the filesystem.
 ImgChannel create(java.lang.String name)
          Create a new file it must not already exist.
 FileSystemParam fsparam()
          Get the filesystem / archive parameters.
 void fsparam(FileSystemParam param)
          Reconfigure the filesystem with the given parameters.
 java.util.List<DirectoryEntry> list()
          List all the files in the directory.
 DirectoryEntry lookup(java.lang.String name)
          Lookup the file and return a directory entry for it.
 ImgChannel open(java.lang.String name, java.lang.String mode)
          Open a file.
 void sync()
          Sync with the underlying file.
 

Method Detail

create

ImgChannel create(java.lang.String name)
                  throws FileExistsException
Create a new file it must not already exist.

Parameters:
name - The file name.
Returns:
A directory entry for the new file.
Throws:
FileExistsException - If the file already exists.

open

ImgChannel open(java.lang.String name,
                java.lang.String mode)
                throws java.io.FileNotFoundException
Open a file. The returned file object can be used to read and write the underlying file.

Parameters:
name - The file name to open.
mode - Either "r" for read access, "w" for write access or "rw" for both read and write.
Returns:
A file descriptor.
Throws:
java.io.FileNotFoundException - When the file does not exist.

lookup

DirectoryEntry lookup(java.lang.String name)
                      throws java.io.IOException
Lookup the file and return a directory entry for it.

Parameters:
name - The filename to look up.
Returns:
A directory entry.
Throws:
java.io.IOException - If an error occurs reading the directory.

list

java.util.List<DirectoryEntry> list()
List all the files in the directory.

Returns:
A List of directory entries.

fsparam

FileSystemParam fsparam()
Get the filesystem / archive parameters. Things that are stored in the header.

Returns:
The filesystem parameters.

fsparam

void fsparam(FileSystemParam param)
Reconfigure the filesystem with the given parameters. Only some parameters can be changed and the may only be changeable at certain points in the construction of a file system for example.

Parameters:
param - The new parameters.
Throws:
java.lang.IllegalStateException - If the changes cannot be made (for example if the file system is already written).

sync

void sync()
          throws java.io.IOException
Sync with the underlying file. All unwritten data is written out to the underlying file.

Throws:
java.io.IOException - If an error occurs during the write.

close

void close()
Close the filesystem. Any saved data is flushed out. It is better to explicitly sync the data out first, to be sure that it has worked.

Specified by:
close in interface java.io.Closeable