从github down了一个工程,MS编译报找不到direct.h,网上搜索,借鉴https://blog.csdn.net/yapingxin/article/details/51444133和http://www.two-sdg.demon.co.uk/curbralan/code/dirent/dirent.html,下载对应代码,添加到工程中,将问题解决。下面贴出.c和.h。

direct.cpp

/*Implementation of POSIX directory browsing functions and types for Win32.Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)History: Created March 1997. Updated June 2003 and July 2012.Rights:  See end of file.*/#include <dirent.h>
#include <errno.h>
#include <io.h> /* _findfirst and _findnext set errno iff they return -1 */
#include <stdlib.h>
#include <string.h>#ifdef __cplusplus
extern "C"
{
#endiftypedef ptrdiff_t handle_type; /* C99's intptr_t not sufficiently portable */struct DIR
{handle_type         handle; /* -1 for failed rewind */struct _finddata_t  info;struct dirent       result; /* d_name null iff first time */char                *name;  /* null-terminated char string */
};DIR *opendir(const char *name)
{DIR *dir = 0;if(name && name[0]){size_t base_length = strlen(name);const char *all = /* search pattern must end with suitable wildcard */strchr("/\\", name[base_length - 1]) ? "*" : "/*";if((dir = (DIR *) malloc(sizeof *dir)) != 0 &&(dir->name = (char *) malloc(base_length + strlen(all) + 1)) != 0){strcat(strcpy(dir->name, name), all);if((dir->handle =(handle_type) _findfirst(dir->name, &dir->info)) != -1){dir->result.d_name = 0;}else /* rollback */{free(dir->name);free(dir);dir = 0;}}else /* rollback */{free(dir);dir   = 0;errno = ENOMEM;}}else{errno = EINVAL;}return dir;
}int closedir(DIR *dir)
{int result = -1;if(dir){if(dir->handle != -1){result = _findclose(dir->handle);}free(dir->name);free(dir);}if(result == -1) /* map all errors to EBADF */{errno = EBADF;}return result;
}struct dirent *readdir(DIR *dir)
{struct dirent *result = 0;if(dir && dir->handle != -1){if(!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1){result         = &dir->result;result->d_name = dir->info.name;}}else{errno = EBADF;}return result;
}void rewinddir(DIR *dir)
{if(dir && dir->handle != -1){_findclose(dir->handle);dir->handle = (handle_type) _findfirst(dir->name, &dir->info);dir->result.d_name = 0;}else{errno = EBADF;}
}#ifdef __cplusplus
}
#endif/*Copyright Kevlin Henney, 1997, 2003, 2012. All rights reserved.Permission to use, copy, modify, and distribute this software and itsdocumentation for any purpose is hereby granted without fee, providedthat this copyright and permissions notice appear in all copies andderivatives.This software is supplied "as is" without express or implied warranty.But that said, if there are any problems please get in touch.*/

direct.h

#ifndef DIRENT_INCLUDED
#define DIRENT_INCLUDED/*Declaration of POSIX directory browsing functions and types for Win32.Author:  Kevlin Henney (kevlin@acm.org, kevlin@curbralan.com)History: Created March 1997. Updated June 2003.Rights:  See end of file.*/#ifdef __cplusplus
extern "C"
{
#endiftypedef struct DIR DIR;struct dirent
{char *d_name;
};DIR           *opendir(const char *);
int           closedir(DIR *);
struct dirent *readdir(DIR *);
void          rewinddir(DIR *);/*Copyright Kevlin Henney, 1997, 2003. All rights reserved.Permission to use, copy, modify, and distribute this software and itsdocumentation for any purpose is hereby granted without fee, providedthat this copyright and permissions notice appear in all copies andderivatives.This software is supplied "as is" without express or implied warranty.But that said, if there are any problems please get in touch.*/#ifdef __cplusplus
}
#endif#endif

dirent.h和dirent.c下载相关推荐

  1. VS2103没有“dirent.h”文件

    文章目录 1 问题描述 2 原因 3 解决办法 4 具体步骤 5 参考链接 1 问题描述 在VS2013中使用dirent.h文件时,找不到该文件. 错误描述: 无法打开包括文件"diren ...

  2. dirent.h简介

    dirent.h简介 <dirent.h>是一个应用程序接口, 主要用于文件系统的目录读取操作,主要提供了几个目录数据读取函数, 参见opengroup.org. <dirent.h ...

  3. Linux下的dirent.h在windows下的替换

    一.问题背景 dirent.h是一个用于操作文件系统目录的接口文件,里面有目录相关的读取函数.但dirent.h是linux系统下的文件,在windows下不能直接应用,因为windows下的MSVC ...

  4. windwos下C语言缺少dirent.h依赖

    本来想写一个目录遍历的功能,引入dirent.h的时候发现缺少这个依赖. google了下,直接下方地址下载dirent.h https://github.com/tronkko/dirent/blo ...

  5. c语言#include windows.h,c语言之ls目录的简单实现和window版本dirent.h

    #include #if _WIN32 #include #include #include "dirent.h" #else #include #include #endif / ...

  6. UNIX 环境高级编程(四)—— dirent.h

    dirent.h 是 POSIX.1 标准定义的 unix 类目录操作的头文件,包含了许多 UNIX 系统服务的函数原型,例如 opendir 函数.readdir 函数. 1. 基本函数接口 1.1 ...

  7. 打不开<dirent.h>和<<unistd.h>>

    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include 在git ...

  8. MapX.h和MapX.cpp下载

    请点击这里下载,这个原代码实现了原版MapX未实现的功能,下载地址:

  9. 结构体DIR和dirent

    1.存储目录中的文件信息(文件名.扩展名等等)#include <dirent.h> struct dirent{   long d_ino; /* inode number 索引节点号 ...

  10. C语言实现音乐播放器(Linux madplay)

    (一)需求分析 1.扫描指定路径下的音乐,并显示出来 2.实现音乐的播放.暂停.上一首和下一首的功能 3.程序退出释放内存资源 (二)思路 1.扫描出指定路径下的音乐文件(便利指定文件夹,找出音频文件 ...

最新文章

  1. robotframwork的WEB功能测试(一)—切换window窗口
  2. 无法将类型为“System.__ComObject”的 COM 对象强制转换为类类型“mshtml.HTMLInputElementClass...
  3. 赞扬精心设计:基于属性的测试如何帮助我成为更好的开发人员
  4. ps怎么对比原图快捷键_PS学习之旅:ps如何制作满天星,让你夜晚的天空图片更美...
  5. Linux C高级编程——时间编程
  6. LeetCode 744. 寻找比目标字母大的最小字母(二分查找)
  7. python 实现两个excel表格数据的对比--代码
  8. 3D MAX脚本原理
  9. 电子电路基础 (13)——数字电路基础 - 逻辑电路
  10. linux 显示数字权限,Linux数字权限解释
  11. 回顾过去。。展望未来
  12. [微信]微信小程序开发--用户昵称中带有emoji表情的处理方法
  13. Uboot 使用串口Kermit协议传输文件
  14. linux提取fasta文件的id,从大的fasta文件中提取特定的fasta序列
  15. YQP36预加水盘式成球机设计(论文+DWG图纸)
  16. python怎么编程乘法口诀表_少儿编程|python|制作九九乘法口诀表
  17. 让你的代码只做一件事情
  18. 对比python字符串函数,学习pandas的str矢量化字符串函数
  19. Debian 官方下载地址
  20. html写顶部固定悬浮菜单栏,JS实现自动固定顶部的悬浮菜单栏效果

热门文章

  1. win10-用户忘记密码如何登录
  2. 一个月转推荐:LR算法原理
  3. java 值班管理_​运维告警的值班管理
  4. WordPress收费下载插件Erphpdown最新下载[持续更新]
  5. web界面设计要素及基本设计规范
  6. I2C设备调试及波形分析
  7. 龙芯pmon启动流程概述
  8. loongson PMON使用
  9. jndi weblogic mysql_WebLogic使用总结(三)——WebLogic配置JNDI数据源
  10. 考核指标如CTR/CVR/ROI/ARPU等