From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 26-NOV-1989 21:27
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Re: modifying creation date of a file.

Received: From UCBVAX.BERKELEY.EDU by GIZMO.SRI.COM with TCP; Thu, 23 NOV 89 20:49:57 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.39)
	id AA01089; Thu, 23 Nov 89 20:32:08 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 24 Nov 89 04:27:07 GMT
From: quanta.eng.ohio-state.edu!kcgl1.eng.ohio-state.edu!JONESD@tut.cis.ohio-state.edu  (David Jones)
Organization: Ohio State University
Subject: Re: modifying creation date of a file.
Message-Id: <3593@quanta.eng.ohio-state.edu>
References: <89Oct31.140957est.57700@ugw.utcs.utoronto.ca>, <594@gp.govt.nz>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <89Oct31.140957est.57700@ugw.utcs.utoronto.ca>,
MACEWAN@UTORMED.BITNET (James MacEwan) writes:
> Hi,
> I have a programmer here that would like to change the creation date
> of a particular file to a date about 2 years ago. (the file was created today)
>
> I figure that I could use patch on the directory file that is in the
> next level up, but I cannot find the format of directory files.
>
> this is a one time thing so quick and dirty solutions are happily
> accepted.

The file system provides supported functions for modifying file headers,
there is no need to jeopardize files-11 integrity by patching INDEXF.SYS
directly (trying to locate the header and modify the both the create date
and header checksum is extremely tedious).  Look under the disk driver
chapter in the I/O Users Guide.

Below is a quick-and-dirty program to update the creation date.  It was created
by modifying another q&d program that I used to reset the backup date on
a file.
------------------------------------------------------------------------------
	PROGRAM QUICK_AND_DIRTY
	INTEGER NEW_DATE(2), STATUS, SYS$BINTIM, MODIFY_CREATE_DATE
	CHARACTER FILE*60, TIME*24
C
	TYPE*,'Enter file to update:'
	READ ( 5, 10 ) FILE
10	FORMAT ( A )
	TYPE*,'enter new create date'
	READ ( 5, 10 ) TIME
C
	STATUS = SYS$BINTIM ( TIME(:23), NEW_DATE )
	IF ( .NOT. STATUS ) CALL EXIT ( STATUS )
C
	STATUS = MODIFY_CREATE_DATE ( FILE, 'SYS$DISK:[]', NEW_DATE )
	IF ( .NOT. STATUS ) CALL EXIT ( STATUS )
C
	END
C
        INTEGER FUNCTION MODIFY_CREATE_DATE
	1	( FILE_SPEC, DEFAULT_SPEC, NEW_DATE )
C+
C**         Function MODIFY_CREATE_DATE
C	Locate file and make the creation data something else.
C
C       Input:
C           FILE_SPEC   Character*(*).  File to modify.
C           DEFAULT_SPEC Character*(*).
C	    NEW_DATE	Quadword.  New creation time, in VMS system time
C			format.
C-
	IMPLICIT NONE
        CHARACTER*(*) FILE_SPEC, DEFAULT_SPEC
	INTEGER*4 NEW_DATE(2)
C
	INCLUDE '($ATRDEF)'
        INCLUDE '($FABDEF)'
	INCLUDE '($FIBDEF)'
        INCLUDE '($NAMDEF)'
	INCLUDE '($IODEF)'
C
        INTEGER STATUS, CHANNEL, LENGTH, SYS$ASSIGN
        INTEGER SYS$SEARCH, SYS$PARSE, SYS$QIOW, FIB_DESCRIPTOR(2)
        INTEGER*2 IOSB(4)
	RECORD /ATRDEF/ ATR(3)
        RECORD /FABDEF/ FAB
        RECORD /NAMDEF/ NAM
	RECORD /FIBDEF/ FIB
	BYTE BITE(4)
        CHARACTER ESA*255, RSA*255
C
C       Initialize FAB and NAM blocks we will be using for SYS$PARSE and
C	SYS$SEARCH.
C
        FAB.FAB$B_BID = FAB$C_BID
        FAB.FAB$B_BLN = FAB$C_BLN
        CALL LIB$ANALYZE_SDESC ( FILE_SPEC, BITE, FAB.FAB$L_FNA )
        FAB.FAB$B_FNS = BITE(1)
        CALL LIB$ANALYZE_SDESC ( DEFAULT_SPEC, BITE, FAB.FAB$L_DNA )
        FAB.FAB$B_DNS = BITE(1)
        FAB.FAB$L_FOP = FAB$M_NAM
        FAB.FAB$L_NAM = %LOC ( NAM )
C
        NAM.NAM$B_BID = NAM$C_BID
        NAM.NAM$B_BLN = NAM$C_BLN
        NAM.NAM$B_ESS = -1
        NAM.NAM$L_ESA = %LOC ( ESA )
        NAM.NAM$B_RSS = -1
        NAM.NAM$L_RSA = %LOC ( RSA )
C
C       Use parse and search to find file
C
        STATUS = SYS$PARSE ( FAB )
        IF ( .NOT. STATUS ) GOTO 500
C
        STATUS = SYS$SEARCH ( FAB )
        IF ( .NOT. STATUS ) GOTO 500
C
C       Assign channel to disk specified in NAM block.
C
        LENGTH = ICHAR ( NAM.NAM$T_DVI )
        IF ( LENGTH .EQ. 0 ) THEN
            STATUS = 316
            GOTO 500
        END IF
        STATUS = SYS$ASSIGN ( NAM.NAM$T_DVI(2:LENGTH+1), CHANNEL, , )
        IF ( .NOT. STATUS ) GOTO 500
C
C       Build attribute descriptor for write attributes sub-function that
C	updates the creation date.
C
	ATR(1).ATR$W_SIZE = 8
	ATR(1).ATR$W_TYPE = ATR$C_CREDATE
	ATR(1).ATR$L_ADDR = %LOC ( NEW_DATE )
	ATR(2).ATR$W_SIZE = 0
	ATR(2).ATR$W_TYPE = 0
C
C       Build FIB needed for access operation (just FID needed)
C
	FIB.FIB$L_ACCTL = 			! set flags to permit update
	1	FIB$M_WRITE + FIB$M_NORECORD	! but not change modify date.
	FIB.FIB$W_FID(1) = NAM.NAM$W_FID(1)
	FIB.FIB$W_FID(2) = NAM.NAM$W_FID(2)
	FIB.FIB$W_FID(3) = NAM.NAM$W_FID(3)
	FIB_DESCRIPTOR ( 1 ) = 10 		! length of fib (shortest)
	FIB_DESCRIPTOR ( 2 ) = %LOC ( FIB )	! address of FIB
C
C       Make function call to XQP to modify file attributes.
C
	STATUS = SYS$QIOW ( , %VAL(CHANNEL), %VAL(IO$_MODIFY), IOSB, , ,
	1	FIB_DESCRIPTOR, , , , ATR, )
	IF ( STATUS ) STATUS = IOSB ( 1 )
C
400     CALL SYS$DASSGN ( %VAL(CHANNEL) )
500     MODIFY_CREATE_DATE = STATUS
        RETURN
        END

David L. Jones               |      Phone:    (614) 292-6929
Ohio State Unviversity       |      Internet:
1971 Neil Ave. Rm. 406       |               jonesd@kcgl1.eng.ohio-state.edu
Columbus, OH 43210           |               jones-d@eng.ohio-state.edu

Disclaimer: A repudiation of a claim.

