操作系統(tǒng)課程設(shè)計報告_第1頁
操作系統(tǒng)課程設(shè)計報告_第2頁
操作系統(tǒng)課程設(shè)計報告_第3頁
操作系統(tǒng)課程設(shè)計報告_第4頁
操作系統(tǒng)課程設(shè)計報告_第5頁
已閱讀5頁,還剩13頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

操作系統(tǒng)課程設(shè)計報告

概述:本課程設(shè)計旨在使學(xué)生熟悉文件管理系統(tǒng)的設(shè)計方法,加深對所學(xué)各種文件操作的了解及其操作方法的特點。通過模擬文件系統(tǒng)的實現(xiàn),深入理解操作系統(tǒng)中文件系統(tǒng)的理論知識,加深對教材中的重要算法的理解。同時通過編程實現(xiàn)這些算法,更好地掌握操作系統(tǒng)的原理及實現(xiàn)方法,提高綜合運用各專業(yè)課知識的能力。主要任務(wù):本課程設(shè)計的主要任務(wù)是設(shè)計和實現(xiàn)一個簡單的文件系統(tǒng),包括建立文件存儲介質(zhì)的管理機(jī)制、建立目錄(采用一級目錄結(jié)構(gòu))、文件系統(tǒng)功能(顯示目錄、創(chuàng)建、刪除、打開、關(guān)閉、讀、寫)和文件操作接口(顯示目錄、創(chuàng)建、刪除、打開、關(guān)閉、讀、寫)。系統(tǒng)設(shè)計:本系統(tǒng)模擬一個文件管理系統(tǒng),要完成對文件的基本操作,包括文件、文件夾的打開、新建、刪除和讀取寫入文件,創(chuàng)建更改目錄,列出目錄內(nèi)容等信息。系統(tǒng)建立了文件目錄樹,存儲文件系統(tǒng)中的所有文件。對于用戶名下的文件,用文件目錄樹的分支來存儲。采用命令行操作界面很直觀,也方便用戶進(jìn)行操作,用戶只要按照操作界面所顯示的命令來操作即可。整體設(shè)計框架:系統(tǒng)初始化界面由創(chuàng)建用戶存儲空間、管理文件、退出系統(tǒng)三個模塊組成。用戶創(chuàng)建由創(chuàng)建用戶存儲空間、進(jìn)入目錄、刪除用戶存儲空間、顯示所有用戶存儲空間等模塊組成。然后各個模塊再由一些小模塊組成。其中創(chuàng)建文件、打開關(guān)閉文件、讀寫文件等文件操作模塊包括在進(jìn)入目錄模塊里面。系統(tǒng)實現(xiàn):以下是本課程設(shè)計的主要內(nèi)容的實現(xiàn)程序代碼:```c#include<stdio.h>#include<string.h>#include<stdlib.h>typedefstructfile{charname[10];structfile*next;}File;typedefstructcontent{charname[10];File*file;intf_num;structcontent*next;}Content;typedefstructuser{charname[10];charpsw[10];Content*con;structuser*next;}User;charcur_user[20];User*user;intuser_num=0;```添加文件:在該函數(shù)中,我們首先需要獲取文件名,然后檢查是否已經(jīng)存在該文件。如果存在,則輸出錯誤信息;否則,創(chuàng)建一個新的文件并將其添加到文件列表中。voidadd_file(Content*con){charf_name[10];chartail[]=".txt";intexist=0;File*file=con->file->next;printf("請輸入文件名:");scanf("%s",f_name);strcat(f_name,tail);while(file!=NULL){if(strcmp(f_name,file->name)==0){exist=1;break;}file=file->next;}if(exist==1){printf("文件已存在!---AddFile\n");return;}FILE*q;q=fopen(f_name,"w");fclose(q);while(file->next!=NULL)file=file->next;File*new_f=(File*)malloc(sizeof(File));strcpy(new_f->name,f_name);new_f->next=NULL;file->next=new_f;con->f_num++;printf("添加文件%s成功!\n",f_name);}讀取文件:在該函數(shù)中,我們需要獲取文件名并檢查是否存在該文件。如果不存在,則輸出錯誤信息;否則,打開該文件并讀取其內(nèi)容。voidread_file(Content*con){charname[10];chartail[]=".txt";intfind=0;File*file=con->file->next;printf("請輸入需要讀取的文件名:");scanf("%s",name);strcat(name,tail);while(file!=NULL){if(strcmp(name,file->name)==0){find=1;break;}file=file->next;}if(find==0){printf("讀取錯誤或文件不存在!---ReadFile\n");return;}printf("文件已打開...\n");FILE*fp=fopen(name,"r");charc;while((c=fgetc(fp))!=EOF)printf("%c",c);fclose(fp);printf("\n文件%s讀取成功!\n",name);}寫入文件:在該函數(shù)中,我們需要獲取文件名并檢查是否存在該文件。如果不存在,則輸出錯誤信息;否則,打開該文件并允許用戶輸入內(nèi)容,直到輸入“#”為止。voidwrite_file(Content*con){charname[10];chartail[]=".txt";intfind=0;File*file=con->file->next;printf("請輸入需要編輯的文件名:");scanf("%s",name);strcat(name,tail);while(file!=NULL){if(strcmp(name,file->name)==0){find=1;break;}file=file->next;}if(find==0){printf("寫入錯誤或文件不存在!---WriteFile\n");return;}printf("文件被打開...\n");FILE*fp=fopen(name,"a");charc;while((c=getchar())!='#')fputc(c,fp);fclose(fp);printf("文件%s編輯成功!\n",name);}scanf("%s",name);Content*current_con=u->con;while(current_con->next!=NULL){if(strcmp(current_con->name,name)==0){break;}current_con=current_con->next;}File*current_file=current_con->file;while(current_file->next!=NULL){current_file=current_file->next;}current_file->next=temp_f;temp_f->next=NULL;printf("移動成功!\n");}intdisplay_contents(User*u){inti=0;Content*con=u->con->next;while(con!=NULL){i++;printf("存儲空間%d:%s\n",i,con->name);con=con->next;}printf("顯示存儲空間為%d\n",i);returni;}intis_exist_con(Content*c,charname[]){intexist=0;Content*con=c->next;while(con!=NULL){if(strcmp(con->name,name)==0){exist=1;break;}con=con->next;}returnexist;}voidadd_content(User*u){charname[10];intexist=0;Content*con,*current_con;File*file,*current_file;do{exist=0;printf("輸入存儲空間名稱:");scanf("%s",name);if(is_exist_con(u->con,name)){exist=1;printf("此存儲空間已存在!\n");}}while(exist==1);printf("新建中...\n");current_con=u->con;while(current_con->next!=NULL){current_con=current_con->next;}current_file=current_con->file;while(current_file->next!=NULL){current_file=current_file->next;}Content*new_con=(Content*)malloc(sizeof(Content));new_con->next=NULL;File*new_file=(File*)malloc(sizeof(File));new_file->next=NULL;new_con->file=new_file;current_file->next=new_file;current_con->next=new_con;}scanf("%d",&choice);switch(choice){case1:display_files(con);break;case2:add_file(con);break;case3:write_file(con);break;case4:read_file(con);break;case5:delete_file(con);break;case6:move_file(u,con);break;}}while(choice!=0);voidlogin(){intchoice;intfind=0;intlogin=0;User*p;Content*con;User*head=user->next;p=(User*)malloc(sizeof(User));con=(Content*)malloc(sizeof(Content));con->next=NULL;p->con=con;head=p;do{printf("1.顯示所有存儲空間\n");printf("2.新建存儲空間\n");printf("3.刪除存儲空間\n");printf("4.寫入存儲空間\n");printf("0.退出\n");printf("輸入以上選項:");scanf("%d",&choice);switch(choice){case1:display_contents(head);break;case2:add_content(head);break;case3:del_content(head);break;case4:into_content(head);break;}}while(choice!=0);}intmain(){user=(User*)malloc(

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論