home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d180 / browser.lha / Browser / vollist.c < prev   
C/C++ Source or Header  |  1989-02-25  |  2KB  |  67 lines

  1. #include <libraries/dosextens.h>
  2. #include <stdio.h>
  3. #ifdef DEBUG
  4. #include "debug.h"
  5. #endif
  6. /* Fakes an Examine/ExNext interface to the device list. Call OpenVolList
  7.  * first, then ReadVolList(fib), and finally CloseVolList. This last is
  8.  * a dummy, but it's handy if you want to be safe and put a forbid/permit
  9.  * around the whole thing.
  10.  */
  11.  
  12. #define toAPTR(b) ((b)<<2)
  13. #define toBPTR(a) ((a)>>2)
  14.  
  15. struct DeviceList *list;
  16.  
  17. OpenVolList()
  18. {
  19.     extern struct DosLibrary *DOSBase;
  20.     struct RootNode *root;
  21.     struct DosInfo *info;
  22.  
  23.     root = (struct RootNode *)DOSBase -> dl_Root;
  24.     info = (struct DosInfo *)toAPTR(root->rn_Info);
  25.     list = (struct DeviceList *)toAPTR(info->di_DevInfo);
  26. }
  27.  
  28. ReadVolList(fib)
  29. struct FileInfoBlock *fib;
  30. {
  31.     struct DeviceList *next;
  32.  
  33.     while(list) {
  34.         next = (struct DeviceList *)toAPTR(list->dl_Next);
  35.         if(list->dl_Type == DLT_VOLUME ||
  36.            list->dl_Type == DLT_DIRECTORY) {
  37.             char *ptr;
  38.             int count;
  39.             ptr = (char *)toAPTR((BPTR)list->dl_Name);
  40.             count = *ptr++;
  41.             if(count > 106)
  42.                 count = 106;
  43.             strncpy(fib->fib_FileName, ptr, count);
  44.             fib->fib_FileName[count++] = ':';
  45.             fib->fib_FileName[count] = 0;
  46.             if(strcmp(fib->fib_FileName, "RAM Disk:") == 0)
  47.                 strcpy(fib->fib_FileName, "RAM:");
  48.             fib->fib_DiskKey = 0;
  49.             fib->fib_DirEntryType = list->dl_Type;
  50.             fib->fib_Protection = 0;
  51.             fib->fib_EntryType = list->dl_Type;
  52.             fib->fib_Size = 0;
  53.             fib->fib_NumBlocks = 0;
  54.             fib->fib_Date = list->dl_VolumeDate;
  55.             fib->fib_Comment[0] = 0;
  56.             list = next;
  57.             return 1;
  58.         }
  59.         list = next;
  60.     }
  61.     return 0;
  62. }
  63.  
  64. CloseVolList()
  65. {
  66. }
  67.