资源简介
unistd.h 头文件,可直接使用,应急下载

代码片段和文件信息
/*
* An example demonstrating recursive directory traversal.
*
* Compile this file with Visual Studio 2008 project vs2008.sln and run
* the produced command in console with a directory name argument. For
* example command
*
* find “C:\Program Files“
*
* might produce a listing with thousands of entries such as
*
* c:\Program Files/7-Zip/7-zip.chm
* c:\Program Files/7-Zip/7-zip.dll
* c:\Program Files/7-Zip/7z.dll
* c:\Program Files/Adobe/Reader 10.0/Reader/logsession.dll
* c:\Program Files/Adobe/Reader 10.0/Reader/LogTransport2.exe
* c:\Program Files/Windows NT/Accessories/wordpad.exe
* c:\Program Files/Windows NT/Accessories/write.wpc
*
* The find command provided by this file is only an example. That is
* the command does not provide options to restrict the output to certain
* files as the Linux version does.
*/
#include
#include
#include
#include “dirent.h“
static int find_directory (const char *dirname);
int
main(
int argc char *argv[])
{
int i;
int ok;
/* For each directory in command line */
i = 1;
while (i < argc) {
ok = find_directory (argv[i]);
if (!ok) {
exit (EXIT_FAILURE);
}
i++;
}
/* List current working directory if no arguments on command line */
if (argc == 1) {
find_directory (“.“);
}
return EXIT_SUCCESS;
}
/* Find files and subdirectories recursively */
static int
find_directory(
const char *dirname)
{
DIR *dir;
char buffer[PATH_MAX + 2];
char *p = buffer;
const char *src;
char *end = &buffer[PATH_MAX];
int ok;
/* Copy directory name to buffer */
src = dirname;
while (p < end && *src != ‘\0‘) {
*p++ = *src++;
}
*p = ‘\0‘;
/* Open directory stream */
dir = opendir (dirname);
if (dir != NULL) {
struct dirent *ent;
/* Print all files and directories within the directory */
while ((ent = readdir (dir)) != NULL) {
char *q = p;
char c;
/* Get final character of directory name */
if (buffer < q) {
c = q[-1];
} else {
c = ‘:‘;
}
/* Append directory separator if not already there */
if (c != ‘:‘ && c != ‘/‘ && c != ‘\\‘) {
*q++ = ‘/‘;
}
/* Append file name */
src = ent->d_name;
while (q < end && *src != ‘\0‘) {
*q++ = *src++;
}
*q = ‘\0‘;
/* Decide what to do with the directory entry */
switch (ent->d_type) {
case DT_LNK:
case DT_REG:
/* Output file name with directory */
printf (“%s\n“ buffer);
break;
case DT_DIR:
/* Scan sub-directory recursively */
if (strcmp (ent->d_name
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2014-04-07 14:18 tests\
目录 0 2014-04-07 14:18 tests\1\
文件 0 2014-04-07 14:18 tests\1\file
目录 0 2014-04-07 14:18 tests\1\dir\
文件 172 2014-04-07 14:18 tests\1\dir\readme.txt
目录 0 2014-04-07 14:18 tests\2\
文件 0 2014-04-07 14:18 tests\2\Testfile-1.2.3.dat
文件 56 2014-04-07 14:18 tests\2\file.txt
文件 7605 2014-04-07 14:18 tests\t-dirent.c
目录 0 2014-04-07 14:18 examples\
文件 4893 2014-04-07 14:18 examples\updatedb.c
文件 5625 2014-04-07 14:18 examples\locate.c
文件 2082 2014-04-07 14:18 examples\ls.c
文件 3469 2014-04-07 14:18 examples\find.c
文件 3502 2014-04-07 14:18 ChangeLog
目录 0 2014-04-07 14:18 vs2008\
目录 0 2014-04-07 14:18 vs2008\t-dirent\
文件 3543 2014-04-07 14:18 vs2008\t-dirent\t-dirent.vcproj
目录 0 2014-04-07 14:18 vs2008\locate\
文件 3541 2014-04-07 14:18 vs2008\locate\locate.vcproj
目录 0 2014-04-07 14:18 vs2008\updatedb\
文件 3547 2014-04-07 14:18 vs2008\updatedb\updatedb.vcproj
文件 2702 2014-04-07 14:18 vs2008\vs2008.sln
目录 0 2014-04-07 14:18 vs2008\ls\
文件 3529 2014-04-07 14:18 vs2008\ls\ls.vcproj
目录 0 2014-04-07 14:18 vs2008\find\
文件 3535 2014-04-07 14:18 vs2008\find\find.vcproj
目录 0 2014-04-07 14:18 include\
文件 22917 2014-04-07 14:18 include\dirent.h
相关资源
- hidusage.h hidpi.h 等USB开发用头文件
- 开源图像库leptonica头文件和库文件
- 编译好的json_lib.lib 包含64位,32位,头
- windows 32位64位 x264库,包含libdll和头文
- reg52.h详解
- hidapi进行USB通讯必备的库文件和头文
- OpenCV3.3+contrib-master,VS2013编译后的l
- vs2010 win7下编译的openssl-1.0.2n静态库
- TMS320F28335系列头文件、库文件、cmd等
- GDI+头文件以及库文件
- miracl库及使用手册和头文件miracl.lb及
- openssl bcb的静态库lib+头文件+chm
- Delphi的OpenCV头文件和
- STC12C5A32S2的PDF与头文件
- HOOPS头文件库
- 编译FFmpeg3.2.2生成的库文件及头文件
- DSP281x官方头文件及例程
- 1313个C标准库头文件
- AVR所有头文件
- STC单片机在UV4中的头文件数据库STC.
- openSSL头文件和静态库文件以及动态库
- OpenSSL头文件和lib我的系统是windows7/
- OpenGL所有库OpenGL,freeglut、glu、glut、
- C51V900修正版3.1已包含STC头文件.rar
- vs2015编译的openssl-1.0.2l包含静态库(
- UNIX环境高级编程第三版中英文两版
- USB HID开发相关的库和头文件32位和6
- google v8引擎编译后的dll及头文件
- tesseract在vs2008的环境下,需要的动态
- OpenCV 4.0.0 VS2017vc15编译后的lib、dll、
评论
共有 条评论