home *** CD-ROM | disk | FTP | other *** search
- page 58,132
- ;
- ; fstamp.asm
- ; contains: getfstamp(),putfstamp()
- ;
- include model.h
- include prologue.h
- include equ.h
- name fstamp
- pseg getfstam
-
- ;==>-- int getfstamp(td,fname)
- ;
- ;; ARGUMENTS:
- ; (struct TIMEDATE *) td - points to time date structure
- ; (char *) fname - filename
- ;
- ;; DESCRIPTION:
- ; Get time/date stamp of file to structure.
- ;
- ;; RETURNS:
- ; Normally 0, (if no error) returns -1 if dos version is not
- ; 2.0 or above, If file not found returns a DOS error code.
- ; Consult DOS Technical Manual for codes.
- ;
- ;; AUTHOR:
- ; "" 25-MAR-1987 14:34:06.56
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc getfstamp,,getfstam
- mov ah,30h
- int 21h ;get version
- cmp al,0
- jne gef2 ;if can proceed, hop
- mov ax,-1
- jmp short gefexit ;return (error)
- gef2:
- if _LDATA
- push ds
- lds dx,parm3_ ;ds:dx points to filename
- else
- mov dx,parm2_ ;ds:dx points to filename
- endif
- mov ax,3D00h ;function to open file (read)
- int 21h
- if _LDATA
- pop ds
- endif
- jnc gef3 ;if no error on open
- jmp short gefexit
- gef3: mov bx,ax ;bx=file handle
- mov ax,5700h ;get file's date function
- int 21h
- jnc gef4
- push ax
- mov ah,3eh ;close file
- int 21h
- pop ax ;restore error from func 57h
- jmp short gefexit
- gef4:
- if _LDATA
- push ds
- lds si,parm1_ ;ds:si points to timedate structure
- else
- mov si,parm1_ ;ds:si points to timedate structure
- endif ;dx = date, cx=time
- mov ax,cx ; time to AX
- and ax,0000000000011111b ; 2-sec incr, max 31
- shl ax,1 ; x 2 = seconds to nearest 2 secs
- mov [si+seconds],ax
- mov ax,cx
- and ax,0000011111100000b ;mask minutes
- push cx
- mov cl,5
- shr ax,cl
- pop cx
- mov [si+minutes],ax ;store minutes
- mov ax,cx
- and ax,1111100000000000b ;mask hour
- mov cl,11
- shr ax,cl
- mov [si+hours],ax ;time store complete
- mov ax,dx
- and ax,0000000000011111b ;mask day
- mov [si+day],ax
- mov ax,dx
- and ax,0000000111100000b ;mask month
- mov cl,5
- shr ax,cl
- mov [si+month],ax
- mov ax,dx
- and ax,1111111000000000b ;mask year
- mov cl,9
- shr ax,cl
- add ax,1980 ;make year 1980..2099
- mov [si+year],ax
- if _LDATA
- pop ds
- endif
- mov ah,3eh ;close file
- int 21h
- jc gefexit
- xor ax,ax ;success at last
- gefexit:
- cproce
-
- ;==>-- int putfstamp(td,fname)
- ;
- ;; ARGUMENTS:
- ; (struct TIMEDATE *) td - points to time date structure
- ; (char *) fname - filename to change
- ;
- ;; DESCRIPTION:
- ; Set time/date stamp of file from structure.
- ;
- ;; RETURNS:
- ; Normally 0, (if no error) returns -1 if dos version is not
- ; 2.0 or above, If file not found returns a DOS error code.
- ; Consult DOS Technical Manual for codes.
- ;
- ;; AUTHOR:
- ; "" 25-MAR-1987 14:58:08.12
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- cproc putfstamp,,putfstam
- mov ah,30h
- int 21h ;get version
- cmp al,0
- jne pef2 ;if can proceed, hop
- mov ax,-1
- jmp short pefexit ;return (error)
- pef2:
- if _LDATA
- push ds
- lds dx,parm3_ ;ds:dx points to filename
- else
- mov dx,parm2_ ;ds:dx points to filename
- endif
- mov ax,3D00h ;function to open file (read)
- int 21h
- if _LDATA
- pop ds
- endif
- jnc pef3 ;if no error on open
- jmp short pefexit
- pef3: mov bx,ax ;bx=file handle
- if _LDATA
- push ds
- lds si,parm1_ ;ds:si points to timedate structure
- else
- mov si,parm1_ ;ds:si points to timedate structure
- endif ;dx = date, cx=time
- push bx ;save handle
- mov ax,[si+year] ; must be 1980..2099
- sub ax,1980
- mov cl,9
- shl ax,cl
- and ax,1111111000000000b
- mov dx,ax
- mov ax,[si+month]
- mov cl,5
- shl ax,cl
- and ax,0000000111100000b
- or dx,ax
- mov ax,[si+day]
- and ax,0000000000011111b
- or dx,ax ;dx=date
- mov ax,[si+hours] ; hour
- mov cl,11
- shl ax,cl
- and ax,1111100000000000b
- mov bx,ax
- mov ax,[si+minutes] ; minute
- mov cl,5
- shl ax,cl
- and ax,0000011111100000b
- or bx,ax
- mov ax,[si+seconds] ; second
- shr ax,1 ; div by 2
- and ax,0000000000011111b
- or bx,ax
- mov cx,bx ;cx=time
- pop bx ;get file handle back
- if _LDATA
- pop ds ;get ds back
- endif
- mov ax,5701h ;set file's date function
- int 21h
- jnc pef4
- push ax
- mov ah,3eh ;close file
- int 21h
- pop ax ;restore error from func 57h
- jmp short pefexit
- pef4: mov ah,3eh ;close file
- int 21h
- jc pefexit
- xor ax,ax ;success at last
- pefexit:
- cproce
- endps
- end
-