Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

scandir.h

Go to the documentation of this file.
00001 /*
00002 From: Tom Torfs (tomtorfs@village.uunet.be)
00003 Subject: scandir() for win32
00004 View: Complete Thread (5 articles)
00005 Original Format
00006 Newsgroups: comp.os.ms-windows.programmer.win32, comp.unix.programmer
00007 Date: 2002-10-31 03:26:30 PST
00008 
00009 Hello All,
00010 
00011 Below you will find an implementation of scandir() (and alphasort())
00012 for Win32. I wrote it because it helps me a lot when writing directory
00013 scanning code for both Unix and Win32. I hope some of you will find it
00014 useful as well.
00015 
00016 greetings,
00017 Tom
00018 
00019 *** scandir.h ***
00020 
00021 */
00022 
00023 /*
00024  * scandir() for win32
00025  * this tool should make life easier for people writing for both unix
00026 and wintel
00027  * written by Tom Torfs, 2002/10/31
00028  * donated to the public domain; use this code for anything you like
00029 as long as
00030  * it is understood there are absolutely *NO* warranties of any kind,
00031 even implied
00032  */
00033 
00034 #ifdef _WIN32
00035 
00036 #include <stdio.h>
00037 
00038 #define MAXNAMLEN FILENAME_MAX
00039 
00040 typedef unsigned long ino_t;
00041 
00042 /* directory entry structure */
00043 struct dirent {
00044     char d_name[MAXNAMLEN+1]; /* name of directory entry (0
00045 terminated) */
00046      ino_t d_ino;               /* file serial number -- will be 0 for
00047 win32 */
00048      short d_namlen;            /* length of string in d_name */
00049      short d_reclen;            /* length of this record */
00050 };
00051 
00052 /* the scandir() function */
00053 int scandir(
00054      const char *dirname,
00055      struct dirent ***namelist,
00056      int (*select)(const struct dirent *),
00057      int (*compar)(
00058           const struct dirent **,
00059           const struct dirent **
00060      )
00061 );
00062 
00063 /* compare function for scandir() for alphabetic sort
00064    (case-insensitive on Win32) */
00065 int alphasort(
00066      const struct dirent **d1,
00067      const struct dirent **d2
00068 );
00069 
00070 /* case-insensitive strcmp() */
00071 int istrcmp(
00072   const char *s1,
00073   const char *s2
00074 );
00075 
00076 #endif
00077 



MDFS SourceForge project page and download

SourceForge.net Logo

Generated on Sat Jan 3 03:14:20 2004 for MDFS by doxygen1.3.5