ist.palcom.storage.pfs
Class FileStorage

java.lang.Object
  extended by ist.palcom.storage.pfs.AbstractStorage
      extended by ist.palcom.storage.pfs.FileStorage
All Implemented Interfaces:
Storage

public class FileStorage
extends AbstractStorage


Field Summary
 
Fields inherited from interface ist.palcom.storage.pfs.Storage
ERROR, NOP, OK, READ, READWRITE, WRITE
 
Constructor Summary
FileStorage(java.lang.String root)
          Create a FileStorage
 
Method Summary
 int close(java.lang.String file)
          Close a FileStorage
 int delete(java.lang.String file)
          Delete a file
 long length(java.lang.String file)
          The lenght of the file
 int open(java.lang.String name, int mode)
          Open a FileStorage
 long pos(java.lang.String file)
          Return the position of the pointer
 int read(java.lang.String file)
          Read from the file
 int readBytes(java.lang.String file, byte[] b, int off, int len)
          Read from the FileStorage
 int seek(java.lang.String file, long pos)
          Seek in a StorageAccessStream
 int write(java.lang.String file, int b)
          Write a byte to a file
 int writeBytes(java.lang.String file, byte[] b, int off, int len)
          Write a byte array
 
Methods inherited from class ist.palcom.storage.pfs.AbstractStorage
available, create, dirs, volume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileStorage

public FileStorage(java.lang.String root)
Create a FileStorage

Parameters:
root - the name of the root
Throws:
StorageException
Method Detail

open

public int open(java.lang.String name,
                int mode)
Open a FileStorage

Specified by:
open in interface Storage
Specified by:
open in class AbstractStorage
Parameters:
name - the filename
mode - true == writeover false == append
Returns:
an int error code
Throws:
StorageException

close

public int close(java.lang.String file)
Close a FileStorage

Specified by:
close in interface Storage
Specified by:
close in class AbstractStorage
Returns:
an int error code
Throws:
StorageException

pos

public long pos(java.lang.String file)
Return the position of the pointer

Specified by:
pos in interface Storage
Overrides:
pos in class AbstractStorage
Returns:
an long
Throws:
StorageException

seek

public int seek(java.lang.String file,
                long pos)
Seek in a StorageAccessStream

Specified by:
seek in interface Storage
Overrides:
seek in class AbstractStorage
Parameters:
pos - the position to seek
Throws:
StorageException

read

public int read(java.lang.String file)
Read from the file

Specified by:
read in interface Storage
Specified by:
read in class AbstractStorage
Parameters:
file - the name of the file
Returns:
an int
Throws:
StorageException

write

public int write(java.lang.String file,
                 int b)
Write a byte to a file

Specified by:
write in interface Storage
Specified by:
write in class AbstractStorage
Parameters:
file - the name of the file
b - the Byte
Throws:
StorageException

readBytes

public int readBytes(java.lang.String file,
                     byte[] b,
                     int off,
                     int len)
Read from the FileStorage

Specified by:
readBytes in interface Storage
Overrides:
readBytes in class AbstractStorage
Parameters:
file - the name of the file
b - the byte array to store
off - the offset
len - the length of the byte array
Returns:
how many bytes that was read
Throws:
StorageException

writeBytes

public int writeBytes(java.lang.String file,
                      byte[] b,
                      int off,
                      int len)
Write a byte array

Specified by:
writeBytes in interface Storage
Overrides:
writeBytes in class AbstractStorage
Parameters:
file - the name of the file
b - the byte array
off - offset in the stream
len - lenght of the stream
Throws:
StorageException

length

public long length(java.lang.String file)
The lenght of the file

Parameters:
file - the name of the file
Returns:
an long
Throws:
StorageException

delete

public int delete(java.lang.String file)
Delete a file

Specified by:
delete in interface Storage
Overrides:
delete in class AbstractStorage
Parameters:
file - the name of the file
Returns:
int errorcode
Throws:
StorageException