易截截图软件、单文件、免安装、纯绿色、仅160KB

linux C 读取目录文件并统计文件数

#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <errno.h>
#include <string.h>
#define MAX 1024
int get_file_count(char *root)
{
 DIR *dir;
 struct dirent * ptr;
 int total = 0;
 char path[MAX];
 dir = opendir(root); /* 打开目录*/
 if(dir == NULL)
 {
  perror("fail to open dir");
  exit(1);
 }
 errno = 0;
 while((ptr = readdir(dir)) != NULL)
 {
  //顺序读取每一个目录项;
  //跳过“..”和“.”两个目录
  if(strcmp(ptr->d_name,".") == 0 || strcmp(ptr->d_name,"..") == 0)
  {
   continue;
  }
  //printf("%s%s\n",root,ptr->d_name);
  //如果是目录,则递归调用 get_file_count函数
  
  if(ptr->d_type == DT_DIR)
  {
   sprintf(path,"%s%s/",root,ptr->d_name);
   //printf("%s\n",path);
   total += get_file_count(path);
  }
  
  if(ptr->d_type == DT_REG)
  {
   total++;
   printf("%s%s\n",root,ptr->d_name);
  }
 }
 if(errno != 0)
 {
  printf("fail to read dir");  //失败则输出提示信息
  exit(1);
 }
 closedir(dir);
 return total;
}
int main(int argc, char * argv[])
{
 int total;
 if(argc != 2)
 {
  printf("wrong usage\n");
  exit(1);
 }
 total = get_file_count(argv[1]);
 printf("%s ha %d files\n",argv[1],total);
 return 0;
}


相关文档:

实战Linux Bluetooth编程(三) HCI层编程

1. HCI层协议概述:
HCI提供一套统一的方法来访问Bluetooth底层。如图所示:
从图上可以看出,Host Controller Interface(HCI)  就是用来沟通Host和Module。Host通常就是PC, Module则是以各种物理连接形式(USB,serial,pc-card等)连接到PC上的bluetooth Dongle。
在Host这一端:application,SDP,L2cap等协议 ......

一段基于linux V4L视频采集摄像程序的源码

/*****************************************************************************************************
linux_m4v.c
gcc -o linux_m4v linux_m4v.c -lc -lm -lxvidcore
*******************************************************************************************************/
#include <string.h>
# ......

Linux 内核启动分析(转)

Linux 内核启动分析(转)
Linux 内核启动分析
1.       内核启动地址
1.1.   名词解释
ZTEXTADDR
解压代码运行的开始地址。没有物理地址和虚拟地址之分,因为此时MMU处于关闭状态。这个地址不一定时RAM的地址,可以是支持读写寻址的flash等存储中介。
Start address of ......

firefox 简单 插件编译 【linux】

#ifdef XP_UNIX
/*
* Set up the plugin function table that Netscape will use to
* call us. Netscape needs to know about our version and size
* and have a UniversalProcPointer for every function we
* implement.
*/
pluginFuncs->version = (NP_VERSION_MAJOR << 8) + NP_VERSION_MINOR;
......

linux下超星阅读器的安装

1.A. extract the install file
    tar zxvf bxviewer.tar.gz
    cd bxviewer
    ./installbxv   
    logout
 1.B. if system can't find bxv after ur installation, you can always set
    it up by hand
......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号