|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface OpenFile
Interface that provides read/write access to files in a filesystem. There are two implementations. One is a "stub" that directly turns the file operations into the underlying UNIX operations. (cf. comment in FileSystem.java). The other is the "real" implementation, which turns these operations into read and write disk sector requests. In this baseline implementation of the file system, we don't worry about concurrent accesses to the file system by different threads -- this is part of the assignment.
Method Summary | |
---|---|
int |
close()
Close the file, releasing any resources held in kernel memory. |
long |
length()
Determine the number of bytes in the file (this interface is simpler than the UNIX idiom -- lseek to end of file, tell, lseek back). |
int |
read(byte[] into,
int index,
int numBytes)
Read bytes from the file, starting at the implicit position. |
int |
readAt(byte[] into,
int index,
int numBytes,
long position)
Read bytes from the file, bypassing the implicit position. |
void |
seek(long position)
Set the position from which to start reading/writing -- UNIX lseek |
int |
write(byte[] from,
int index,
int numBytes)
Write bytes to the file, starting at the implicit position. |
int |
writeAt(byte[] from,
int index,
int numBytes,
long position)
Write bytes to the file, bypassing the implicit position. |
Method Detail |
---|
void seek(long position)
position
- The desired position in the file, in bytes from
the start of file.int readAt(byte[] into, int index, int numBytes, long position)
into
- Buffer into which to read data.index
- Starting position in the buffer.numBytes
- Number of bytes desired.position
- Starting position in the file.
int writeAt(byte[] from, int index, int numBytes, long position)
from
- Buffer containing the data to be written.index
- Starting position in the buffer.numBytes
- Number of bytes to write.position
- Starting position in the file.
int read(byte[] into, int index, int numBytes)
into
- Buffer into which to read data.index
- Starting position in the buffer.numBytes
- Number of bytes desired.
int write(byte[] from, int index, int numBytes)
from
- Buffer containing the data to be written.index
- Starting position in the buffer.numBytes
- Number of bytes to write.
long length()
int close()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |