⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 openfilewithposition.java

📁 nachos操作系统框架
💻 JAVA
字号:
// 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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -