diff options
| author | Adam <Adam@anope.org> | 2011-11-08 17:29:16 -0500 |
|---|---|---|
| committer | Adam <Adam@anope.org> | 2011-11-08 17:29:16 -0500 |
| commit | b5ff856f47d8e54d12c568462a06351633c29610 (patch) | |
| tree | a4e2f96c59ee49aa5e6cacdfd30db6155151ad36 /src/win32/dir/dir.cpp | |
| parent | 97b9055f92f21cd91af44a3d5dacce0024536cff (diff) | |
Windows
Diffstat (limited to 'src/win32/dir/dir.cpp')
| -rw-r--r-- | src/win32/dir/dir.cpp | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/win32/dir/dir.cpp b/src/win32/dir/dir.cpp new file mode 100644 index 000000000..28a54be98 --- /dev/null +++ b/src/win32/dir/dir.cpp @@ -0,0 +1,47 @@ + /* POSIX emulation layer for Windows. + * + * Copyright (C) 2008-2011 Anope Team <team@anope.org> + * + * Please read COPYING and README for further details. + */ + +#include "dir.h" +#include <stdio.h> + +DIR *opendir(const char *path) +{ + char real_path[MAX_PATH]; + _snprintf(real_path, sizeof(real_path), "%s/*", path); + + DIR *d = new DIR(); + d->handle = FindFirstFile(real_path, &d->data); + d->read_first = false; + + if (d->handle == INVALID_HANDLE_VALUE) + { + delete d; + return NULL; + } + + return d; +} + +dirent *readdir(DIR *d) +{ + if (d->read_first == false) + d->read_first = true; + else if (!FindNextFile(d->handle, &d->data)) + return NULL; + + d->ent.d_ino = 1; + d->ent.d_name = d->data.cFileName; + + return &d->ent; +} + +int closedir(DIR *d) +{ + FindClose(d->handle); + delete d; + return 0; +} |
