ist.palcom.storage.pfs
Class ByteStorage

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

public class ByteStorage
extends AbstractStorage

ByteStorage.java ByteStorage is a very simple filesystem that is implemented on a byte array


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

Constructor Detail

ByteStorage

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

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

create

public int create(java.lang.String filen)
Open a ByteStorage

Specified by:
create in interface Storage
Overrides:
create in class AbstractStorage
Parameters:
filen - the filename
Returns:
an int error code
Throws:
StorageException

open

public int open(java.lang.String filen,
                int mode)
Open a ByteStorage

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

close

public int close(java.lang.String filen)
Close a ByteStorage

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

fd

public int fd(java.lang.String filen)

seek

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

Specified by:
seek in interface Storage
Overrides:
seek in class AbstractStorage
Parameters:
pos - the position to seek
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

read

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

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

readBytes

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

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

write

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

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

writeBytes

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

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

print

public void print()