4f3cef0454
* ABOUT-NLS * Makefile.am * autogen.sh * configure.ac * config/config.rpath * config/mkinstalldirs * m4/Makefile.am * m4/glibc2.m4 * m4/gnupg.m4 * m4/gpgme.m4 * m4/intmax.m4 * m4/longdouble.m4 * m4/longlong.m4 * m4/printf-posix.m4 * m4/signed.m4 * m4/size_max.m4 * m4/ulonglong.m4 * m4/wchar_t.m4 * m4/wint_t.m4 * m4/xsize.m4 * po/Makefile.in.in * po/Makevars * po/bg.po * po/ca.po * po/cs.po * po/de.po * po/el.po * po/en_GB.po * po/es.po * po/fi.po * po/fr.po * po/hr.po * po/hu.po * po/it.po * po/ja.po * po/ko.po * po/nb.po * po/nl.po * po/pl.po * po/pt_BR.po * po/ru.po * po/sk.po * po/sr.po * po/stamp-po * po/sv.po * po/zh_CN.po * po/zh_TW.po * src/Makefile.am * src/codeconv.c * src/compose.c * src/exporthtml.c * src/exportldif.c * src/folder.c * src/main.c * src/manual.c * src/mh.c * src/mimeview.c * src/send_message.c * src/common/Makefile.am * src/common/fnmatch.c * src/common/fnmatch.h * src/common/fnmatch_loop.c * src/common/nntp.c * src/common/plugin.c * src/common/smtp.c * src/common/socket.c * src/common/string_match.c * src/common/sylpheed.c * src/common/utils.c * src/common/utils.h * src/common/w32_dirent.c * src/common/w32_reg.c * src/common/w32_signal.c * src/common/w32_stat.c * src/common/w32_stdio.c * src/common/w32_stdlib.c * src/common/w32_string.c * src/common/w32_time.c * src/common/w32_unistd.c * src/common/w32_wait.c * src/common/w32lib.h * src/etpan/Makefile.am * src/gtk/Makefile.am * src/plugins/clamav/Makefile.am * src/plugins/demo/Makefile.am * src/plugins/dillo_viewer/Makefile.am * src/plugins/pgpcore/Makefile.am * src/plugins/pgpcore/passphrase.c * src/plugins/pgpcore/plugin.def * src/plugins/pgpcore/sgpgme.c * src/plugins/pgpcore/sylpheed.def * src/plugins/pgpcore/version.rc * src/plugins/pgpinline/Makefile.am * src/plugins/pgpinline/plugin.def * src/plugins/pgpinline/sylpheed.def * src/plugins/pgpinline/version.rc * src/plugins/pgpmime/Makefile.am * src/plugins/pgpmime/mypgpcore.def * src/plugins/pgpmime/plugin.def * src/plugins/pgpmime/sylpheed.def * src/plugins/pgpmime/version.rc * src/plugins/spamassassin/Makefile.am Very little ;-) patch from Werner Koch, providing infrastructure for cross-compiling to Win32
102 lines
2.3 KiB
C
102 lines
2.3 KiB
C
/* w32_dirent.c - Posix emulation layer for Sylpheed (Claws)
|
|
*
|
|
* This file is part of w32lib.
|
|
*
|
|
* 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 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* w32lib is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* 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, 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 <stdlib.h>
|
|
#include <string.h>
|
|
#include <windows.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;
|
|
strcpy (dir->dd_name, name);
|
|
return dir;
|
|
}
|
|
|
|
int
|
|
closedir (DIR *dir)
|
|
{
|
|
FindClose( (HANDLE)dir->dd_handle );
|
|
free( dir );
|
|
return 0;
|
|
}
|
|
|
|
struct dirent *
|
|
readdir( DIR *dir )
|
|
{
|
|
WIN32_FIND_DATA fInfo;
|
|
struct dirent *xdirent;
|
|
int ret;
|
|
|
|
if ( !dir->dd_handle )
|
|
{
|
|
char *dirname;
|
|
|
|
if (*dir->dd_name)
|
|
{
|
|
size_t n = strlen (dir->dd_name);
|
|
dirname = malloc (n + 4 + 1);
|
|
if (dirname) {
|
|
strcpy (dirname, dir->dd_name);
|
|
strcpy (dirname + n, "\\*.*");
|
|
}
|
|
}
|
|
else
|
|
dirname = strdup( "\\*.*" );
|
|
if (!dirname)
|
|
return NULL; /* Error. */
|
|
|
|
dir->dd_handle = (long)FindFirstFile( dirname, &fInfo );
|
|
free( dirname );
|
|
if ( !dir->dd_handle )
|
|
ret = 0;
|
|
else
|
|
ret = 1;
|
|
}
|
|
else if ( dir->dd_handle != -1l )
|
|
{
|
|
ret = FindNextFile ((HANDLE)dir->dd_handle, &fInfo);
|
|
}
|
|
else
|
|
ret = 0;
|
|
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;
|
|
xdirent->d_namlen = strlen( xdirent->d_name );
|
|
}
|
|
return xdirent;
|
|
}
|