Commit e97179b6 by Ramsay Jones

win32: Add a 'git__' prefix to the directory reading routines

This reduces the global namespace pollution and allows for
a win32 compiler (eg. Open Watcom) to provide these routines
in a header other than <dirent.h> (eg in <io.h>).

Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
parent 90d4d2f0
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#ifdef GIT_WIN32 #ifdef GIT_WIN32
struct dirent { struct git__dirent {
int d_ino; int d_ino;
char d_name[261]; char d_name[261];
}; };
...@@ -17,15 +17,24 @@ struct dirent { ...@@ -17,15 +17,24 @@ struct dirent {
typedef struct { typedef struct {
HANDLE h; HANDLE h;
WIN32_FIND_DATA f; WIN32_FIND_DATA f;
struct dirent entry; struct git__dirent entry;
char *dir; char *dir;
int first; int first;
} DIR; } git__DIR;
extern DIR *opendir(const char *); extern git__DIR *git__opendir(const char *);
extern struct dirent *readdir(DIR *); extern struct git__dirent *git__readdir(git__DIR *);
extern void rewinddir(DIR *); extern void git__rewinddir(git__DIR *);
extern int closedir(DIR *); extern int git__closedir(git__DIR *);
# ifndef GIT__WIN32_NO_WRAP_DIR
# define dirent git__dirent
# define DIR git__DIR
# define opendir git__opendir
# define readdir git__readdir
# define rewinddir git__rewinddir
# define closedir git__closedir
# endif
#endif #endif
......
#define GIT__WIN32_NO_WRAP_DIR
#include "dir.h" #include "dir.h"
static int init_filter(char *filter, size_t n, const char *dir) static int init_filter(char *filter, size_t n, const char *dir)
...@@ -15,10 +16,10 @@ static int init_filter(char *filter, size_t n, const char *dir) ...@@ -15,10 +16,10 @@ static int init_filter(char *filter, size_t n, const char *dir)
return 1; return 1;
} }
DIR *opendir(const char *dir) git__DIR *git__opendir(const char *dir)
{ {
char filter[4096]; char filter[4096];
DIR *new; git__DIR *new;
if (!dir || !init_filter(filter, sizeof(filter), dir)) if (!dir || !init_filter(filter, sizeof(filter), dir))
return NULL; return NULL;
...@@ -45,7 +46,7 @@ DIR *opendir(const char *dir) ...@@ -45,7 +46,7 @@ DIR *opendir(const char *dir)
return new; return new;
} }
struct dirent *readdir(DIR *d) struct git__dirent *git__readdir(git__DIR *d)
{ {
if (!d || d->h == INVALID_HANDLE_VALUE) if (!d || d->h == INVALID_HANDLE_VALUE)
return NULL; return NULL;
...@@ -66,7 +67,7 @@ struct dirent *readdir(DIR *d) ...@@ -66,7 +67,7 @@ struct dirent *readdir(DIR *d)
return &d->entry; return &d->entry;
} }
void rewinddir(DIR *d) void git__rewinddir(git__DIR *d)
{ {
char filter[4096]; char filter[4096];
...@@ -83,7 +84,7 @@ void rewinddir(DIR *d) ...@@ -83,7 +84,7 @@ void rewinddir(DIR *d)
} }
} }
int closedir(DIR *d) int git__closedir(git__DIR *d)
{ {
if (d) { if (d) {
if (d->h != INVALID_HANDLE_VALUE) if (d->h != INVALID_HANDLE_VALUE)
......
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