|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnachos.machine.OpenFile
public class OpenFile
A file that supports reading, writing, and seeking.
| Constructor Summary | |
|---|---|
OpenFile()
Allocate a new unnamed OpenFile that is not associated with any file system. |
|
OpenFile(FileSystem fileSystem,
String name)
Allocate a new OpenFile object with the specified name on the specified file system. |
|
| Method Summary | |
|---|---|
void |
close()
Close this file and release any associated system resources. |
FileSystem |
getFileSystem()
Get the file system to which this file belongs. |
String |
getName()
Get the name of this open file. |
int |
length()
Get the length of this file. |
int |
read(byte[] buf,
int offset,
int length)
Read this file starting at the current file pointer and return the number of bytes successfully read. |
int |
read(int pos,
byte[] buf,
int offset,
int length)
Read this file starting at the specified position and return the number of bytes successfully read. |
void |
seek(int pos)
Set the value of the current file pointer. |
int |
tell()
Get the value of the current file pointer, or -1 if this file has no pointer. |
int |
write(byte[] buf,
int offset,
int length)
Write this file starting at the current file pointer and return the number of bytes successfully written. |
int |
write(int pos,
byte[] buf,
int offset,
int length)
Write this file starting at the specified position and return the number of bytes successfully written. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public OpenFile(FileSystem fileSystem,
String name)
fileSystem - the file system to which this file belongs.name - the name of the file, on that file system.public OpenFile()
| Method Detail |
|---|
public FileSystem getFileSystem()
public String getName()
public int read(int pos,
byte[] buf,
int offset,
int length)
pos - the offset in the file at which to start reading.buf - the buffer to store the bytes in.offset - the offset in the buffer to start storing bytes.length - the number of bytes to read.
public int write(int pos,
byte[] buf,
int offset,
int length)
pos - the offset in the file at which to start writing.buf - the buffer to get the bytes from.offset - the offset in the buffer to start getting.length - the number of bytes to write.
public int length()
public void close()
public void seek(int pos)
public int tell()
public int read(byte[] buf,
int offset,
int length)
buf - the buffer to store the bytes in.offset - the offset in the buffer to start storing bytes.length - the number of bytes to read.
public int write(byte[] buf,
int offset,
int length)
buf - the buffer to get the bytes from.offset - the offset in the buffer to start getting.length - the number of bytes to write.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||