diff options
author | Michal Čihař <nijel@debian.org> | 2015-10-14 13:15:34 +0200 |
---|---|---|
committer | Michal Čihař <nijel@debian.org> | 2015-10-14 13:15:34 +0200 |
commit | 14ab055695a4b394d2611983e13992dc601f8c8b (patch) | |
tree | 48ffd2be3c81c314c0276fe651ee16014dc45b40 /helper | |
parent | 3a1d9ea026f7f0ce5c5fedd8058892d5e1d3d271 (diff) |
Imported Upstream version 1.36.6
Diffstat (limited to 'helper')
-rw-r--r-- | helper/win32-dirent.c | 33 | ||||
-rw-r--r-- | helper/win32-dirent.h | 6 |
2 files changed, 22 insertions, 17 deletions
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 <http://www.gnu.org/licenses/>. + * 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 <io.h> -#include <stdio.h> #include <stdlib.h> #include <string.h> #include <windows.h> -#include "win32-dirent.h" +#include <dirent.h> + +#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 <http://www.gnu.org/licenses/>. + * 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 */ |