Original Unix filesystems, open the directory as a regular file and read
and interpret the byte-stream ?? There were convenient
fixed-width entries (14 characters, plus a two-byte inode number).
OS re-writing of entire directory blocks (e.g., compacting out
entries no longer used) was controversial, since doing so destroyed
assumptions that directories could be iterated through from begining
to end.
From the link that you cut to SFL, we have this directory API that
works on POSIX and Windows:
Directory access functions
Filename: sfldir.h
Package: Standard Function Library (SFL)
Written: 1996/04/02 iMatix SFL project team (e-mail address removed)
Revised: 2000/01/18
Copyright: Copyright (c) 1996-2000 iMatix Corporation
Synopsis
The directory access functions provide a portable interface to the
system's file directory structure. In general these functions are
modelled around the UNIX opendir and readdir functions, but they are
also similar to the DOS interface. These functions can fail on SVr4 if
the <dirent.h> file does not match the C library. Recompile with the
switch -D _USE_BSD_DIRENT and they should work a bit better. Tested
on: MS-DOS (Turbo-C), Windows (MSVC 4.0), UNIX (Linux, IBM AIX,
SunOS). OS/2 port was done by Ewen McNeill (e-mail address removed). DJGPP and
DRDOS LFN by Rob Judd (e-mail address removed). Changes for Win32 by Will
Menninger (e-mail address removed).
List of Functions
* Bool open dir
(DIRST *dir, const char *dir_name);
* Bool read dir
(DIRST *dir);
* Bool close dir
(DIRST *dir);
* char * format dir
(DIRST *dir, Bool full);
* int fix dir
(DIRST *dir);
* int free dir
(DIRST *dir);
* char * resolve path
(const char *path);
* char * locate path
(const char *root, const char *path);
* char * clean path
(const char *path);
* NODE * load dir list
(const char *dir_name, const char *sort);
* void sort dir list
(NODE *filelist, const char *sort);
* FILEINFO * add dir list
(NODE *filelist, const DIRST *dir);
* void free dir list
(NODE *filelist);
* char * get curdir
(void);
* int set curdir
(const char *path);
* Bool file matches
(const char *filename, const char *pattern);
* int make dir
(const char *path);
* int remove dir
(const char *path);
* qbyte dir usage
(const char *path, Bool recurse);
* qbyte dir files
(const char *path, Bool recurse);