Changeset 785


Ignore:
Timestamp:
1999-11-21T14:09:30+13:00 (24 years ago)
Author:
sjboddie
Message:

added readdir function for windows

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/lib/fileutil.cpp

    r745 r785  
    2828/*
    2929   $Log$
     30   Revision 1.11  1999/11/21 01:09:30  sjboddie
     31   added readdir function for windows
     32
    3033   Revision 1.10  1999/10/25 22:27:51  sjboddie
    3134   added read_dir function - doesn't support windows yet
     
    160163// need to do a windows version of this some time ...
    161164#if defined __WIN32__
    162 bool read_dir (const text_t &dirname, text_tarray &filelist) {}
     165
     166#include <windows.h>
     167
     168BOOL read_dir (const text_t &dirname, text_tarray &filelist) {
     169 
     170  WIN32_FIND_DATA FileData; 
     171  HANDLE hSearch;
     172  DWORD dwAttrs;
     173  char *dirpath = dirname.getcstr();
     174  strcat (dirpath, "\\*");
     175
     176  BOOL finished = false;
     177 
     178  hSearch = FindFirstFile(dirpath, &FileData);
     179  if (hSearch == INVALID_HANDLE_VALUE) return false;
     180 
     181  text_t filename = FileData.cFileName;
     182  if (filename != "." && filename != ".." && filename != "CVS")
     183    filelist.push_back (filename);
     184 
     185  while (FindNextFile(hSearch, &FileData)) {
     186    filename = FileData.cFileName;
     187    if (filename == "." || filename == ".." || filename == "CVS")
     188      continue;
     189    filelist.push_back (filename);
     190  }
     191 
     192  FindClose(hSearch);
     193 
     194  return true;
     195}
    163196
    164197#else
Note: See TracChangeset for help on using the changeset viewer.