资源简介
基于Linux的模拟文件系统管理的设计与实现
在Linux环境中实现文件系统的功能

代码片段和文件信息
#include
#include
#include
typedef struct file{
char name[10];
struct file *next;
}File;
typedef struct content{
char name[10];
File *file;
int f_num;
struct content *next;
}Content;
typedef struct user{
char name[10];
char psw[10];
Content *con;
struct user *next;
}User;
char cur_user[20];
User *user;
int user_num=0;
void write(char name[]){
FILE *p;
char ch;
p=fopen(name“w“);
ch=getchar();
while(1){
fputc(chp);
ch=getchar();
if(ch==‘#‘) break;
}
fclose(p);
}
void read(char name[]){
FILE *p;
int i=0;
p=fopen(name“r“);
while(!feof(p)){
i++;
printf(“%c“fgetc(p));
}
if(i==0) printf(“The File Is Empty!\n“);
fclose(p);
}
void addNewUser(){
int exist;
char name[10];
char psw[10];
User *head*p;
Content *con;
if(user_num==10){
printf(“Has 10 users!\n“);
return;
}
do{
printf(“Input New User Name(0~10):\n“);
scanf(“%s“name);
exist=0;
head=user->next;
while(head!=NULL){
if(strcmp(head->namename)==0){
exist=1;
break;
}
head=head->next;
}
if(exist==1) printf(“The User Have Existed!\nPlease Input Again:“);
}while(exist==1);
printf(“Input New User Password(0~10):\n“);
scanf(“%s“psw);
p=(User *)malloc(sizeof(User));
strcpy(p->namename);
strcpy(p->pswpsw);
con=(Content *)malloc(sizeof(Content));
con->next=NULL;
p->con=con;
p->next=NULL;
head=user;
while(head->next!=NULL) head=head->next;
head->next=p;
user_num++;
printf(“Add New User Success!\n“);
}
int display_files(Content *con){
int i=0;
File *file;
file=con->file;
file=file->next;
while(file!=NULL){
i++;
printf(“File %d: %s\n“ifile->name);
file=file->next;
}
printf(“ A Total Of %d Files\n“i);
return i;
}
int is_exist_file(File *fchar name[]){
int exist=0;
File *file=f->next;
while(file!=NULL){
if(strcmp(file->namename)==0){
exist=1;
break;
}
file=file->next;
}
return exist;
}
void add_file(Content *con){
int exist;
char f_name[10];
char tail[]=“.txt“;
FILE *q;
File *file=con->file;
File *new_f;
if(con->f_num==10){
printf(“Has 10 file!\n“);
return;
}
do{
exist=0;
printf(“Input New File Name:“);
scanf(“%s“f_name);
strcat(f_nametail);
if(is_exist_file(con->filef_name)) exist=1;
if(exist==1) printf(“The File Have Existed!\n“);
}while(exist==1);
q=fopen(f_name“w“);
fclose(q);
while(file->next!=NULL) file=file->next;
new_f=(File *)malloc(sizeof(File));
strcpy(new_f->namef_name);
new_f->next=NULL;
file->next=new_f;
con->f_num++;
printf(“Add File %s Success!\n“f_name);
}
void read_file(Content *con){
char name[10];
char tail[]=“.txt“;
int find=0;
File *file=con->file->next;
printf(“Input The FileName You Want To Display:“);
scanf(“%s“name);
strcat(nametail);
while(file!=
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 9740 2009-07-08 23:45 file3.c
----------- --------- ---------- ----- ----
9740 1
- 上一篇:Power Designer 15
- 下一篇:在线作业系统,在线提交作业
相关资源
- uboot到linux logo显示不间断 补丁
- UNIX/LINUX编程实践教程的源码
- Linux任务管理器
- linux应用层的华容道游戏源代码
- STM32基于rt_thread操作系统的SDHC卡文件
- 51模拟SPI读写SD卡(包括Fat和Fat32文件
- ubuntu9.10 可加载内核模块和字符设备驱
- MP3文件ID3v2ID3v2APEv2标签读取
- 操作系统实验——虚存管理实验
- linux下的发包工具sendip
- 尚观培训linux许巍关于c 的笔记和讲义
- 尚观培训linux董亮老师关于数据结构的
- linux 线程池源码 c 版
- linux C 电梯程序练习
- 广东工业大学操作系统实验四文件系
- linux下用多进程同步方法解决生产者
- 二级文件系统(操作系统)
- Linux 操作系统实验(全)
- Linux From Scratch 中文手册
- linux 网络实验 ftp程序
- Linux命令大全离线版&在线版
- 操作系统共享内存实验
- dos 下运行Linux 命令--gnu_utils
- linux 0.12内核源代码
- linux简易shell C实现
- linux实验报告及心得体会
- 基于GTK的Linux环境下的简易任务管理器
- linux扫雷游戏代码
- CAN Linux驱动代码
- Linux系统教材
评论
共有 条评论