-
大小: 2.16MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2023-10-15
- 語(yǔ)言: C/C++
- 標(biāo)簽: 文件系統(tǒng)??C/C++??樹狀結(jié)構(gòu)??
資源簡(jiǎn)介
文件系統(tǒng)的目錄結(jié)構(gòu)采用類似Linux的樹狀結(jié)構(gòu);
a) 目錄的添加、刪除、重命名;
b) 目錄的顯示(列表)
c) 文件的添加、刪除、重命名
d) 文件和目錄的拷貝
用戶進(jìn)入時(shí)顯示可用命令列表;用戶輸入help時(shí)顯示所有命令的幫助文檔;用戶輸入exit時(shí)退出該系統(tǒng),開發(fā)語(yǔ)言選用C/C++

代碼片段和文件信息
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include“FileSystem.h“
using?namespace?std;
FileSystem::FileSystem()
{
ifstream?in_stream;
int?i;
in_stream.open(“file.txt“);
Node?df;
if(in_stream.fail())
{
cout<<“Input?file?opening?failed.\n“;
exit(1);
}
else{
for(i=0;i {
in_stream>>df.flag>>df.name>>df.owner>>df.CreateTime>>df.Last_Visit
>>df.Last_Modify>>df.visitProperty>>df.parent>>df.left>>df.right>>df.path;
node[i]=df;
}
}
in_stream.close();
curdir=0;
fd=0;
in_stream.open(“user.txt“);
if(in_stream.fail())
{
cout<<“Input?file?opening?failed\n“;
exit(1);
}
else{
User?ur;
in_stream>>Amount;
for(i=0;i {
ur.num=i;
in_stream>>ur.username>>ur.password;
user.push_back(ur);
}
}
in_stream.close();
}
FileSystem::~FileSystem()
{
ofstream?out_stream;
int?i;
out_stream.open(“file.txt“);
if(out_stream.fail())
{
cout<<“Output?file?opening?failed.\n“;
exit(1);
}
else{
Node?df;
for(i=0;i {
df=node[i];
out_stream< < <<“????“< <<“????“< }
}
out_stream.close();
out_stream.open(“user.txt“);
if(out_stream.fail())
{
cout<<“Output?file?opening?failed.\n“;
exit(1);
}
else{
User?ur;
list::iterator?iter;
out_stream< iter=user.begin();
while(iter?!=?user.end())
{
ur=*iter;
out_stream< iter++;
}
}
out_stream.close();
}
bool?FileSystem::Finddir(int?tchar?*samename)//從下標(biāo)t開始根據(jù)目錄名查找目錄,找到了返回true并把下標(biāo)值賦給fd,否則返回false
{
fd=-1;
if(strcmp(node[t].namesamename)==0?&&?(node[t].flag==1?||?node[t].flag==0))
{
??????????fd=t;?
??????????return?true;
}
if(node[t].left==-1)
{
return?false;
}
dirout(tsamename);
if(fd==-1)
{
return?false;
}
else
{
if(strcmp(node[fd].namesamename)==0?&&?(node[fd].flag==1?||?node[fd].flag==0))
{
return?true;
}
else
{
return?false;
}
}
}
void?FileSystem::dirout(int?tchar?*samename)
{
if(t==-1)
{
return;
}
else
{
if(strcmp(node[t].namesamename)==0?&&?node[t].flag==1)
{
fd=t;
return;
}
dirout(node[t].rightsamename);
dirout(node[t].leftsamename);
}
return;
}
void?FileSystem::OS_createdir(char?*line)//在當(dāng)前目錄中創(chuàng)建目錄
{
int?ip;
while(!direxist(curdirline))
{
cout<<“該目錄名已經(jīng)存在\n“< cin>>line;
}
p=point(curdir);
if(node[curdir].left==-1)
{
node[curdir].left=2*curdir+1;
i=node[curdir].left;
}
else{
node[p].right=2*p+2;
i=node[p].right;
}
node[i].
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件?????289280??2011-01-04?20:15??文件系統(tǒng)\文件系統(tǒng)實(shí)驗(yàn)文檔.doc
?????文件?????606303??2011-01-01?11:56??文件系統(tǒng)\文件系統(tǒng)程序\Debug\FileSystem.exe
?????文件?????860416??2011-01-01?11:56??文件系統(tǒng)\文件系統(tǒng)程序\Debug\FileSystem.ilk
?????文件?????495892??2011-01-04?18:18??文件系統(tǒng)\文件系統(tǒng)程序\Debug\FileSystem.obj
?????文件????2456816??2011-01-01?11:56??文件系統(tǒng)\文件系統(tǒng)程序\Debug\FileSystem.pch
?????文件????1180672??2011-01-01?11:56??文件系統(tǒng)\文件系統(tǒng)程序\Debug\FileSystem.pdb
?????文件?????634969??2011-01-04?20:08??文件系統(tǒng)\文件系統(tǒng)程序\Debug\main.exe
?????文件?????877848??2011-01-04?20:08??文件系統(tǒng)\文件系統(tǒng)程序\Debug\main.ilk
?????文件??????36403??2011-01-04?20:08??文件系統(tǒng)\文件系統(tǒng)程序\Debug\main.obj
?????文件????2628864??2011-01-04?18:18??文件系統(tǒng)\文件系統(tǒng)程序\Debug\main.pch
?????文件????1213440??2011-01-04?18:19??文件系統(tǒng)\文件系統(tǒng)程序\Debug\main.pdb
?????文件??????99328??2011-01-04?20:12??文件系統(tǒng)\文件系統(tǒng)程序\Debug\vc60.idb
?????文件?????167936??2011-01-04?18:18??文件系統(tǒng)\文件系統(tǒng)程序\Debug\vc60.pdb
?????文件??????34167??2011-01-04?20:12??文件系統(tǒng)\文件系統(tǒng)程序\file.txt
?????文件??????26691??2011-01-04?18:18??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.cpp
?????文件???????3575??2011-01-01?12:00??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.dsp
?????文件????????528??2011-01-01?12:00??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.dsw
?????文件???????1828??2011-01-04?18:18??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.h
?????文件??????41984??2011-01-01?12:00??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.ncb
?????文件??????48640??2011-01-01?12:00??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.opt
?????文件????????786??2011-01-01?11:56??文件系統(tǒng)\文件系統(tǒng)程序\FileSystem.plg
?????文件????????391??2011-01-03?19:49??文件系統(tǒng)\文件系統(tǒng)程序\main.cpp
?????文件???????3509??2011-01-04?20:18??文件系統(tǒng)\文件系統(tǒng)程序\main.dsp
?????文件????????516??2011-01-04?20:18??文件系統(tǒng)\文件系統(tǒng)程序\main.dsw
?????文件??????58368??2011-01-04?20:18??文件系統(tǒng)\文件系統(tǒng)程序\main.ncb
?????文件??????48640??2011-01-04?20:18??文件系統(tǒng)\文件系統(tǒng)程序\main.opt
?????文件????????242??2011-01-04?20:08??文件系統(tǒng)\文件系統(tǒng)程序\main.plg
?????文件?????????77??2011-01-04?20:12??文件系統(tǒng)\文件系統(tǒng)程序\user.txt
?????目錄??????????0??2011-01-04?18:19??文件系統(tǒng)\文件系統(tǒng)程序\Debug
?????目錄??????????0??2011-01-04?20:18??文件系統(tǒng)\文件系統(tǒng)程序
............此處省略4個(gè)文件信息
- 上一篇:C++ 圖像壓縮算法
- 下一篇:機(jī)載激光雷達(dá) Las格式讀寫及顯示
評(píng)論
共有 條評(píng)論