亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? filesystem.c

?? 一個關(guān)于操作系統(tǒng)的線程模擬
?? C
字號:
#include  <stdio.h>
#include  <string.h>
#include  <io.h>
#include  <dos.h>
#include  <conio.h>
#include  <process.h>
#include "head.h"

void main()
{ long currentuserpos,newuserpos;
  long currentfilepos,prefilepos,sourcefilepos,targetfilepos;
  long textpos;
  long currentpasspos,newpasspos;
  log newuser,user;
  pas newpass,pass;
  fil currentfile,prefile,sourcefile,targetfile;
  texter content,newtext,sourcetext,targettext;
  int Pcode,numbers,basement;
  char choice,choice1,choice2,choice3;
  char loguser[20],pw[20],enterfile[8],texts[1000];
  FILE *fp; 
  printf("              Wellcome to virtual file system.\n"
		 "    This program will not damage your current file system.\n"
		 "                   copyright 2004/7/2\n"     
		 "         computer 015       xudong        01171121\n");
                //創(chuàng)建虛擬硬盤
if((fp=fopen("vdisk.vdr","rb+"))==NULL)	//新建vdisk為空文件
	{if((fp=fopen("vdisk.vdr","wb+"))==NULL)//判斷剩余空間,無空間則退出系統(tǒng)
		{printf("Not enough disk space for a virtual drive");
		 exit(0);
		}
   	 else
		{strcpy(newuser.username,"Administrator");//給newuser.username賦一個初值
	     strcpy(newpass.password,"newpassword");//給newpass.password賦一個初值
		 newuser.link=newuser.nextuser=0l;
		 newpass.link1=newpass.nextpass=0l;
		 fwrite(&newuser,loglen,1,fp);
		 fwrite(&newpass,paslen,1,fp);
		}
	 }
	

/////////////////////login///////////////////////////////////
begin:rewind(fp);
printf("\n LOGIN  or  QUIT(l/q):");
enter:
        choice=getch();
		putch(choice);
	  	
 switch(choice)
		{case 'l':
		 case 'L':break;
		 case 'q':
		 case 'Q':exit(0);
		 default:printf("\nplease choose again(l/q)");goto enter;
		}
printf("\nENTER UR USERNAME:");
scanf("%s",loguser);printf("\n");
password: printf("\nENTER UR PASSWORD:");
scanf("%s",pw);printf("\n");
start:
     currentuserpos=ftell(fp);//輸入的新指針給當(dāng)前用戶地址
	 currentpasspos=ftell(fp);//輸入的新指針給當(dāng)前密碼地址
     fread(&user,loglen,1,fp);
	 fread(&pass,paslen,1,fp);
    if(!strcmp(user.username,loguser))//輸入用戶名和當(dāng)前用戶名比較
	   {if(!strcmp(pass.password,pw))//輸入密碼和當(dāng)前密碼比較
		{printf("\nWelcome back,%s.U have been registered!^_^\n",loguser);//相同,輸出歡迎老用戶
		 goto menu;
	}else 
		goto password;
	}
 else
		{if(user.nextuser==0l) goto anewuser;//如果當(dāng)前vdisk中沒有用戶,跳轉(zhuǎn)newuser
		 else
			{fseek(fp,user.nextuser,0);
		     fseek(fp,pass.nextpass,0);
			 goto start;
			}
		}
anewuser:
 goend;
 newuserpos=ftell(fp);//輸入的新指針給新用戶地址
 newpasspos=ftell(fp);//輸入的新指針給新密碼地址
 strcpy(newuser.username,loguser);//輸入的新用戶名給newuser.username
 strcpy(newpass.password,pw);//輸入的新密碼給newpass.password
 newuser.link=newuser.nextuser=0l;
 newpass.link1=newpass.nextpass=0l;
 fwrite(&newuser,loglen,1,fp);//寫入
 fwrite(&newpass,paslen,1,fp);
 fseek(fp,currentuserpos,0);//移動指針到當(dāng)前用戶地址
 fseek(fp,currentpasspos,0);//移動指針到當(dāng)前密碼地址
 fread(&user,loglen,1,fp);//打開
 fread(&pass,paslen,1,fp);
 user.nextuser=newuserpos;//新用戶地址給user的后繼
 pass.nextpass=newpasspos;//新密碼地址給password的后繼
 fseek(fp,currentuserpos,0);//指針移動到當(dāng)前用戶地址
 fseek(fp,currentpasspos,0);//指針移動到當(dāng)前密碼地址
 fwrite(&user,loglen,1,fp);//寫入用戶名
 fwrite(&pass,paslen,1,fp);//寫入密碼
 currentuserpos=newuserpos;//新用戶地址給當(dāng)前用戶地址
 currentpasspos=newpasspos;//新密碼地址給當(dāng)前密碼地址
 user=newuser; 

 printf("\nWelcome new user,try to use this OS %s.\n",loguser);
 goto menu;
 pass=newpass;



///////////////////////////////MENU/////////////////////////////////////
menu:
   
	while (1)
		{

		printf("-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*\n"
			  "         THE DEMO DISPLAY FOR THE FILE SYSTEM         \n"
			  "                                                      \n"
			  "            1 : create a new file                     \n"
			  "            2 : delete a file                         \n"
			  "            3 : write                                 \n"
			  "            4 : read                                  \n"
			  "            5 : directory                             \n"
		      "            6 : copy                                  \n"
			  "            7 : logout for another user                 \n"
			  "            8 : exit the OS                  \n"
			  "\n");
		do
		{
			printf("\n		PLEASE ENTER YOUR CHOICE :");
			choice1=getch();
			putch(choice1);
		}while((choice1<'1')||(choice1>'8'));
		printf("\n\n");
		switch (choice1)
		{
			case '1' :goto create;
						break;
			case '2' :goto del;
						break;
			case '3' :goto write;
						break;
            case '4' :goto read;
						break;
			case '5' :goto dir;
						break;
			case '6' :goto copy;
						break;
			case '7' :goto logout;
						break;
			case '8'  :goto exit;
						break;
			default: goto error;
				      break;
		}


 
/////////////////////exit/////////////////////////
exit:
	exit(0);//退出



//////////////////////logout/////////////////////////
logout:
  
 printf("\nlogout or not(Y/N):");
 choice2=getch();
 //	putch(choice2);
 switch(choice2)
		{case 'Y':goto begin;
		 case 'y':goto begin;
		 case 'N':goto menu;
		 case 'n':goto menu;
		 default: goto logout;
		
		}


/////////////////////create//////////////////////////
create:
 printf("\nEnter a new file name:");//創(chuàng)建文件
 scanf("%s",enterfile);
 printf("\nenter a pcode(0-read only,1-write only,2-both w/r):");//輸入保護(hù)碼
 entercode:
 scanf("%d",&Pcode);
 if(Pcode!=0&&Pcode!=1&&Pcode!=2)
			{printf("\nout of range,re-enter:");
			 goto entercode;
			}
          if(user.link!=0l)//用戶還沒有文件
			{again:
		       currentfilepos=user.link;
			 loop:
			   fseek(fp,currentfilepos,0);
		       fread(&currentfile,fillen,1,fp);
			   if(!strcmp(currentfile.filename,enterfile))//輸入的文件名和當(dāng)前文件文件名比較
				{printf("\nThere is a file with the same file name!Please re-enter the file name:");
				 scanf("%s",enterfile);
				 goto again;//文件名相同,跳轉(zhuǎn)again
				}
			 if(currentfile.nextfile==0l) goto out;
			 currentfilepos=currentfile.nextfile;//后繼文件地址給當(dāng)前文件地址,跳轉(zhuǎn)loop,重新比較
			 goto loop;
			 out:goend;
			 currentfile.nextfile=ftell(fp);
			 fseek(fp,currentfilepos,0);
			 fwrite(&currentfile,fillen,1,fp);
			 goto createnew;
				}
 else
				{goend;
				 currentfilepos=ftell(fp);
				 user.link=currentfilepos;
				 fseek(fp,currentuserpos,0);
				 fwrite(&user,loglen,1,fp);
				 createnew:
				   goend;
				 currentfilepos=ftell(fp);
				 strcpy(currentfile.filename,enterfile);//輸入文件名賦給當(dāng)前文件的文件名
				 currentfile.pcode=Pcode;//保護(hù)碼賦給當(dāng)前文件的保護(hù)碼
				 currentfile.length=0;//默認(rèn)當(dāng)前文件長度為0
				 currentfile.addr=currentfile.nextfile=0l;
				 fwrite(&currentfile,fillen,1,fp);
				 if(Pcode==0)
					{printf("\nThis file is read-only! ");
					
					 printf("\?");
					 getch();	
					 fgets(texts,1000,stdin);
				 anewtext://創(chuàng)建新文件
					   goend;
					 currentfile.addr=ftell(fp);
				     fseek(fp,currentfilepos,0);
					 fwrite(&currentfile,fillen,1,fp);
			     	 printf("%s has been created!\n",enterfile);
				 goto writing;	
					}
				else goto menu;
				}
 /////////////////////////directory////////////////////

dir:
	
	printf("\nFile name\tPcode\tblocks\n");	//顯示當(dāng)前用戶所擁有的文件
  
     currentfilepos=user.link;
    while(currentfilepos!=0l)
	
	{fseek(fp,currentfilepos,0);
		 fread(&currentfile,fillen,1,fp);
		 printf("%s\t\t  %d\t  %d\n",currentfile.filename,currentfile.pcode,currentfile.length);
		currentfilepos=currentfile.nextfile;
			}
 goto menu;
}


//////////////////////write///////////////////////
write:
     printf("\nPlease enter the file name:");	//寫入
 scanf("%s",enterfile);
 getchar();	
if(user.link==0l) goto nofile;
 currentfilepos=user.link;
 fseek(fp,currentfilepos,0);
 fread(&currentfile,fillen,1,fp);
 while(strcmp(currentfile.filename,enterfile)&&currentfile.nextfile!=0l)//輸入用戶名跟當(dāng)前用戶名比較
			{currentfilepos=currentfile.nextfile;           //當(dāng)前用戶后繼地址給當(dāng)前文件地址            
			 fseek(fp,currentfilepos,0);
			 fread(&currentfile,fillen,1,fp);
			}
 if(strcmp(currentfile.filename,enterfile)) goto nofile;
 if(currentfile.pcode==0)//如果只讀,則不允許
			{printf("\nThis file is write-only.You cannot read it!\n");
			 goto menu;
			}
 printf("\nstart:");//開始寫入文字
 fgets(texts,1000,stdin);
 printf("\nSave or Not(Y/N):");
 //////////////////////////save///////////////////////
save:choice3=getchar();	//保存
 switch(choice3)
		{case 'Y':
		 case 'y':break;
		 case 'N':
		 case 'n':goto menu;
		 default:printf("\nwrong choice,again(Y/N):");goto save;
		 }
  if((textpos=currentfile.addr)==0l) goto anewtext;//當(dāng)前文件塊的地址
  fseek(fp,textpos,0);
  fread(&content,textlen,1,fp);
  while(content.nexttext!=0l)
			{textpos=content.nexttext;
			 fseek(fp,textpos,0);
			 fread(&content,textlen,1,fp);
			}
 goend;
 content.nexttext=ftell(fp);
 fseek(fp,textpos,0);
 fwrite(&content,textlen,1,fp);
writing:
 goend;
 textpos=ftell(fp);
 numbers=strlen(texts)/19;	//需要的文件塊的數(shù)量/
 basement=0;
 while(basement<numbers)
			{strcopy(newtext.text,texts+basement*19,19);
			 newtext.nexttext=0l;
			 fwrite(&newtext,textlen,1,fp);
			 goend;
			 newtext.nexttext=ftell(fp);
			 fseek(fp,textpos,0);
			 fwrite(&newtext,textlen,1,fp);
			 textpos=newtext.nexttext;
			 basement++;
			 fseek(fp,textpos,0);
			}
 strcopy(newtext.text,texts+basement*19,19);	//最后一個文件塊的內(nèi)容/
 newtext.nexttext=0l;
 fwrite(&newtext,textlen,1,fp);
 currentfile.length+=numbers+1;////////change///////////
 fseek(fp,currentfilepos,0);
 fwrite(&currentfile,fillen,1,fp);
 goto menu;


 ////////////////////////copy/////////////////////////////
copy:
	 printf("\nPlease enter the source file name:");	
 scanf("%s",enterfile);
 if(user.link==0l) goto nofile;
 sourcefilepos=user.link;
 fseek(fp,sourcefilepos,0);
 fread(&sourcefile,fillen,1,fp);
 while(strcmp(sourcefile.filename,enterfile)&&sourcefile.nextfile!=0l)	//尋找原文件
			{sourcefilepos=sourcefile.nextfile;
			 fseek(fp,sourcefilepos,0);
			 fread(&sourcefile,fillen,1,fp);
			}
 if(strcmp(sourcefile.filename,enterfile)) goto nofile;
 printf("\nPlease enter the target file name:");
tarfile:scanf("%s",enterfile);
 currentfilepos=user.link;
 fseek(fp,currentfilepos,0);
 fread(&currentfile,fillen,1,fp);
 while(strcmp(currentfile.filename,enterfile)&&currentfile.nextfile!=0l)	//尋找目標(biāo)文件
			{currentfilepos=currentfile.nextfile;
			 fseek(fp,currentfilepos,0);
			 fread(&currentfile,fillen,1,fp);
			}
 if(!strcmp(currentfile.filename,enterfile))
			{printf("\nThere is a file with the same name.Please re-enter the target file name:");
			 goto tarfile;
			}
 goend;
 targetfilepos=currentfile.nextfile=ftell(fp);
 fseek(fp,currentfilepos,0);
 fwrite(&currentfile,fillen,1,fp);
 goend;
 targetfile=sourcefile;	//把sourcefile的file信息給targefile
 targetfile.nextfile=0l;
 strcpy(targetfile.filename,enterfile);
 fwrite(&targetfile,fillen,1,fp);
 if(targetfile.addr==0l) goto menu;
 goend;
 targetfile.addr=ftell(fp);
 fseek(fp,targetfilepos,0);
 fwrite(&targetfile,fillen,1,fp);
 textpos=sourcefile.addr;	//sourcefile文件塊的地址
 fseek(fp,textpos,0);
 fread(&sourcetext,textlen,1,fp);
 while(sourcetext.nexttext!=0l)
			{strcpy(targettext.text,sourcetext.text);
			 goend;
			 fwrite(&targettext,textlen,1,fp);
			 goend;
			 targettext.nexttext=ftell(fp);
			 fseek(fp,-(long)textlen,2);
			 fwrite(&targettext,textlen,1,fp);
			 textpos=sourcetext.nexttext;
			 fseek(fp,textpos,0);
			 fread(&sourcetext,textlen,1,fp);
			}
 strcpy(targettext.text,sourcetext.text);	//拷貝最后一個文件塊
 targettext.nexttext=0l;
 goend;
 fwrite(&targettext,textlen,1,fp);
 
 goto menu;
nofile:printf("\nThe file is not found!");	//error
 goto menu;


 /////////////////////read///////////////////////////
read:
 printf("\nPlease enter the file name:");	
 scanf("%s",enterfile);
 if(user.link==0l) goto nofile;
 currentfilepos=user.link;
 fseek(fp,currentfilepos,0);
 fread(&currentfile,fillen,1,fp);
 while(strcmp(currentfile.filename,enterfile)&&currentfile.nextfile!=0l)	
			{currentfilepos=currentfile.nextfile;
			 fseek(fp,currentfilepos,0);
			 fread(&currentfile,fillen,1,fp);
			}
 if(strcmp(currentfile.filename,enterfile)) goto nofile;
 if(currentfile.pcode==1)	//文件只讀則不允許
			{printf("\nThis file is read-only.You cannot modify it!\n");
			 goto menu;
			}
 else
			{textpos=currentfile.addr;
			 printf("\n");
			 while(textpos!=0l)
				{fseek(fp,textpos,0);
				 fread(&content,textlen,1,fp);
				 printf("%s",content.text);
				 textpos=content.nexttext;
				}
			 goto menu;
			};


 /////////////////////////delete///////////////////////////
del:printf("\nPlease enter the file name:");	
 scanf("%s",enterfile);
 if(user.link==0l) goto nofile;		
 currentfilepos=user.link;
 fseek(fp,currentfilepos,0);
 fread(&currentfile,fillen,1,fp);
 while(strcmp(currentfile.filename,enterfile)&&currentfile.nextfile!=0l)	
			{prefilepos=currentfilepos;
			 currentfilepos=currentfile.nextfile;
			 fseek(fp,currentfilepos,0);
			 fread(&currentfile,fillen,1,fp);
			}
 if(strcmp(currentfile.filename,enterfile)) goto nofile;
       if(currentfilepos==user.link)
			{user.link=currentfile.nextfile;
			 fseek(fp,currentuserpos,0);
			 fwrite(&user,fillen,1,fp);
			 goto menu;
			}
 else
			{fseek(fp,prefilepos,0);
			 fread(&prefile,fillen,1,fp);
			 prefile.nextfile=currentfile.nextfile;
			 fseek(fp,prefilepos,0);
			 fwrite(&prefile,fillen,1,fp);
			 goto menu;
			};

error:printf("you have chosen a wrong choice,choose again!!\n");
	 goto menu;

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产999精品久久| 精品免费日韩av| 欧美性受极品xxxx喷水| 欧美日韩精品一区二区三区四区| 色婷婷一区二区| 精品国产91乱码一区二区三区 | 免费成人在线影院| 精品一区二区三区久久久| 99麻豆久久久国产精品免费 | 一本大道久久a久久综合| 欧美精品v日韩精品v韩国精品v| 欧美成人乱码一区二区三区| 亚洲手机成人高清视频| 久久精品国产99久久6| 99国产精品国产精品毛片| 欧美不卡123| 亚洲成人精品一区二区| 91视频免费观看| 亚洲国产精品成人综合| 极品少妇一区二区三区精品视频| 99久久精品一区| 亚洲欧美日韩一区二区| 国产成人av电影在线| 日韩精品在线一区| 国内精品久久久久影院一蜜桃| 欧美无乱码久久久免费午夜一区| 亚洲精品v日韩精品| 在线观看日韩av先锋影音电影院| 中国av一区二区三区| 99久久综合色| 亚洲与欧洲av电影| 91精品久久久久久久久99蜜臂| 天天av天天翘天天综合网| 欧美丰满少妇xxxxx高潮对白| 亚洲午夜在线电影| 26uuu精品一区二区在线观看| 国模娜娜一区二区三区| 国产精品美女久久久久久久久 | 在线视频一区二区三区| 亚洲va天堂va国产va久| 日韩欧美你懂的| 国产精品18久久久久久久网站| 久久天天做天天爱综合色| 成人av在线影院| 亚洲高清免费观看| 国产亚洲精品免费| 99久久伊人网影院| 免费观看在线综合色| 中文字幕欧美激情| 在线免费观看日本欧美| 国产最新精品免费| 亚洲国产精品久久不卡毛片| 日韩免费成人网| 色噜噜狠狠色综合中国| 美女网站在线免费欧美精品| 久久精品无码一区二区三区| 在线观看亚洲一区| 国内成人自拍视频| 免费成人美女在线观看.| 亚洲综合男人的天堂| 日韩毛片精品高清免费| 中文无字幕一区二区三区| 欧美成人欧美edvon| 日韩三级中文字幕| 日韩欧美美女一区二区三区| 91麻豆精品国产91久久久使用方法| 色诱亚洲精品久久久久久| av一区二区三区在线| 91蜜桃在线免费视频| 99精品视频在线播放观看| 成人精品视频.| 91成人网在线| 欧美日韩中文字幕精品| 欧美日韩综合不卡| 欧美一区二区成人6969| 日本一区免费视频| 亚洲自拍另类综合| 日韩av网站在线观看| 成人国产一区二区三区精品| 欧美在线免费观看视频| 欧美久久婷婷综合色| 久久先锋影音av| 亚洲人午夜精品天堂一二香蕉| 免费高清在线视频一区·| 国产成人亚洲综合a∨婷婷图片 | 日本一区二区三区四区| 亚洲精品综合在线| 国产成人综合视频| 日韩一级大片在线观看| 亚洲免费观看高清完整版在线 | 综合色中文字幕| 国产一区二区久久| 日韩亚洲欧美高清| 日本不卡123| 欧美色综合网站| 亚洲靠逼com| 色婷婷综合久色| 国产精品麻豆99久久久久久| 国产自产2019最新不卡| 欧美大片在线观看一区二区| 美女国产一区二区| 欧美视频一区二| 香蕉加勒比综合久久| 欧美美女一区二区三区| 亚洲成人免费视频| 欧美电影影音先锋| 久久国产三级精品| 国产欧美一区二区精品性| 国产大片一区二区| 成人免费在线观看入口| 在线视频国内一区二区| 亚洲福利电影网| 久久久久久久久久美女| 粉嫩一区二区三区在线看| 亚洲欧美影音先锋| 欧美美女网站色| 国产精品一区在线观看乱码| 亚洲国产精品99久久久久久久久| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲男人天堂av| 久久精品一区四区| 欧美特级限制片免费在线观看| 日韩电影一区二区三区| 国产精品久久久久aaaa樱花 | 日本女优在线视频一区二区| 日韩一区二区免费在线观看| 高清不卡一区二区在线| 日韩高清不卡一区| 亚洲综合一二三区| 日韩一区在线看| 26uuuu精品一区二区| 欧美日韩国产123区| 91浏览器打开| 不卡欧美aaaaa| 久久精品久久综合| 免费成人小视频| 天天综合日日夜夜精品| 亚洲综合色视频| 亚洲一区二区在线观看视频| 国产精品卡一卡二| 日本一区二区三区四区| 国产欧美日韩另类视频免费观看 | 午夜电影久久久| 日本中文在线一区| 激情久久五月天| 91首页免费视频| 91麻豆高清视频| 色成人在线视频| 欧美日韩aaaaaa| 日韩欧美一级二级三级久久久| 91精品欧美一区二区三区综合在| 欧美日韩www| 国产精品三级av| 亚洲v精品v日韩v欧美v专区| 亚洲成a人片在线不卡一二三区 | 精品国产伦一区二区三区观看体验| 91精品国产高清一区二区三区蜜臀 | 国产精品美女久久久久久| 一区二区三区在线看| 调教+趴+乳夹+国产+精品| 国产精品一区二区无线| 日本精品免费观看高清观看| 欧美不卡一区二区三区四区| 中文字幕日本乱码精品影院| 亚洲第一会所有码转帖| 99在线精品视频| 久久综合给合久久狠狠狠97色69| 亚洲色图欧美激情| proumb性欧美在线观看| av一本久道久久综合久久鬼色| 欧美区视频在线观看| 欧美国产日韩亚洲一区| 理论片日本一区| 在线观看亚洲精品视频| 久久久久9999亚洲精品| 奇米在线7777在线精品| 欧美二区三区91| 亚洲一区视频在线| 欧美日韩一区二区三区在线| 亚洲欧美欧美一区二区三区| fc2成人免费人成在线观看播放 | 日韩精品一级二级| 这里只有精品99re| 麻豆精品一区二区| 久久综合给合久久狠狠狠97色69| 亚洲不卡av一区二区三区| 欧美午夜一区二区三区| 日韩中文字幕一区二区三区| 色综合欧美在线| 亚洲主播在线播放| 欧美一卡二卡三卡四卡| 国产精品白丝jk黑袜喷水| 亚洲精品在线一区二区| 粉嫩久久99精品久久久久久夜| 亚洲欧洲日韩女同| 欧美一区二视频| 99久久精品国产观看| 美女视频免费一区| 亚洲激情在线播放| 欧美不卡一区二区|