openfilewithposition.java

来自「nachos操作系统框架」· Java 代码 · 共 59 行

JAVA
59
字号
// PART OF THE MACHINE SIMULATION. DO NOT CHANGE.package nachos.machine;/** * An <tt>OpenFile</tt> that maintains a current file position. */public abstract class OpenFileWithPosition extends OpenFile {    /**     * Allocate a new <tt>OpenFileWithPosition</tt> with the specified name on     * the specified file system.     *     * @param	fileSystem	the file system to which this file belongs.     * @param	name		the name of the file, on that file system.     */    public OpenFileWithPosition(FileSystem fileSystem, String name) {	super(fileSystem, name);    }    /**     * Allocate a new unnamed <tt>OpenFileWithPosition</tt> that is not     * associated with any file system.     */    public OpenFileWithPosition() {	super();    }    public void seek(int position) {	this.position = position;    }    public int tell() {	return position;    }    public int read(byte[] buf, int offset, int length) {	int amount = read(position, buf, offset, length);	if (amount == -1)	    return -1;		position += amount;	return amount;    }    public int write(byte[] buf, int offset, int length) {	int amount = write(position, buf, offset, length);	if (amount == -1)	    return -1;		position += amount;	return amount;    }    /**     * The current value of the file pointer.     */    protected int position = 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?