📄 ext2.c
字号:
/*ext2.c*/
/*主程序*/
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <signal.h>
#include "structure.h"
#include "login.h"
#include "alloc.h"
#include "format.h"
#include "dir.h"
#include "file.h"
int main(char argc,char **argv)
{
char command[10],temp[10];
char authority[1];
if(login())
{
printf("System refused!\n");
return 1;
}
initialize_memory();
while(1)
{
printf("\n%s]#",current_path);
scanf("%s",command);
if(!strcmp(command,"cd"))
{
scanf("%s",temp);
cd(temp);
}
else if(!strcmp(command,"mkdir"))
{
scanf("%s",temp);
mkdir(temp,2);
}
else if(!strcmp(command,"mkf"))
{
scanf("%s",temp);
mkdir(temp,1);
}
else if(!strcmp(command,"rmdir"))
{
scanf("%s",temp);
rmdir(temp);
}
else if(!strcmp(command,"rm"))
{
scanf("%s",temp);
del(temp);
}
else if(!strcmp(command,"attrib"))
{
scanf("%s",authority);
scanf("%s",temp);
chmod(authority,temp);
}
else if(!strcmp(command,"open"))
{
scanf("%s",temp);
open_file(temp);
}
else if(!strcmp(command,"close"))
{
scanf("%s",temp);
close_file(temp);
}
else if(!strcmp(command,"read"))
{
scanf("%s",temp);
read_file(temp);
}
else if(!strcmp(command,"write"))
{
scanf("%s",temp);
write_file(temp);
}
else if(!strcmp(command,"ls"))ls();
else if(!strcmp(command,"format"))
{
char tempch;
printf("Format will erase all the data in the Disk\n");
printf("Are you sure?y/n:\n");
scanf(" %c",&tempch);
if(tempch=='Y'||tempch=='y')
{
fclose(fp);
initialize_disk();
}
else
printf("Format Disk canceled\n");
}
else if(!strcmp(command,"help"))help();
else if(!strcmp(command,"quit"))break;
else printf("No this Command,Please check!\n");
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -