/**************************************** mydir.c By Stephen Vermeulen 1989 (403) 282-7990 PO Box 3295, Station B Calgary, Alberta, CANADA, T2M 4L8 Placed in the public domain, do with as you please. This routine is used to recursively decend the file system tree from our current directory location. It prints the full relative path (relative to the path you supply to the CLI) to each file on a line by itself to your CLI. This is useful as an aid in doing recursive directory ZOOing. For example to zoo the complete contents of DF0: you can do: mydir df0: | zoo aI completedisk and if you don't have pipes you can use: mydir >temp df0: zoo #include #include #include #include ScanDir(lock, dirname) ULONG lock; char *dirname; { ULONG tlock; char tdir[256], t; struct FileInfoBlock *fib; fib = (struct FileInfoBlock *) AllocMem((long) sizeof(struct FileInfoBlock), 0L); if (fib) { if (Examine(lock, fib)) { while (ExNext(lock, fib)) { strcpy(tdir, dirname); if (strlen(tdir)) { t = tdir[strlen(tdir) - 1]; if ((t != '/') && (t != ':')) strcat(tdir, "/"); } strcat(tdir, fib->fib_FileName); if (fib->fib_DirEntryType > 0) { tlock = (ULONG) Lock(tdir, ACCESS_READ); ScanDir(tlock, tdir); /** it was a directory so recurse **/ UnLock(tlock); } else printf("%s\n", tdir); } } FreeMem(fib, (long) sizeof(struct FileInfoBlock)); } } main(argc, argv) int argc; char *argv[]; { ULONG root; struct FileInfoBlock *fib; fib = (struct FileInfoBlock *) AllocMem((long) sizeof(struct FileInfoBlock), 0L); if (fib) { if (argc == 1) { root = (ULONG) Lock("", ACCESS_READ); if (Examine(root, fib)) { if (fib->fib_DirEntryType > 0) ScanDir(root, argv[argc]); } UnLock(root); } else { while (--argc) { root = (ULONG) Lock(argv[argc], ACCESS_READ); if (Examine(root, fib)) { if (fib->fib_DirEntryType > 0) ScanDir(root, argv[argc]); } UnLock(root); } } FreeMem(fib, (long) sizeof(struct FileInfoBlock)); } }