From:	CSBVAX::MRGATE!RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP  3-NOV-1988 00:58
To:	ARISIA::EVERHART
Subj:	Getting the date of a file.


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Tue,  1 NOV 88 21:22:45 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Tue, 1 Nov 88 21:15:12 PST
Received: from IRLEARN.BITNET by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 6563; Tue, 01 Nov 88 23:28:10 EST
Received: from ccvax.ucd.ie by IRLEARN.BITNET (Mailer X1.24) with BSMTP id
 6384; Tue, 01 Nov 88 17:39:34 GMT
Date: Tue, 1 Nov 88 16:38 GMT
From: "Tom Wade, Systems" <T_WADE%ccvax.ucd.ie@CUNYVM.CUNY.EDU>
Subject: Getting the date of a file.
To: info-vax@kl.sri.com
X-VMS-To: IN%"info-vax@kl.sri.com"

Someone wanted a routine to return the modification date of a file.  The
following MACRO program is part of a program I wrote some time ago. The
relevant routine is GET_CREATION_DATE. As its name suggests, it returns
the creation date. To get it to return the modification (revision) date
simply change the constant XAB$Q_Cdt to XAB$Q_Rdt et voila. The first
argument to the routine is the file name (passed by descriptor, which is
the default for a string in a sensible language :-)) and the second is
the address of a quadword which gets the time. It is returned in internal
format, so you may need to call the $ASCTIM service to convert it to a
text string. There are some extra routines which you don't need, but you
can simply compile the whole file and link it against your calling program
without modifying it.

Regards.
Tom Wade, Speaker to VAXes
Computer Center, University College Dublin,
Belfield, Dublin 4,
Ireland.
Internet: Tom Wade <t.wade@cc.ucd.ie>
---------------------------------------------------------------
Q: How many feminists does it take to change a light bulb ?
A: THAT'S NOT FUNNY !!!!!
---------------------------------------------------------------

                .Title  NOTICEL_ROUTINES
                .Ident  "2.0"

;******************************************************************************
;   Routines to interface to system services and RMS data structures.
;******************************************************************************

;******************************************************************************
;   Data area for RMS buffers.

Msg_fab:        $FAB -                          ; file access block for
                        Fna = filename, -       ; message file. Used to
                        Fac = get, -            ; calculate date of creation.
                        Org = seq, -
                        Shr = get, -
                        Xab = msg_xab

Msg_xab:        $XABDAT

File_desc:              .Long   0               ; file name descriptor.
Pointer:                .Long   0               ; pointer to string.
Filename:               .Blkb   100

;******************************************************************************
;   Data area for time conversion routines.

Time:                   .Quad   0               ; internal time format.

;******************************************************************************
;   Data area for $GETJPI service call.

Jpi_list:               .Word   4
                        .Word   JPI$_UIC        ; longword UIC.
                        .Address uic
                        .Long   0               ; don't want length.
                        .Long   0               ; list terminator.

Uic:                    .Long   0               ; caller's UIC placed here.

;******************************************************************************
;   Routine to return the creation date of a file. 1st arg is name of the
;   file passed by descriptor. 2nd arg is address of quadword for result.

                .Entry  GET_CREATION_DATE       ^M <>

                Movq    @4(AP), file_desc       ; set up pointer to name.
                Movc3   file_desc, @pointer, filename
                Movb    file_desc, msg_fab+FAB$B_FNS

                $OPEN -                         ; open the file
                        Fab = msg_fab
                Blbc    R0,     oops

                $CLOSE -                        ; and close it again.
                        Fab = msg_fab

                Movq    msg_xab+XAB$Q_CDT, @8(AP); return creation date.
                Ret

Oops:           Clrq    @8(AP)                  ; set date to 0 for error.
                Ret

;******************************************************************************
;   Routine to return the present time in internal format. Value placed
;   in 1st arg (quadword)

                .Entry  GET_TIME        ^M<>

                $GETTIM_S -
                        timadr = time           ; get time now.

                Movq    time,   @4(AP)          ; return to caller's arg.
                Ret

;******************************************************************************
;   Routine to return the caller's UIC in 1st arg (longword).

                .Entry  GET_UIC ^M<>

                $GETJPIW_S -
                        itmlst = jpi_list

                Movl    uic,    @4(AP)
                Ret

;******************************************************************************

                .End

