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

📄 openfile.java

📁 Nachos 5 java version
💻 JAVA
字号:
// PART OF THE MACHINE SIMULATION. DO NOT CHANGE.package nachos.machine;import java.io.EOFException;/** * A file that supports reading, writing, and seeking. */public class OpenFile {    /**     * Allocate a new <tt>OpenFile</tt> object.     */    public OpenFile() {    }        /**     * Read this file starting at the specified position and return the number     * of bytes successfully read. If no bytes were read because of a fatal     * error, returns -1     *     * @param	pos	the offset in the file at which to start reading.     * @param	buf	the buffer to store the bytes in.     * @param	offset	the offset in the buffer to start storing bytes.     * @param	length	the number of bytes to read.     * @return	the actual number of bytes successfully read, or -1 on failure.     */        public int read(int pos, byte[] buf, int offset, int length) {	return -1;    }        /**     * Write this file starting at the specified position and return the number     * of bytes successfully written. If no bytes were written because of a     * fatal error, returns -1.     *     * @param	pos	the offset in the file at which to start writing.     * @param	buf	the buffer to get the bytes from.     * @param	offset	the offset in the buffer to start getting.     * @param	length	the number of bytes to write.     * @return	the actual number of bytes successfully written, or -1 on     *		failure.     */        public int write(int pos, byte[] buf, int offset, int length) {	return -1;    }    /**     * Get the length of this file.     *     * @return	the length of this file, or -1 if this file has no length.     */    public int length() {	return -1;    }    /**     * Close this file and release any associated system resources.     */    public void close() {    }    /**     * Set the value of the current file pointer.     */    public void seek(int pos) {    }    /**     * Get the value of the current file pointer, or -1 if this file has no     * pointer.     */    public int tell() {	return -1;    }    /**     * Read this file starting at the current file pointer and return the     * number of bytes successfully read. Advances the file pointer by this     * amount. If no bytes could be* read because of a fatal error, returns -1.     *     * @param	buf	the buffer to store the bytes in.     * @param	offset	the offset in the buffer to start storing bytes.     * @param	length	the number of bytes to read.     * @return	the actual number of bytes successfully read, or -1 on failure.     */        public int read(byte[] buf, int offset, int length) {	return -1;    }    /**     * Write this file starting at the current file pointer and return the     * number of bytes successfully written. Advances the file pointer by this     * amount. If no bytes could be written because of a fatal error, returns     * -1.     *     * @param	buf	the buffer to get the bytes from.     * @param	offset	the offset in the buffer to start getting.     * @param	length	the number of bytes to write.     * @return	the actual number of bytes successfully written, or -1 on     *		failure.     */        public int write(byte[] buf, int offset, int length) {	return -1;    }}

⌨️ 快捷键说明

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