filesys.h
来自「操作系统课程设计。在UNIX平台下实现Solary操作系统的一些功能」· C头文件 代码 · 共 97 行
H
97 行
/////////////////////////////////////////////////////////////
//FileName : filesys.h
//
//Creator : Fang Wenbin(0410706)
//CreateTime : 2006-12-26
//
//File Desc:
// 1. s_SuperBlock -- super block of file system
// 2. FileSystem -- the upper layer of filesystem, provides
// a higher level operations of files.
/////////////////////////////////////////////////////////////
#ifndef FS_H#define FS_H#include "copyright.h"#include "openfile.h"class SynchDisk;///
///stores file system's parameters
///class s_SuperBlock{ public: s_SuperBlock(); ~s_SuperBlock(); void Init(); short numOfInodes; //in this DISK, values 256 short numOfZones; //in this DISK, values 1024 short numOfZmapBlocks; //in this DISK, values 1 short numOfImapBlocks; //in this DISK, values 1 short firstDataBlock; //in this DISK, values 67 int limitOfFile; //in this DISK, values 2mb short firstImapBlock; //in this DISK, values 1 short firstZmapBlock; //in this DISK, values 2 short numOfDataBlocks; //in this DISK, values short sizeOfInode; //in this DISK, values 32 short sizeOfDirEntry; //in this DISK, values 16 short numOfInodeBlocks; //in this DISK, values 64 short firstInodeBlock; //in this DISK, values 3};#ifdef FILESYS_STUB class FileSystem { public: FileSystem(bool format) {} bool Create(char *name, int initialSize) { int fileDescriptor = OpenForWrite(name); if (fileDescriptor == -1) return FALSE; Close(fileDescriptor); return TRUE; } OpenFile* Open(char *name) { int fileDescriptor = OpenForReadWrite(name, FALSE); if (fileDescriptor == -1) return NULL; return new OpenFile(""); } bool Remove(char *name) { return Unlink(name) == 0; }};#else // FILESYS///
///the main class of file system
///higher level operations of files
///class FileSystem { public: FileSystem(bool format); ~FileSystem(); void s_CreateFile(char *filePath); void s_CreateDir(char *filePath); void s_WriteFile(char *filePath, int size, char *data); void s_ReadFile(char *filePath, int size, char *data); int s_GetFileLength(char *filePath); void s_RemoveFile(char *filePath); int s_GetFileType(char *filePath); void s_CopyFile(char *src, char *des); void s_RenameFile(char *src, char *des); void s_List(char *dir); s_SuperBlock *s_superBlock; //super block SynchDisk *s_synchDisk; };#endif // FILESYS#endif // FS_H
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?