[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MSVC compiler support [patch 20]: opendir, readdir, ...
From: |
Michael Goffioul |
Subject: |
MSVC compiler support [patch 20]: opendir, readdir, ... |
Date: |
Tue, 17 Oct 2006 21:53:31 +0200 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
Win32 implementation of opendir, readdir...
Index: liboctave/dir-ops.cc
===================================================================
RCS file: /cvs/octave/liboctave/dir-ops.cc,v
retrieving revision 1.9
diff -p -c -r1.9 dir-ops.cc
*** liboctave/dir-ops.cc 30 Jun 2006 16:48:39 -0000 1.9
--- liboctave/dir-ops.cc 17 Oct 2006 11:07:41 -0000
*************** Software Foundation, Inc., 51 Franklin S
*** 37,42 ****
--- 37,100 ----
#include "lo-sysdep.h"
#include "str-vec.h"
+ #ifdef _MSC_VER
+ #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 = (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 NULL;
+ 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 NULL;
+ }
+ d->d.d_name = d->fd.cFileName;
+ d->dirty = 0;
+ return &(d->d);
+ }
+ #endif
+
bool
dir_entry::open (const std::string& n)
{
- MSVC compiler support [patch 15]: CRUFT.DLL exported symbols (C), (continued)
- MSVC compiler support [patch 17]: octinterp.dll exported symbols, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 17]: octinterp.dll exported symbols, John W. Eaton, 2006/10/26
- MSVC compiler support [patch 18]: recursion stack overflow, Michael Goffioul, 2006/10/17
- Re: MSVC compiler support [patch 18]: recursion stack overflow, David Bateman, 2006/10/17
- MSVC compiler support [patch 18]: recursion stack overflow, John W. Eaton, 2006/10/17
- MSVC compiler support [patch 19]: strncasecmp needed in liboctave, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 19]: strncasecmp needed in liboctave, John W. Eaton, 2006/10/26
- MSVC compiler support [patch 20]: opendir, readdir, ...,
Michael Goffioul <=
- MSVC compiler support [patch 20]: opendir, readdir, ..., John W. Eaton, 2006/10/25
- MSVC compiler support [patch 21]: glob_match ctor, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 21]: glob_match ctor, John W. Eaton, 2006/10/25
- MSVC compiler support [patch 22]: mx-op-defs additional macros, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 22]: mx-op-defs additional macros, John W. Eaton, 2006/10/26
- MSVC compiler support [patch 32]: waitpid, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 32]: waitpid, John W. Eaton, 2006/10/17
- MSVC compiler support [patch 25]: INFINITE, Michael Goffioul, 2006/10/17
- MSVC compiler support [patch 25]: INFINITE, John W. Eaton, 2006/10/25
- MSVC compiler support [patch 24]: strftime crash, Michael Goffioul, 2006/10/17