vlc | branch: master | Rémi Denis-Courmont <[email protected]> | Mon Mar 19 20:38:31 2012 +0200| [7f3120af8fb80008ee5683c51c36cd5022797b8b] | committer: Rémi Denis-Courmont
posix: open directories with close-on-exec flag > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7f3120af8fb80008ee5683c51c36cd5022797b8b --- src/posix/filesystem.c | 16 +++++++++------- 1 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/posix/filesystem.c b/src/posix/filesystem.c index 03fe5d3..5d8625f 100644 --- a/src/posix/filesystem.c +++ b/src/posix/filesystem.c @@ -162,15 +162,17 @@ int vlc_mkdir (const char *dirname, mode_t mode) */ DIR *vlc_opendir (const char *dirname) { - const char *local_name = ToLocale (dirname); - if (unlikely(local_name == NULL)) - { - errno = ENOENT; +#ifdef O_DIRECTORY + int fd = vlc_open (dirname, O_RDONLY | O_DIRECTORY); +#else /* If O_DIRECTORY is missing. fdopendir() will deal with ENOTDIR. */ + int fd = vlc_open (dirname, O_RDONLY); +#endif + if (fd == -1) return NULL; - } - DIR *dir = opendir (local_name); - LocaleFree (local_name); + DIR *dir = fdopendir (fd); + if (dir == NULL) + close (fd); return dir; } _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
