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

📄 openfile.cc

📁 操作系统课程设计。在UNIX平台下实现Solary操作系统的一些功能
💻 CC
字号:
// openfile.cc //	Routines to manage an open Nachos file.  As in UNIX, a//	file must be open before we can read or write to it.//	Once we're all done, we can close it (in Nachos, by deleting//	the OpenFile data structure).////	Also as in UNIX, for convenience, we keep the file header in//	memory while the file is open.//// Copyright (c) 1992-1993 The Regents of the University of California.// All rights reserved.  See copyright.h for copyright notice and limitation // of liability and disclaimer of warranty provisions.#include "copyright.h"#include "filehdr.h"#include "openfile.h"#include "system.h"#ifdef HOST_SPARC#include <strings.h>#endif//----------------------------------------------------------------------// OpenFile::OpenFile// 	Open a Nachos file for reading and writing.  Bring the file header//	into memory while the file is open.////	"sector" -- the location on disk of the file header for this file//----------------------------------------------------------------------OpenFile::OpenFile(char* fileName){ 	dir = new Directory((char*)fileName);}//----------------------------------------------------------------------// OpenFile::~OpenFile// 	Close a Nachos file, de-allocating any in-memory data structures.//----------------------------------------------------------------------OpenFile::~OpenFile(){	delete dir;}intOpenFile::Read(char *into, int numBytes){	dir->s_ReadFile(numBytes, into);	}intOpenFile::Write(char *into, int numBytes){	dir->s_WriteFile(numBytes, into);	}intOpenFile::ReadAt(char *into, int numBytes, int pos){	int len = dir->dirHdr->numBytes;	char *data = new char[len];	dir->s_ReadFile(len, data);	data += pos;	memcpy(into, data, numBytes);	data -= pos;	delete data;}intOpenFile::WriteAt(char *into, int numBytes, int pos){}

⌨️ 快捷键说明

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