📄 directory.h
字号:
/////////////////////////////////////////////////////////////
//FileName : directory.h
//
//Creator : Fang Wenbin(0410706)
//CreateTime : 2006-12-26
//
//File Desc:
// the header of directory.cc, implement the operations of
// file or directory.
/////////////////////////////////////////////////////////////
#include "copyright.h"#ifndef DIRECTORY_H#define DIRECTORY_H#include "openfile.h"#define FileNameMaxLen 9 #define s_FILE_NAME_MAX_LEN 14 //the length of filenameclass s_SuperBlock;class DirectoryEntry { public: bool inUse; int sector; char name[FileNameMaxLen + 1]; };
///
///dir entry, which stores file name and inode index
///class s_DirEntry{public: s_DirEntry() { for (int i = 0; i < 14; i++) s_name[i] = '\0'; }public: short s_inodeIndex; // inode index char s_name[s_FILE_NAME_MAX_LEN]; // file name, the max length is 14};class FileHeader;
///
///this class implement the basic operations of file and dir.
///including--
///1.create directory
///2.create file
///3.write file
///4.read file
///5.get file inode
///class Directory { public: Directory(char *parentDir); ~Directory(); static void s_CreateRoot(s_SuperBlock *super);
static int s_SplitPath(char *path, char **buf);
static void s_SplitParentAndFile(char *path, char *parent, char *file);
void s_CreateDir(char *dirName); void s_CreateFile(char *fileName);
int s_FindIndex(FileHeader *inode, char *fileName); FileHeader *s_GetInode(int index); FileHeader *s_FindInode(char *path); s_DirEntry *s_FindDirEntry(char *fileName, int *slot, int *offset);
void s_List();
void s_WriteFile(int size, char *data); void s_ReadFile(int size, char *data); void s_Error(); s_DirEntry *s_GetLastEntry(); int dirHdrIndex; //this file's inode index char *dirPath; //this file's filename bool error; //error indicator, true--come across an error, otherwise, false
FileHeader *dirHdr; //this file's inode};#endif // DIRECTORY_H
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -