anope- supernets anope source code & configuration |
git clone git://git.acid.vegas/anope.git |
Log | Files | Refs | Archive | README |
dir.cpp (788B)
1 /* POSIX emulation layer for Windows. 2 * 3 * (C) 2008-2022 Anope Team 4 * Contact us at team@anope.org 5 * 6 * Please read COPYING and README for further details. 7 */ 8 9 #include "dir.h" 10 #include <stdio.h> 11 12 DIR *opendir(const char *path) 13 { 14 char real_path[MAX_PATH]; 15 _snprintf(real_path, sizeof(real_path), "%s/*", path); 16 17 DIR *d = new DIR(); 18 d->handle = FindFirstFile(real_path, &d->data); 19 d->read_first = false; 20 21 if (d->handle == INVALID_HANDLE_VALUE) 22 { 23 delete d; 24 return NULL; 25 } 26 27 return d; 28 } 29 30 dirent *readdir(DIR *d) 31 { 32 if (d->read_first == false) 33 d->read_first = true; 34 else if (!FindNextFile(d->handle, &d->data)) 35 return NULL; 36 37 d->ent.d_ino = 1; 38 d->ent.d_name = d->data.cFileName; 39 40 return &d->ent; 41 } 42 43 int closedir(DIR *d) 44 { 45 FindClose(d->handle); 46 delete d; 47 return 0; 48 }