-
大小: 10.46MB文件類型: .rar金幣: 1下載: 0 次發(fā)布日期: 2023-11-12
- 語言: C/C++
- 標(biāo)簽:
資源簡介
設(shè)計(jì)和實(shí)現(xiàn)了一個(gè)模擬Linux文件系統(tǒng),采用樹的結(jié)構(gòu)設(shè)計(jì),可登錄注冊,是多用戶文件系統(tǒng),互不干擾。實(shí)驗(yàn)實(shí)現(xiàn)的功能有目錄的創(chuàng)建,刪除,復(fù)制,粘貼,重命名,列表顯示,以及文件的創(chuàng)建,刪除,復(fù)制,粘貼,重命名,讀寫等功能。并對用戶使用該文件系統(tǒng)需要簡單注冊登錄,具有指導(dǎo)用戶操作功能。壓縮包內(nèi)含有這個(gè)系統(tǒng)的說明書,PPT,以及流程圖的VSDX文件和JPEG文件,可以直接用于大型實(shí)驗(yàn)
代碼片段和文件信息
#include?“head.h“
FileSystem::FileSystem(myDirectory*?root?string?curPath?string?userName){
FileSystem::root?=?root;
FileSystem::currentDir?=?FileSystem::root;
FileSystem::curPath?=?curPath;?
FileSystem::copyTempFile?=?NULL;
FileSystem::copyTempDir?=?NULL;?
FileSystem::userName?=?userName;
}
int?FileSystem::newDirectory(string?dirName){
int?res?=?0;
if(whetherContainsIllegalCharacters(dirName)){
myDirectory*?currentDir?=?getCurrentDirectory();?
myDirectory*?newDir?=?new?myDirectory();
newDir->type?=?1;?
newDir->directoryName?=?dirName;
newDir->directorySize?=?0;
newDir->parentDir?=?currentDir;?
newDir->nextDir?=?NULL;
newDir->preDir?=?NULL;
newDir->filePtr?=?NULL;
newDir->dirPtr?=?NULL;
strcpy(newDir->lastTimegetTime());
if(currentDir->dirPtr?==?NULL)
currentDir->dirPtr?=?newDir;
else{
myDirectory*?tmp?=?currentDir->dirPtr;
if(findDirByName(dirName?tmp)){
while(tmp->nextDir?!=?NULL){?
tmp?=?tmp->nextDir;
}
tmp->nextDir?=?newDir;
newDir->preDir?=?tmp;
}else?res?=?1;
}
}else?res?=?2;
return?res;
}
char?*FileSystem::getTime(){
time_t?t?=?time(0);
char?tmp[64];
strftime(?tmp?sizeof(tmp)?“%Y/%m/%d?%X“l(fā)ocaltime(&t));
return?tmp;
}?
bool?FileSystem::findDirByName(string?dirName?myDirectory*?dir){
bool?flag?=?true;
myDirectory*?tmp?=?dir;
while(tmp?!=?NULL){
if(tmp->directoryName?==?dirName){
flag?=?false;
break;
}
tmp?=?tmp->nextDir;
}
return?flag;
}
bool?FileSystem::findFileByName(string?fileName?myFile*?file){
bool?flag?=?false;
myFile*?tmp?=?file;
while(tmp?!=?NULL){
if(tmp->fireName?==?fileName){
flag?=?true;
break;
}
tmp?=?tmp->nextFile;
}
return?flag;
}?
void?FileSystem::setCurrentDirectory(myDirectory*?dir){
FileSystem::currentDir?=?dir;
}?
myDirectory*?FileSystem::getCurrentDirectory(){
return?FileSystem::currentDir;
}
string?FileSystem::getCurPath(){
return?FileSystem::curPath;
}
void?FileSystem::setCurPath(string?s){
FileSystem::curPath?=?s;
}
void?FileSystem::setTempFile(myFile*?file){
FileSystem::copyTempFile?=?file;?
}?
myFile*?FileSystem::getTempFile(){
return?FileSystem::copyTempFile;
}
void?FileSystem::setTempDir(myDirectory*?dire){
FileSystem::copyTempDir?=?dire;
}
?
myDirectory*?FileSystem::getTempDir(){
return?FileSystem::copyTempDir;
}
string?FileSystem::getUserName(){
return?FileSystem::userName;
}?
int?FileSystem::showCurrentDirectory(){
int?res?=?0;
myDirectory*?currentDir?=?getCurrentDirectory();
myDirectory*?tmp?=?currentDir->dirPtr;
myFile*?tmp2?=?currentDir->filePtr;
if(tmp?!=?NULL?||?tmp2?!=?NULL){
if(tmp?!=?NULL){
while(tmp?!=?NULL){
cout?<directoryName;
cout?<“?????dir“;
cout?<“?????“?<directorySize;
cout?<“?????“?<lastTime?< tmp?=?tmp->nextDir;?
}
}?
if(tmp2?!=?NULL){
while(tmp2?!=?NUL
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????15053??2016-01-07?19:32??cxFileSystem\cxFileSystem.cfp
?????文件????????378??2016-01-07?19:32??cxFileSystem\cxFileSystem.cfpg
?????文件??????16731??2016-01-07?19:32??cxFileSystem\FileSystem.cpp
?????文件???????2954??2015-12-29?22:11??cxFileSystem\FileSystem.h
?????文件???????1068??2015-12-26?20:03??cxFileSystem\function.h
?????文件????????315??2015-12-26?22:15??cxFileSystem\head.h
?????文件??????19233??2015-12-30?19:13??cxFileSystem\kernel.cpp
?????文件?????????95??2015-12-19?10:24??cxFileSystem\main.cpp
?????文件????1682057??2016-01-07?12:30??cxFileSystem\mingw5\cxFileSystem.exe
?????文件????????164??2015-12-28?15:27??cxFileSystem\mingw5\cxsw.txt
?????文件????1046636??2015-12-29?22:39??cxFileSystem\mingw5\FileSystem.o
?????文件????1084824??2016-01-07?12:30??cxFileSystem\mingw5\kernel.o
?????文件?????846575??2015-12-29?22:20??cxFileSystem\mingw5\main.o
?????文件?????847346??2015-12-29?22:20??cxFileSystem\mingw5\User.o
?????文件?????????47??2016-01-07?12:32??cxFileSystem\mingw5\user.txt
?????文件???????1039??2015-12-26?23:36??cxFileSystem\mydefineClass.h
?????文件????????297??2015-12-21?16:01??cxFileSystem\User.cpp
?????文件????????325??2015-12-21?10:36??cxFileSystem\User.h
????..A.SH.???????113??2015-12-17?17:45??cxFileSystem\~
?????文件????2206994??2016-01-17?16:10??大型實(shí)驗(yàn)報(bào)告書.doc
?????文件???10681856??2016-01-17?16:11??大型實(shí)驗(yàn)報(bào)告.ppt
?????文件??????90724??2015-12-29?10:01??文件創(chuàng)建.jpg
?????文件??????63165??2015-12-29?10:37??文件讀取.jpg
?????文件??????59522??2015-12-29?15:56??文件復(fù)制.jpg
?????文件??????99863??2015-12-28?16:57??文件結(jié)構(gòu).jpg
?????文件??????54420??2015-12-29?10:08??文件刪除.jpg
?????文件??????73486??2015-12-29?10:39??文件寫入.jpg
?????文件??????82517??2015-12-29?10:29??文件粘貼.jpg
?????文件??????68702??2015-12-29?10:13??文件重命名.jpg
?????文件?????193488??2015-12-28?16:33??系統(tǒng)流程.jpg
............此處省略24個(gè)文件信息
評論
共有 條評論