home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / FSTAMP.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  4.4 KB  |  203 lines

  1.         page    58,132
  2. ;
  3. ; fstamp.asm
  4. ; contains: getfstamp(),putfstamp()
  5. ;
  6.         include    model.h
  7.         include    prologue.h
  8.         include equ.h
  9.         name    fstamp
  10.         pseg    getfstam
  11.  
  12. ;==>--    int getfstamp(td,fname)
  13. ;
  14. ;;    ARGUMENTS:
  15. ;      (struct TIMEDATE *)    td    -    points to time date structure
  16. ;      (char *)          fname    -    filename
  17. ;
  18. ;;    DESCRIPTION:
  19. ;      Get time/date stamp of file to structure.
  20. ;
  21. ;;    RETURNS:
  22. ;      Normally 0, (if no error) returns -1 if dos version is not
  23. ;      2.0 or above,  If file not found returns a DOS error code.
  24. ;      Consult DOS Technical Manual for codes.     
  25. ;
  26. ;;    AUTHOR:
  27. ;     ""   25-MAR-1987  14:34:06.56
  28. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  29. ;;;
  30.     cproc    getfstamp,,getfstam
  31.     mov    ah,30h
  32.     int    21h            ;get version
  33.     cmp    al,0
  34.     jne    gef2            ;if can proceed, hop
  35.     mov    ax,-1
  36.     jmp    short gefexit        ;return (error)
  37. gef2:
  38.     if    _LDATA
  39.      push    ds
  40.      lds    dx,parm3_        ;ds:dx points to filename
  41.     else
  42.      mov    dx,parm2_        ;ds:dx points to filename
  43.     endif
  44.     mov    ax,3D00h        ;function to open file (read)
  45.     int    21h
  46.     if    _LDATA
  47.      pop    ds
  48.     endif
  49.     jnc    gef3            ;if no error on open
  50.     jmp    short gefexit
  51. gef3:    mov    bx,ax            ;bx=file handle
  52.     mov    ax,5700h        ;get file's date function
  53.     int    21h
  54.     jnc    gef4
  55.     push    ax
  56.     mov    ah,3eh            ;close file
  57.     int    21h
  58.     pop    ax            ;restore error from func 57h
  59.     jmp    short gefexit
  60. gef4:
  61.     if    _LDATA
  62.      push    ds
  63.      lds    si,parm1_        ;ds:si points to timedate structure
  64.     else
  65.      mov    si,parm1_        ;ds:si points to timedate structure
  66.     endif                ;dx = date, cx=time 
  67.     mov    ax,cx            ; time to AX
  68.     and    ax,0000000000011111b    ; 2-sec incr, max 31
  69.     shl    ax,1            ; x 2 = seconds to nearest 2 secs
  70.     mov    [si+seconds],ax
  71.     mov    ax,cx
  72.     and    ax,0000011111100000b    ;mask minutes
  73.     push    cx
  74.     mov    cl,5
  75.     shr    ax,cl
  76.     pop    cx
  77.     mov    [si+minutes],ax        ;store minutes
  78.     mov    ax,cx
  79.     and    ax,1111100000000000b    ;mask hour
  80.     mov    cl,11
  81.     shr    ax,cl
  82.     mov    [si+hours],ax        ;time store complete
  83.     mov    ax,dx
  84.     and    ax,0000000000011111b    ;mask day
  85.     mov    [si+day],ax
  86.     mov    ax,dx
  87.     and    ax,0000000111100000b    ;mask month
  88.     mov    cl,5
  89.     shr    ax,cl
  90.     mov    [si+month],ax
  91.     mov    ax,dx
  92.     and    ax,1111111000000000b    ;mask year
  93.     mov    cl,9
  94.     shr    ax,cl
  95.     add    ax,1980            ;make year 1980..2099
  96.     mov    [si+year],ax
  97.     if    _LDATA
  98.      pop    ds
  99.     endif
  100.     mov    ah,3eh            ;close file
  101.     int    21h
  102.     jc    gefexit
  103.     xor    ax,ax            ;success at last
  104. gefexit:
  105.     cproce
  106.  
  107. ;==>--    int putfstamp(td,fname)
  108. ;
  109. ;;    ARGUMENTS:
  110. ;      (struct TIMEDATE *)    td    -    points to time date structure
  111. ;      (char *)          fname    -    filename to change
  112. ;
  113. ;;    DESCRIPTION:
  114. ;      Set time/date stamp of file from structure.
  115. ;
  116. ;;    RETURNS:
  117. ;      Normally 0, (if no error) returns -1 if dos version is not
  118. ;      2.0 or above,  If file not found returns a DOS error code.
  119. ;      Consult DOS Technical Manual for codes.     
  120. ;
  121. ;;    AUTHOR:
  122. ;     ""   25-MAR-1987  14:58:08.12
  123. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  124. ;;;
  125.     cproc    putfstamp,,putfstam
  126.     mov    ah,30h
  127.     int    21h            ;get version
  128.     cmp    al,0
  129.     jne    pef2            ;if can proceed, hop
  130.     mov    ax,-1
  131.     jmp    short pefexit        ;return (error)
  132. pef2:
  133.     if    _LDATA
  134.      push    ds
  135.      lds    dx,parm3_        ;ds:dx points to filename
  136.     else
  137.      mov    dx,parm2_        ;ds:dx points to filename
  138.     endif
  139.     mov    ax,3D00h        ;function to open file (read)
  140.     int    21h
  141.     if    _LDATA
  142.      pop    ds
  143.     endif
  144.     jnc    pef3            ;if no error on open
  145.     jmp    short pefexit    
  146. pef3:    mov    bx,ax            ;bx=file handle
  147.     if    _LDATA
  148.      push    ds
  149.      lds    si,parm1_        ;ds:si points to timedate structure
  150.     else
  151.      mov    si,parm1_        ;ds:si points to timedate structure
  152.     endif                ;dx = date, cx=time 
  153.     push    bx            ;save handle
  154.     mov    ax,[si+year]        ; must be 1980..2099
  155.     sub    ax,1980
  156.     mov    cl,9
  157.     shl    ax,cl
  158.     and    ax,1111111000000000b
  159.     mov    dx,ax
  160.     mov    ax,[si+month]
  161.     mov    cl,5
  162.     shl    ax,cl
  163.     and    ax,0000000111100000b
  164.     or    dx,ax
  165.     mov    ax,[si+day]
  166.     and    ax,0000000000011111b
  167.     or    dx,ax            ;dx=date
  168.     mov    ax,[si+hours]        ; hour
  169.     mov    cl,11
  170.     shl    ax,cl
  171.     and    ax,1111100000000000b
  172.     mov    bx,ax
  173.     mov    ax,[si+minutes]        ; minute
  174.     mov    cl,5
  175.     shl    ax,cl
  176.     and    ax,0000011111100000b
  177.     or    bx,ax
  178.     mov    ax,[si+seconds]        ; second
  179.     shr    ax,1            ;  div by 2
  180.     and    ax,0000000000011111b
  181.     or    bx,ax
  182.     mov    cx,bx            ;cx=time
  183.     pop    bx            ;get file handle back
  184.     if    _LDATA
  185.      pop    ds            ;get ds back
  186.     endif
  187.     mov    ax,5701h        ;set file's date function
  188.     int    21h
  189.     jnc    pef4
  190.     push    ax
  191.     mov    ah,3eh            ;close file
  192.     int    21h
  193.     pop    ax            ;restore error from func 57h
  194.     jmp    short pefexit
  195. pef4:    mov    ah,3eh            ;close file
  196.     int    21h
  197.     jc    pefexit
  198.     xor    ax,ax            ;success at last
  199. pefexit:
  200.     cproce
  201.     endps
  202.     end
  203.