home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <nit.h>
- #include <ntt.h>
-
- #define ABORT(msg) \
- fprintf(stderr,"%s at %d in %s\n",msg,__LINE__,__FILE__); \
- exit(255);
-
- static int result;
- static char scratchPad[10];
-
-
- void WalkDirectory(BYTE directoryHandle, void (*func)(BYTE handle))
- {
- char dirName[16];
-
- int sequenceNumber;
-
- BYTE newDirectoryHandle;
-
-
- sequenceNumber = 0;
-
- for(;;) {
- result = ScanDirectoryInformation(
- directoryHandle,
- "*",
- &sequenceNumber,
- dirName,
- (BYTE *) scratchPad,
- (long *) scratchPad,
- (BYTE *) scratchPad );
-
- if (result) return;
-
- result = AllocTemporaryDirectoryHandle(directoryHandle,dirName,'[',
- &newDirectoryHandle,scratchPad);
- if (result) {
- ABORT("Couldn't allocate a temporary directory handle");
- }
-
- (*func) (newDirectoryHandle);
-
- WalkDirectory(newDirectoryHandle,func);
-
- if (DeallocateDirectoryHandle(newDirectoryHandle)) {
- ABORT("Couldn't deallocate a temporary directory handle");
- }
- }
- }
-
-