Mercurial > hg > dmlib
changeset 630:6e2b53f2878b
Win32 compatibility.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 15 Apr 2013 04:11:44 +0300 |
parents | 3af0d6e39629 |
children | 25656351f5f9 |
files | dmres.c |
diffstat | 1 files changed, 9 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/dmres.c Mon Apr 15 03:39:24 2013 +0300 +++ b/dmres.c Mon Apr 15 04:11:44 2013 +0300 @@ -8,13 +8,10 @@ #include <time.h> #ifdef DM_USE_STDIO -# ifdef __WIN32 -# else -# include <sys/types.h> -# include <sys/stat.h> -# include <unistd.h> -# include <dirent.h> -# endif +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> +#include <dirent.h> #endif @@ -922,26 +919,18 @@ static int dmres_load_directory(DMResourceLib *lib, const char *path) { int res = DMERR_OK; - BOOL done = FALSE; - -#ifdef __WIN32 -#else + struct dirent *dh; DIR *hdir = opendir(path); if (hdir == NULL) return dmGetErrno(); -#endif dmMutexLock(lib->mutex); do { DMResource *node = NULL; -#ifdef __WIN32 -#else - struct dirent *dh = readdir(hdir); - if (dh == NULL) - done = TRUE; - else + dh = readdir(hdir); + if (dh != NULL) { struct stat sbuf; char *fname = dm_strdup_printf("%s/%s", path, dh->d_name); @@ -957,13 +946,13 @@ if (S_ISREG(sbuf.st_mode)) node = dmres_new(lib, dh->d_name, 0, sbuf.st_size); } -#endif + if (node != NULL) { node->fops = &dfStdioFileOps; dmres_insert(lib, node); } - } while (!done); + } while (dh != NULL); out: dmMutexUnlock(lib->mutex);