linux 平台递归读取读取所有文件夹和文件名称
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/types.h>
#include<dirent.h>
#define MAX 1024
char path[100];
char *strmin(char *des,const char *min)
{
int i=strlen(des);
int j=strlen(min);
if(i>=j)
{
strncpy(des+i-j,"\0",1);
}
return des;
}
void print(char *path,char *tmpname)
{
struct stat buf;
if(stat(path,&buf)<0)
{
printf("stat error!\n");
return;
}
struct dirent *filename;
if(S_ISDIR(buf.st_mode))
{
DIR *dp;
dp=opendir(path);
while(1)
{
filename=readdir(dp);
if(filename == NULL)
{
strmin(path,tmpname);
closedir(dp);
return ;
}
else
{
if(strcmp(filename->d_name,".")==0 ||strcmp(filename->d_name,"..")==0)
continue;
printf("%s\n",filename->d_name);
strcat(path,"/");
strcat(path,filename->d_name);
print(path,filename->d_name);
strmin(path,"/");
}
}
}
else
{
int fd;
fd=open(path,O_RDWR);
char buf[MAX];
int size;
while(1)
{
size=read(fd,buf,MAX);
if(size==0)
{
close(fd);
break;
}
}
strmin(path,tmpname);
}
}
int
相关文档:
转贴地址:http://www.linuxsir.org/main/?q=node/137
总结:
zhy2111314
来自:
LinuxSir.Org
整理:
北南南北
摘要:
本文是find 命令的详细说明,可贵的是针对参数举了很多的实例,大量的例证,让初学者更为容易理解;本文是zhyfly兄贴在论坛中;我对本文进行了再次整理,为方便大家阅读;
目录
版权声明
前 ......
//videoserver
#!/bin/bash
#
# videoserver
#
# chkconfig: 3456 11 91
# description: videoserver
# Source function library.
. /etc/rc.d/init.d/functions
prog="videoserver"
start() {
# Start daemons.
echo -n $"Starting $prog: "
/video/videoserver/recordvideosvr /video/videoserver ......
为了突出讲解的方便性,我把以前工作中珍藏的一些实验过程贡献给大家。(未经允许,请勿转载) 一.实验目的 1. 了解Linux操作系统的启动与登录方法 2. 掌握常用Red Hat Linux命令的使用方法,掌握图形用户界面下的基本操作 3. 了解Linux命令中参数选项的用法和作用 4. 熟悉操作系统的命令接口、图形 ......
呵呵一直一来在WINDOWS下有花生壳等众多的DDNS软件实现动态域名解析。但都是在WINDOWS下的。
今天找到了一个金万维公司提供的免费DDNS服务。主要是提供有LINUX下的安装客户端
安装方法:得到金万维gnhostlinux动态域名Linux/Unix下客户端软件
wget http://www.gnway.com/download/gnhostlinux1.2.6.tgz
......