📄 cmd.cpp
字号:
#include "precomp.h"
int main()
{
InitDisk(); //初始化虚拟磁盘空间
char filename[8];
char filecontent[176];//文件内容不能超过176 B,为什么?看看FAT表
char command[10];
int filesize = 0;
int err_no = 0;
while(1)
{
printf("my filesys>"); //命令提示行
scanf("%s",command);
if (!strcmp(command,"mkfile")) //创建文件命令,需要用户提供文件名
{
//printf("\ninput file name(<8 chars):");
scanf("%s",filename);
//printf("\nReady to create file. Please input file content end with ENTER\n");
scanf("%s",filecontent);
filesize = strlen(filecontent);
if((err_no = CreateFile(filename,filecontent,filesize)) == 0)
{
printf("File created ! \n");
}
else
{
printf("Create failed! err_no=%d\n",err_no);
}
}
else if (!strcmp(command,"dir")) //列目录命令
{
ListFile();
}
else if(!strcmp(command,"type")) //显示文件内容命令
{
scanf("%s",filename);
if (displayFile(filename) != 0 )
printf("can't find the file you given!\n");
}
else if(!strcmp(command,"del")) //删除文件命令
{
scanf("%s",filename);
if (deleteFile(filename) != 0 )
printf("can't find the file you given!\n");
}
else if (!strcmp(command,"quit")) //退出本系统命令
{
break;
}
else
{
printf("Unknown command!\n");
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -