--- configure | 2 ++ libavformat/file.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
diff --git a/configure b/configure index 06a9941..09a71d8 100755 --- a/configure +++ b/configure @@ -1679,6 +1679,7 @@ HEADERS_LIST=" dev_video_bktr_ioctl_bt848_h dev_video_meteor_ioctl_meteor_h direct_h + dirent_h dlfcn_h d3d11_h dxva_h @@ -4985,6 +4986,7 @@ enabled xlib && check_func_headers "X11/Xlib.h X11/extensions/Xvlib.h" XvGetPortAttribute -lXv -lX11 -lXext check_header direct.h +check_header dirent.h check_header dlfcn.h check_header d3d11.h check_header dxva.h diff --git a/libavformat/file.c b/libavformat/file.c index e617ac8..bb9ede6 100644 --- a/libavformat/file.c +++ b/libavformat/file.c @@ -23,7 +23,9 @@ #include "libavutil/internal.h" #include "libavutil/opt.h" #include "avformat.h" +#if HAVE_DIRENT_H #include <dirent.h> +#endif #include <fcntl.h> #if HAVE_IO_H #include <io.h> @@ -52,7 +54,9 @@ typedef struct FileContext { int fd; int trunc; int blocksize; +#if HAVE_DIRENT_H DIR *dir; +#endif } FileContext; static const AVOption file_options[] = { @@ -193,6 +197,7 @@ static int file_close(URLContext *h) static int file_open_dir(URLContext *h) { +#if HAVE_DIRENT_H FileContext *c = h->priv_data; c->dir = opendir(h->filename); @@ -200,10 +205,14 @@ static int file_open_dir(URLContext *h) return AVERROR(errno); return 0; +#else + return AVERROR(ENOSYS); +#endif /* HAVE_DIRENT_H */ } static int file_read_dir(URLContext *h, AVIODirEntry **next) { +#if HAVE_DIRENT_H FileContext *c = h->priv_data; struct dirent *dir; char *fullpath = NULL; @@ -231,11 +240,28 @@ static int file_read_dir(URLContext *h, AVIODirEntry **next) (*next)->modification_timestamp = INT64_C(1000000) * st.st_mtime; (*next)->access_timestamp = INT64_C(1000000) * st.st_atime; (*next)->status_change_timestamp = INT64_C(1000000) * st.st_ctime; + +#ifndef _DIRENT_HAVE_D_TYPE + if (S_ISDIR(st.st_mode)) + (*next)->type = AVIO_ENTRY_DIRECTORY; + else if (S_ISFIFO(st.st_mode)) + (*next)->type = AVIO_ENTRY_NAMED_PIPE; + else if (S_ISCHR(st.st_mode)) + (*next)->type = AVIO_ENTRY_CHARACTER_DEVICE; + else if (S_ISBLK(st.st_mode)) + (*next)->type = AVIO_ENTRY_BLOCK_DEVICE; + else if (S_ISREG(st.st_mode)) + (*next)->type = AVIO_ENTRY_FILE; + else + (*next)->type = AVIO_ENTRY_UNKNOWN; +#endif /* _DIRENT_HAVE_D_TYPE */ } av_free(fullpath); } (*next)->name = av_strdup(dir->d_name); + +#ifdef _DIRENT_HAVE_D_TYPE switch (dir->d_type) { case DT_FIFO: (*next)->type = AVIO_ENTRY_NAMED_PIPE; @@ -263,14 +289,22 @@ static int file_read_dir(URLContext *h, AVIODirEntry **next) (*next)->type = AVIO_ENTRY_UNKNOWN; break; } +#endif /* _DIRENT_HAVE_D_TYPE */ return 0; +#else + return AVERROR(ENOSYS); +#endif /* HAVE_DIRENT_H */ } static int file_close_dir(URLContext *h) { +#if HAVE_DIRENT_H FileContext *c = h->priv_data; closedir(c->dir); return 0; +#else + return AVERROR(ENOSYS); +#endif /* HAVE_DIRENT_H */ } URLProtocol ff_file_protocol = { -- 2.3.6 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel