# HG changeset patch # User jwe # Date 1161822773 0 # Node ID 174cfaa0c4af49672a13b4360a32d598080ab35c # Parent 30beea6739da852238249746294e2ce6a0c01fff [project @ 2006-10-26 00:32:53 by jwe] diff -r 30beea6739da -r 174cfaa0c4af liboctave/ChangeLog --- a/liboctave/ChangeLog Wed Oct 25 23:45:16 2006 +0000 +++ b/liboctave/ChangeLog Thu Oct 26 00:32:53 2006 +0000 @@ -2,13 +2,16 @@ * Sparse.cc (assign): Clear lhs index after error. -2006-10-24 David Bateman +2006-10-25 David Bateman * Sparse.cc (assign (Sparse&, const Sparse&)): Fix previous patch so it works. 2006-10-25 Michael Goffioul + * lo-sysdep.cc (opendir, readdir, rewinddir, closedir): + New functions. + * Makefile.in (XTRA_CDEFS, XTRA_CXXDEFS): Substitute here. 2006-10-24 David Bateman diff -r 30beea6739da -r 174cfaa0c4af liboctave/lo-sysdep.cc --- a/liboctave/lo-sysdep.cc Wed Oct 25 23:45:16 2006 +0000 +++ b/liboctave/lo-sysdep.cc Thu Oct 26 00:32:53 2006 +0000 @@ -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 + +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 (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++ ***