设为首页 加入收藏

TOP

Linux 程序设计学习笔记----文件管理实例应用(二)
2014-11-23 22:00:03 来源: 作者: 【 】 浏览:42
Tags:Linux 程序设计 学习 笔记 ---- 文件 管理 实例 应用
eof(struct fnode));
if(NULL==temp)
{
perror("malloc");exit(EXIT_FAILURE);
}
temp->next=NULL;
memset(temp->name,'\0',NAME_SIZE);
memcpy(temp->name,argv[i],strlen(argv[i]));
linklist=insert_list(temp,linklist);
output_info(linklist);//output information of the file
}
else if(S_ISDIR(stat_info.st_mode))
{
char buf[NAME_SIZE];
getcwd(buf,128);

DIR *dirp=NULL;
dirp=opendir(argv[i]);
if(NULL==dirp)
{
perror("opendir");exit(EXIT_FAILURE);
}


struct dirent *entp=NULL;
while(entp=readdir(dirp))
{
struct fnode *temp=(struct fnode *)malloc(sizeof(struct fnode));
if(NULL==temp)
{
perror("malloc");exit(EXIT_FAILURE);
}
temp->next=NULL;
memset(temp->name,'\0',NAME_SIZE);
memcpy(temp->name,entp->d_name,strlen(entp->d_name));
linklist=insert_list(temp,linklist);
}
chdir(argv[i]);//change the current dirctory
close(dirp);
output_info(linklist);
chdir(buf);
}
free_list(linklist);
}
return 1;
}


Linux 程序设计学习笔记----文件管理实例应用


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇利用jQuery Ajax技术实现每隔5秒.. 下一篇二叉树遍历递归与非递归实现

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: