home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 274.lha / DiskHandler / dir.c < prev    next >
C/C++ Source or Header  |  1989-07-25  |  4KB  |  124 lines

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  2. /* |_o_o|\\ Copyright (c) 1987 The Software Distillery.  All Rights Reserved */
  3. /* |. o.| || This program may not be distributed without the permission of   */
  4. /* | .  | || the authors:                                          BBS:      */
  5. /* | o  | ||   John Toebes     Dave Baker    John Mainwaring                 */
  6. /* |  . |//                                                                  */
  7. /* ======                                                                    */
  8. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  9. /* Directory Manipulation */
  10. /*  ActCreateDir ActExamine ActExNext ActParent */
  11. #include "handler.h"
  12.  
  13.  
  14. void ActCreateDir(global,pkt)
  15. GLOBAL global;
  16. struct DosPacket *pkt;              /* a pointer to the dos packet sent      */
  17. /* Arg1 - Lock */
  18. /* Arg2 - name */
  19. /* Arg3 (optional) Attributes */
  20. {
  21.    struct FileLock *lock;
  22.    long key;
  23.  
  24.    BUG(("ActCreateDir\n"));
  25.  
  26.    lock = (struct FileLock *)pkt->dp_Arg1;
  27.  
  28.    key = CreateEntry(global, GetKey(global,lock),
  29.                     (char *)pkt->dp_Arg2, NEWFILE, ST_USERDIR);
  30.  
  31.    pkt->dp_Res1 = MKBADDR(CreateLock(global, key, ACCESS_READ));
  32. }
  33.  
  34. /*---------------------------------------------------------------------------*/
  35. /* Structure of the FileInfoBlock                                            */
  36. /* struct FileInfoBlock {                                                    */
  37. /*    LONG fib_DiskKey;           Location on disk of entry                  */
  38. /*    LONG fib_DirEntryType;      <0 plain file, >0 a directory              */
  39. /*    char fib_FileName[108];     Null terminated name of file               */
  40. /*    LONG fib_Protection;        Protection bits for the file               */
  41. /*    LONG fib_EntryType;         Internal for Dos use                       */
  42. /*    LONG fib_Size;              Length of file in bytes                    */
  43. /*    LONG fib_NumBlocks;         Length of file in blocks                   */
  44. /*    struct DateStamp fib_Date;  File creation date                         */
  45. /*    char fib_Comment[116];      Comment associated with file               */
  46. /*    };                                                                     */
  47. /*---------------------------------------------------------------------------*/
  48. void ActExamine(global, pkt)
  49. GLOBAL global;
  50. struct DosPacket *pkt;              /* a pointer to the dos packet sent      */
  51. /* Arg1: Lock of object to examine */
  52. /* Arg2: FileInfoBlock to fill in */
  53. {
  54.    struct FileInfoBlock *info;
  55.    long key;
  56.  
  57.    BUG(("ActExamine\n"));
  58.    info = (struct FileInfoBlock *)pkt->dp_Arg2;
  59.  
  60.    /* get the block associated with the lock */
  61.    key = GetKey(global, (struct FileLock *)pkt->dp_Arg1);
  62.  
  63.    pkt->dp_Res1 = GetInfo(global, key, info);
  64. }
  65.  
  66. void ActExNext(global,pkt)
  67. GLOBAL global;
  68. struct DosPacket *pkt;              /* a pointer to the dos packet sent      */
  69. /* ARG1 - Lock */
  70. /* ARG2 - BPTR FileInfoBlock */
  71. {
  72.    struct FileInfoBlock *info;
  73.    KEY key, rootkey;
  74.  
  75.    BUG(("ActExNext\n"));
  76.    rootkey = GetKey(global, (struct FileLock *)pkt->dp_Arg1);
  77.    info = (struct FileInfoBlock *)pkt->dp_Arg2;
  78.  
  79.    /* See if they are going for the first time */
  80.    if (rootkey == info->fib_DiskKey)
  81.       {
  82.       if (GetProtect(global,rootkey) & FIBF_READ)
  83.          {
  84.          pkt->dp_Res1 = DOS_FALSE;
  85.          pkt->dp_Res2 = ERROR_READ_PROTECTED;
  86.          return;
  87.          }
  88.  
  89.       BUG(("First time through\n"));
  90.       /* First time, initiate for the next entry */
  91.       key = 0;
  92.       }
  93.    else
  94.       {
  95.       BUG(("Going for next key from %ld\n", info->fib_DiskKey))
  96.       key = info->fib_DiskKey;
  97.       }
  98.  
  99.    /* find next key in directory */
  100.    key = NextKey(global, key, info, rootkey);
  101.  
  102.    pkt->dp_Res2 = ERROR_NO_MORE_ENTRIES;
  103.    pkt->dp_Res1 = GetInfo(global, key, info);
  104. }
  105.  
  106. void ActParent(global,pkt)
  107. GLOBAL global;
  108. struct DosPacket *pkt;              /* a pointer to the dos packet sent      */
  109. /* Arg1 - Lock */
  110. {
  111.    long key;
  112.    struct FileLock *lock;
  113.  
  114.    BUG(("ActParent\n"));
  115.  
  116.    key = ParentKey(global, GetKey(global, (struct FileLock *)pkt->dp_Arg1));
  117.  
  118.    lock = CreateLock(global, key, ACCESS_READ);
  119.  
  120.    BUG(("Parent is %ld lock is %08lx\n", key, lock));
  121.  
  122.    pkt->dp_Res1 = MKBADDR(lock);
  123. }
  124.