Mercurial > hg > octave-max
changeset 6093:174cfaa0c4af
[project @ 2006-10-26 00:32:53 by jwe]
author | jwe |
---|---|
date | Thu, 26 Oct 2006 00:32:53 +0000 |
parents | 30beea6739da |
children | 86ee3cc8d8d2 |
files | liboctave/ChangeLog liboctave/lo-sysdep.cc |
diffstat | 2 files changed, 75 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -2,13 +2,16 @@ * Sparse.cc (assign): Clear lhs index after error. -2006-10-24 David Bateman <dbateman@free.fr> +2006-10-25 David Bateman <dbateman@free.fr> * Sparse.cc (assign (Sparse<LT>&, const Sparse<RT>&)): Fix previous patch so it works. 2006-10-25 Michael Goffioul <michael.goffioul@swing.be> + * lo-sysdep.cc (opendir, readdir, rewinddir, closedir): + New functions. + * Makefile.in (XTRA_CDEFS, XTRA_CXXDEFS): Substitute here. 2006-10-24 David Bateman <dbateman@free.fr>
--- a/liboctave/lo-sysdep.cc +++ b/liboctave/lo-sysdep.cc @@ -92,6 +92,77 @@ #endif } +#ifdef _MSC_VER + +// FIXME -- it would probably be better to adapt the versions of +// opendir, readdir, and closedir from Emacs as they appear to be more +// complete implementations (do the functions below work for network +// paths, for example)? We can probably get along without rewinddir. + +#include <windows.h> + +struct direct +{ + char *d_name; +}; + +typedef struct +{ + HANDLE hnd; + WIN32_FIND_DATA fd; + int dirty; + struct direct d; + const char* current; +} DIR; + +DIR * +opendir (const char *name) +{ + DIR *d = static_cast<DIR *> (malloc (sizeof (DIR))); + static char buffer[MAX_PATH]; + + strncpy (buffer, name, MAX_PATH); + strncat (buffer, "\\*", MAX_PATH); + d->current = buffer; + d->hnd = FindFirstFile (buffer, &(d->fd)); + if (d->hnd == INVALID_HANDLE_VALUE) + return 0; + d->dirty = 1; + return d; +} + +void +rewinddir (DIR* d) +{ + if (d->hnd != INVALID_HANDLE_VALUE) + FindClose (d->hnd); + d->hnd = FindFirstFile (d->current, &(d->fd)); + d->dirty = 1; +} + +void +closedir (DIR *d) +{ + if (d->hnd != INVALID_HANDLE_VALUE) + FindClose (d->hnd); + free (d); +} + +struct direct * +readdir (DIR *d) +{ + if (! d->dirty) + { + if (! FindNextFile(d->hnd, &(d->fd))) + return 0; + } + d->d.d_name = d->fd.cFileName; + d->dirty = 0; + return &(d->d); +} + +#endif + /* ;;; Local Variables: *** ;;; mode: C++ ***