【文章內(nèi)容簡介】
NY請轉(zhuǎn)到當(dāng)前用戶名目錄下當(dāng)前文件存在?(文件號0)輸入要?jiǎng)h除的文件名,并查找對應(yīng)的文件號Y該文件不存在N確定當(dāng)前用戶的用戶號該文件可以被刪除?(不是protect型的)該文件是protect的,不能打開NY該文件已經(jīng)打開?該文件已經(jīng)打開,不能刪除YN刪除文件確定文件路徑刪除的后面的文件向前移該用戶的文件總數(shù)1返回主函數(shù)把刪除后的地址號置為未用【源程序清單】Open,close,write、delete函數(shù)代碼如下:void OpenF() /*打開文件*/{ char fname[MAXNAME]。 int i,k。 if (strcmp(strupr(dirname),strupr(username))!=0) /*用戶名和當(dāng)前目錄不同*/ { printf(\nError! You can only open file in yourself dir.\n)。 } else /*用戶名和當(dāng)前目錄相同了*/ { printf(\nPlease input FileName:)。 gets(fname)。 ltrim(rtrim(fname))。 /*去除空格*/ i=ExistF(fname)。 /*文件是否存在并返回第幾個(gè)文件號*/ if (i=0) /*文件存在*/ { k=ExistD(username)。 /*根據(jù)用戶名確定用戶號*/ if(ifopen[k][i].ifopen==1) /*該文件已經(jīng)打開*/ { printf(\nError. file \39。%s\39。 had been opened, it can not be opened again.\n,fname)。 } else /*該文件還未打開*/ { if((ufd[k]ufdfile[i].fmode==0)||(ufd[k]ufdfile[i].fmode==1)||(ufd[k]ufdfile[i].fmode==2)) /*該文件的屬性是可以被打開的*/ { ifopen[k][i].ifopen=1。 /*打開,將ifopen設(shè)為1*/ ifopen[k][i].openmode=(ufd[k]ufdfile[i].fmode)。 /**/ printf(\39。%s\39。 has been opened successfully!,fname)。 } else /*保護(hù)模式的文件不能被打開*/ printf(\n\39。%s\39。 is a protected file, it can not be opened.,fname)。 } } else /*文件不存在*/ { printf(\nError.\39。%s\39。 dose not exist.\n,fname)。 } }}void CloseF() /*關(guān)閉文件*/{ char fname[MAXNAME]。 int i,k。 if (strcmp(strupr(dirname),strupr(username))!=0) /*用戶名和當(dāng)前目錄不同*/ { printf(\ can only modify filemode in yourself dir.\n)。 } else /*用戶名和當(dāng)前目錄相同了*/ { printf(\nPlease input FileName:)。 gets(fname)。 ltrim(rtrim(fname))。 /*去除空格*/ i=ExistF(fname)。 /*文件是否存在并返回第幾個(gè)文件號*/ if (i=0) /*文件存在*/ { k=ExistD(username)。 /*根據(jù)用戶名確定用戶號*/ if(ifopen[k][i].ifopen==0) /*該文件未打開*/ { printf(\nError. \39。%s\39。 has been closed. you can not close it again.\n,fname)。 } else /*該文件已打開*/ { ifopen[k][i].ifopen=0。 /*關(guān)閉,置為0*/ ifopen[k][i].openmode=4。 /*修改打開模式為初始的打開模式*/ printf(\39。%s\39。 has been closed successfully!,fname)。 } }