From 14ab055695a4b394d2611983e13992dc601f8c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Wed, 14 Oct 2015 13:15:34 +0200 Subject: Imported Upstream version 1.36.6 --- helper/win32-dirent.c | 33 ++++++++++++++++++--------------- helper/win32-dirent.h | 6 ++++-- 2 files changed, 22 insertions(+), 17 deletions(-) (limited to 'helper') diff --git a/helper/win32-dirent.c b/helper/win32-dirent.c index 527c015..c86a73c 100644 --- a/helper/win32-dirent.c +++ b/helper/win32-dirent.c @@ -4,7 +4,7 @@ * * w32lib is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * w32lib is distributed in the hope that it will be useful, @@ -13,24 +13,28 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. * * For more information and a list of changes, see w32lib.h */ -#include -#include #include #include #include -#include "win32-dirent.h" +#include + +#include "w32lib.h" + + DIR * opendir ( const char *name ) { DIR *dir; - + dir = calloc (1, sizeof *dir + strlen (name)); if (!dir) return NULL; @@ -38,7 +42,7 @@ opendir ( const char *name ) return dir; } -int +int closedir (DIR *dir) { FindClose( (HANDLE)dir->dd_handle ); @@ -52,12 +56,12 @@ readdir( DIR *dir ) WIN32_FIND_DATA fInfo; struct dirent *xdirent; int ret; - + if ( !dir->dd_handle ) { char *dirname; - - if (*dir->dd_name) + + if (*dir->dd_name) { size_t n = strlen (dir->dd_name); dirname = malloc (n + 4 + 1); @@ -77,23 +81,22 @@ readdir( DIR *dir ) ret = 0; else ret = 1; - } + } else if ( dir->dd_handle != -1l ) { ret = FindNextFile ((HANDLE)dir->dd_handle, &fInfo); } else ret = 0; - if ( !ret ) + if ( !ret ) return NULL; xdirent = calloc ( 1, sizeof *xdirent); if (xdirent) { - strncpy (xdirent->d_name, fInfo.cFileName, FILENAME_MAX - 1 ); - xdirent->d_name[FILENAME_MAX - 1] = 0; + strncpy (xdirent->d_name, fInfo.cFileName, FILENAME_MAX -1 ); + xdirent->d_name[FILENAME_MAX-1] = 0; xdirent->d_namlen = strlen( xdirent->d_name ); } return xdirent; } - diff --git a/helper/win32-dirent.h b/helper/win32-dirent.h index 7c461e3..59f0dc8 100644 --- a/helper/win32-dirent.h +++ b/helper/win32-dirent.h @@ -4,7 +4,7 @@ * * w32lib is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or + * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * w32lib is distributed in the hope that it will be useful, @@ -13,7 +13,9 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program. If not, see . + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + * USA. * * For more information and a list of changes, see w32lib.h */ -- cgit v1.2.3