Commit 9cb82b16 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Do not stat directories on Windows

For lack of a better solution, I assume that Windows has a finite
paths length limit to prevent infinite recursion. Otherwise we need
dirfd() and unique inodes.
parent 2103c812
...@@ -45,12 +45,6 @@ ...@@ -45,12 +45,6 @@
# include <unistd.h> # include <unistd.h>
#elif defined( WIN32 ) && !defined( UNDER_CE ) #elif defined( WIN32 ) && !defined( UNDER_CE )
# include <io.h> # include <io.h>
static inline int dirfd (void *dir)
{
return -1;
}
#elif defined( UNDER_CE )
# define strcoll strcmp
#endif #endif
#ifdef HAVE_DIRENT_H #ifdef HAVE_DIRENT_H
...@@ -119,7 +113,9 @@ struct directory_t ...@@ -119,7 +113,9 @@ struct directory_t
directory_t *parent; directory_t *parent;
DIR *handle; DIR *handle;
char *uri; char *uri;
#ifndef WIN32
struct stat st; struct stat st;
#endif
char path[1]; char path[1];
}; };
...@@ -225,12 +221,16 @@ static char *encode_path (const char *path) ...@@ -225,12 +221,16 @@ static char *encode_path (const char *path)
/* Detect directories that recurse into themselves. */ /* Detect directories that recurse into themselves. */
static bool has_inode_loop (const directory_t *dir) static bool has_inode_loop (const directory_t *dir)
{ {
#ifndef WIN32
dev_t dev = dir->st.st_dev; dev_t dev = dir->st.st_dev;
ino_t inode = dir->st.st_ino; ino_t inode = dir->st.st_ino;
while ((dir = dir->parent) != NULL) while ((dir = dir->parent) != NULL)
if ((dir->st.st_dev == dev) && (dir->st.st_ino == inode)) if ((dir->st.st_dev == dev) && (dir->st.st_ino == inode))
return true; return true;
#else
# define fstat( fd, st ) (0)
#endif
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment