資源簡介
設計一個簡單的多用戶文件系統。①在系統中用一個文件來模擬一個磁盤;②此系統至少有:Create、delete、open、close、read、write等和部分文件屬性的功能。③實現這個文件系統。④能實際演示這個文件系統。
(1)程序采用二級文件目錄(即設置主目錄MFD)和用戶文件目錄(UFD)。另外,為打開文件設置了運行文件目錄(AFD)。
(2)為了便于實現,可以對文件讀寫作進行簡化,在執行讀寫命令時,只需改讀寫指針,并不進行實際的讀寫操作。
(3)文件目錄的檢索使用簡單的線性搜索即可。
(4)其他自行設定的要求條件。
代碼片段和文件信息
#include?
#include
#include?
#include?
#include?
#include?“File.h“
#include?“User.h“
using?namespace?std;
struct?MFD{?//?主文件目錄
????string?u_name;?//?用戶名
????int?addr;?//?指向子目錄指針
}mfd[10];
int?mfdcnt?=?8;?//?用戶數
int?k?=?5;?//?每個用戶最多打開的文件數
struct?UFD{?//?用戶文件目錄
????File?file[1000];
????string?u_name;?//?用戶名
????int?id;?//?文件的總數
????int?cnt;?//?用戶文件存在的個數
????int?open_cnt;?//?用戶打開文件個數,最大為k
????void?init()?{?cnt=0;?open_cnt=0;?id=0;}
????void?create()?{?file[id].create();?cnt++;?id++;}
????void?del(int?pos)?{?file[pos].del();?cnt--;}
????void?open(int?pos)?{
????????if(open_cnt?==?k)?cout<<“您已經打開了“< ????????else?{
????????????if(file[pos].open()?==?1)?open_cnt++;
????????}
????}
????void?clo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2020-06-11?22:50??代碼\
?????文件????????1220??2020-06-11?12:39??代碼\FILEEXP.cbp
?????文件?????????429??2020-06-11?12:39??代碼\FILEEXP.depend
?????文件?????????737??2020-06-11?12:39??代碼\FILEEXP.layout
?????文件????????1553??2020-06-11?12:39??代碼\File.h
?????文件?????????259??2020-06-11?12:39??代碼\MFD.h
?????文件????????1124??2020-06-11?12:39??代碼\UFD.h
?????文件?????????395??2020-06-11?20:33??代碼\User.h
?????文件?????7065060??2020-06-11?20:24??代碼\User.h.gch
?????目錄???????????0??2020-06-11?15:31??代碼\bin\
?????目錄???????????0??2020-06-11?15:31??代碼\bin\Debug\
?????文件?????1043083??2020-06-11?12:39??代碼\bin\Debug\FILEEXP.exe
?????文件????????5448??2020-06-11?12:39??代碼\main.cpp
?????文件?????1936825??2020-06-11?20:18??代碼\main.exe
?????目錄???????????0??2020-06-11?15:31??代碼\obj\
?????目錄???????????0??2020-06-11?15:31??代碼\obj\Debug\
?????文件???????55632??2020-06-11?12:39??代碼\obj\Debug\main.o
- 上一篇:ttms最終版.zip
- 下一篇:HRN高響應比優先調度算法的C語言模擬.cpp
評論
共有 條評論