home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / acmautils.lha / AcmaUtils / Source / FileChanged.s < prev    next >
Encoding:
Text File  |  1994-03-05  |  2.3 KB  |  108 lines

  1. ;
  2. ; FileChanged V1.00  Friday 13-Aug-1993
  3. ;
  4. ; by Jan Hagqvist
  5. ;
  6. ; Checks if the file has been altered (archiveflag 'a' clear)
  7. ;
  8. ; V1.00 Friday 13-Aug-1993    Oh, shi(f)t!   !FRI 13 (:o
  9. ;
  10.  
  11.   XREF _LVOOpenLibrary
  12.   XREF _LVOCloseLibrary
  13.   XREF _LVOOpen
  14.   XREF _LVOExamineFH
  15.   XREF _LVOClose
  16.   XREF _LVOIoErr
  17.   XREF _LVOFault
  18.   XREF _LVOVPrintf
  19.   XREF _LVOGetProgramName
  20.  
  21. CheckFile
  22.   clr.b   -1(a0,d0)            ; Null terminate the arg string
  23.   move.l  a0,a4                ; The arg string
  24.   moveq.l #0,d6                ; Clear the return flag
  25.   move.l  4,a6
  26.   cmp.w   #36,20(a6)            ; Is the system V36+?
  27.   bmi.s   Quit2                ; No, so quit and make it fast!
  28.   lea     DosName(pc),a1
  29.   moveq.l #0,d0
  30.   jsr     _LVOOpenLibrary(a6)        ; Open Dos
  31.   tst.l   d0                ; Got it?
  32.   beq.s   Quit2                ; No
  33.  
  34.   move.l d0,a6
  35.   tst.b   (a4)                ; Any args?
  36.   beq.s   About                ; No
  37.   cmp.b   #'?',(a4)            ; Arg='?'
  38.   beq.s   About                ; Yep
  39.  
  40.   move.l  a4,d1
  41.   move.l  #1005,d2
  42.   jsr     _LVOOpen(a6)            ; Open the file
  43.   tst.l   d0                ; Got it?
  44.   beq.s   QuitError            ; No
  45.  
  46.   move.l  d0,d7
  47.   move.l  d0,d1
  48.   move.l  #FIB,d2
  49.   jsr     _LVOExamineFH(a6)        ; Get fileinfo
  50.  
  51.   move.l  d2,a0
  52.   move.l  116(a0),d0            ; Get the protection flags
  53.   btst    #4,d0                ; File changed?
  54.   bne.s   CloseIt            ; No
  55.   moveq.l #5,d6                ; Yep, set return flag to WARN
  56. CloseIt
  57.   move.l  d7,d1
  58.   jsr     _LVOClose(a6)            ; Close the file
  59.  
  60. Quit
  61.   move.l  a6,a1
  62.   move.l  4,a6
  63.   jsr     _LVOCloseLibrary(a6)        ; Close Dos
  64. Quit2
  65.   move.l  d6,d0
  66.   rts
  67.  
  68. QuitError
  69.   jsr     _LVOIoErr(a6)            ; Get the error num
  70.   move.l  d0,d1
  71.   move.l  #ErrorText,d2
  72.   move.l  #FIB,d3
  73.   move.l  #260,d4
  74.   jsr     _LVOFault(a6)            ; Get the error text
  75.   move.l  #FIB,d1
  76.   moveq.l #0,d2
  77.   jsr     _LVOVPrintf(a6)        ; Print it
  78.   move.l  #LineFeed,d1
  79.   moveq.l #0,d2
  80.   jsr     _LVOVPrintf(a6)
  81.   bra.s   Quit
  82.  
  83. About
  84.   move.l  #FIB,d1
  85.   move.l  #260,d2
  86.   jsr     _LVOGetProgramName(a6)
  87.   move.l  #AboutText,d1
  88.   move.l  #AboutArgs,d2
  89.   jsr     _LVOVPrintf(a6)
  90.   bra.s   Quit
  91.  
  92. AboutArgs            dc.l FIB,0
  93.  
  94. DosName                dc.b 'dos.library',0
  95. ErrorText            dc.b 'DOS Error',0
  96. LineFeed            dc.b 10,0
  97. AboutText            dc.b 10,'FileChanged V1.00  Friday 13-Aug-1993',10
  98.                 dc.b 'by Jan Hagqvist',10
  99.                 dc.b 'Made in Finland',10,10
  100.                 dc.b 'Returns WARN if the file has been changed (archiveflag "a" is clear).',10,10
  101.                 dc.b 'USAGE: %s filename',10,10,0
  102.  
  103.   section 2,bss
  104.  
  105. FIB                dcb.b 260,0
  106.  
  107.   END
  108.