home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 514b.lha / ToolLib_v8.1 / Source / extdos.s next >
Text File  |  1991-06-08  |  8KB  |  209 lines

  1.                 opt     l+,o+,ow-
  2. *
  3. *   extdos.s vesion 8.1 - © Copyright 1990 Jaba Development
  4. *
  5. *   Author    : Jan van den Baard
  6. *   Assembler : Devpac version 2.14
  7. *
  8. *
  9.  
  10.                 incdir  'sys:devpac_inc/'
  11.                 include 'mymacros.i'
  12.                 include 'libraries/dos_lib.i'
  13.                 include 'exec/exec_lib.i'
  14.                 include 'tool.i'
  15.  
  16.                 xref    _DOSBase
  17.  
  18.                 xref    StrCpy
  19.                 xref    InitMemoryChain
  20.                 xref    AllocItem
  21.                 xref    FreeMemoryChain
  22.  
  23.                 xdef    IoErrToStr
  24.                 xdef    OpenDir
  25.                 xdef    GetEntry
  26.                 xdef    CloseDir
  27.                 xdef    FreeDir
  28.  
  29. OpenDir:        movem.l d2-d3/a2-a3/a6,-(sp)
  30.                 move.l  a0,a2
  31.                 move.l  a1,a3
  32.                 NEWLIST a2
  33.                 lea.l   dr_DirMem(a2),a0
  34.                 move.l  #DIRBLOCK,d0
  35.                 bsr     InitMemoryChain
  36.                 lea.l   dr_DirMem(a2),a0
  37.                 move.l  #fib_SIZEOF,d0
  38.                 moveq   #MEMF_PUBLIC,d1
  39.                 bsr     AllocItem
  40.                 move.l  d0,d3
  41.                 move.l  d0,dr_InfoBlock(a2)
  42.                 beq.s   OpenErr
  43.                 move.l  _DOSBase,a6
  44.                 move.l  a3,d1
  45.                 move.l  #ACCESS_READ,d2
  46.                 libcall Lock
  47.                 move.l  d0,dr_Lock(a2)
  48.                 beq.s   OpenErr
  49.                 move.l  d0,d1
  50.                 move.l  d3,d2
  51.                 libcall Examine
  52.                 tst.l   d0
  53.                 beq.s   OpenErr
  54.                 move.l  d3,a0
  55.                 tst.l   fib_DirEntryType(a0)
  56.                 blt.s   OpenErr
  57.                 clr.l   dr_NumEntries(a2)
  58.                 moveq   #1,d0
  59.                 bra.s   EndOD
  60. OpenErr:        lea.l   dr_DirMem(a2),a0
  61.                 bsr     FreeMemoryChain
  62.                 move.l  dr_Lock(a2),d1
  63.                 beq.s   NoLck
  64.                 libcall UnLock
  65. NoLck:          clr.l   dr_Lock(a2)
  66.                 moveq   #0,d0
  67. EndOD:          movem.l (sp)+,d2-d3/a2-a3/a6
  68.                 rts
  69.  
  70. GetEntry:       movem.l d2-d3/a2-a3/a6,-(sp)
  71.                 move.l  a0,a2
  72.                 move.l  dr_InfoBlock(a2),d3
  73.                 move.l  _DOSBase,a6
  74.                 move.l  dr_Lock(a2),d1
  75.                 move.l  d3,d2
  76.                 libcall ExNext
  77.                 beq.s   NoNext
  78.                 lea.l   dr_DirMem(a2),a0
  79.                 move.l  #ei_SIZEOF,d0
  80.                 moveq   #MEMF_PUBLIC,d1
  81.                 bsr     AllocItem
  82.                 move.l  d0,a3
  83.                 beq     NextErr
  84.                 move.l  d3,a0
  85.                 tst.l   fib_DirEntryType(a0)
  86.                 blt.s   IsFile
  87.                 move.w  #ENTRY_DIR,ei_Type(a3)
  88.                 bra.s   HaveType
  89. IsFile:         move.w  #ENTRY_FILE,ei_Type(a3)
  90. HaveType:       move.l  fib_Size(a0),ei_SizeBytes(a3)
  91.                 move.l  fib_NumBlocks(a0),ei_SizeBlocks(a3)
  92.                 move.l  fib_Protection(a0),ei_ProtectionBits(a3)
  93.                 lea.l   fib_FileName(a0),a1
  94.                 lea.l   ei_Name(a3),a0
  95.                 bsr     StrCpy
  96.                 move.l  d3,a0
  97.                 lea.l   fib_DateStamp(a0),a0
  98.                 move.l  ds_Days(a0),ei_Date+ds_Days(a3)
  99.                 move.l  ds_Minute(a0),ei_Date+ds_Minute(a3)
  100.                 move.l  ds_Tick(a0),ei_Date+ds_Tick(a3)
  101.                 inc.l   dr_NumEntries(a2)
  102.                 move.l  a2,a0
  103.                 move.l  a3,a1
  104.                 ADDTAIL
  105.                 move.l  a3,d0
  106.                 bra.s   EndGN
  107. NoNext:         libcall IoErr
  108.                 cmp.l   #ERROR_NO_MORE_ENTRIES,d0
  109.                 bne.s   NextErr
  110.                 move.l  dr_Lock(a2),d1
  111.                 libcall UnLock
  112.                 clr.l   dr_Lock(a2)
  113.                 cldat   d0
  114.                 bra.s   EndGN
  115. NextErr:        move.l  dr_Lock(a2),d1
  116.                 libcall UnLock
  117.                 clr.l   dr_Lock(a2)
  118.                 lea.l   dr_DirMem(a2),a0
  119.                 bsr     FreeMemoryChain
  120.                 cldat   d0
  121. EndGN:          movem.l (sp)+,d2-d3/a2-a3/a6
  122.                 rts
  123.  
  124. CloseDir:       movem.l a2/a6,-(sp)
  125.                 move.l  a0,a2
  126.                 move.l  _DOSBase,a6
  127.                 move.l  dr_Lock(a2),d1
  128.                 beq.s   NoClose
  129.                 libcall UnLock
  130.                 clr.l   dr_Lock(a2)
  131. NoClose:        movem.l (sp)+,a2/a6
  132.                 rts
  133.  
  134. FreeDir:        move.l  a2,-(sp)
  135.                 move.l  a0,a2
  136.                 bsr     CloseDir
  137.                 lea.l   dr_DirMem(a0),a0
  138.                 bsr     FreeMemoryChain
  139.                 NEWLIST a2
  140.                 clr.l   dr_NumEntries(a2)
  141.                 move.l  (sp)+,a2
  142.                 rts
  143.  
  144.  
  145.  
  146. *
  147. * makes a call to "IoErr" and returns a pointer to a string
  148. * which explains the occured error. If IoErr didn't return
  149. * one of the error codes listed below NULL is returned!
  150. *
  151. IoErrToStr:     move.l  a6,-(sp)
  152.                 move.l  _DOSBase,a6
  153.                 libcall IoErr           ; what seem's to be the trouble ?
  154.                 lea.l   ErrTab,a0       ; get the ErrorTable in a0
  155. GetStr:         move.l  (a0)+,d1        ; scan the table for the error
  156.                 blt.s   GotIT           ; end of the table ?
  157.                 cmp.l   d0,d1           ; found the error code ?
  158.                 beq.s   GotIT
  159.                 addq.w  #4,a0           ; increase table pointer
  160.                 bra.s   GetStr          ; loop
  161. GotIT:          move.l  (a0),d0         ; return a pointer to the error string
  162. EndIOE:         move.l  (sp)+,a6
  163.                 rts
  164.  
  165. *
  166. * ASCII versions of the "IoErr" return codes
  167. *
  168. err1:           dc.b    '103: Insufficient free store.',0
  169. err2:           dc.b    '105: Task table full.',0
  170. err3:           dc.b    '120: Argument line invalid or too long.',0
  171. err4:           dc.b    '121: File is not an object module.',0
  172. err5:           dc.b    '122: Invalid resident library during load.',0
  173. err6:           dc.b    '202: Object in use.',0
  174. err7:           dc.b    '203: Object already exists.',0
  175. err8:           dc.b    '204: Directory not found.',0
  176. err9:           dc.b    '205: Object not found.',0
  177. err10:          dc.b    '206: Invalid window.',0
  178. err11:          dc.b    '209: Packet request type unknown.',0
  179. err12:          dc.b    '210: Invalid stream component name.',0
  180. err13:          dc.b    '211: Invalid object lock.',0
  181. err14:          dc.b    '212: Object not of required type.',0
  182. err15:          dc.b    '213: Disk not validated.',0
  183. err16:          dc.b    '214: Disk write protected.',0
  184. err17:          dc.b    '215: Rename across devices attempted.',0
  185. err18:          dc.b    '216: Directory not empty.',0
  186. err19:          dc.b    '218: Device not mounted.',0
  187. err20:          dc.b    '219: Seek error.',0
  188. err21:          dc.b    '220: Comment too big.',0
  189. err22:          dc.b    '221: Disk full.',0
  190. err23:          dc.b    '222: File is protected from deletion.',0
  191. err24:          dc.b    '223: File is protected from writing.',0
  192. err25:          dc.b    '224: File is protected from reading.',0
  193. err26:          dc.b    '225: Not a DOS disk.',0
  194. err27:          dc.b    '226: No disk in drive.',0
  195. err28:          dc.b    '232: No more entries in directory.',0
  196.  
  197.                 even
  198. *
  199. * A table in the form "error_code,pointer_to_error_string,...."
  200. *
  201. ErrTab:         dc.l    103,err1,105,err2,120,err3,121,err4,122,err5
  202.                 dc.l    202,err6,203,err7,204,err8,205,err9,206,err10
  203.                 dc.l    209,err11,210,err12,211,err13,212,err14,213,err15
  204.                 dc.l    214,err16,215,err17,216,err18,218,err19,219,err20
  205.                 dc.l    220,err21,221,err22,222,err23,223,err24,224,err25
  206.                 dc.l    225,err26,226,err27,232,err28,-1,0
  207.  
  208.  
  209.