Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-02 - 43,50244/rename.mac
There are 4 other files named rename.mac in the archive. Click here to see a list.
	TITLE	RENAME
	ENTRY	RENAME
;THIS ROUTINE RENAMES AN EXISTING FILE 'OLDNAM.EXT' TO 'NEWNAM.EXT'.
;IF 'OLDNAM.EXT' DOESN'T EXIST RENAME HAS THE FUNCTIONAL VALUE .FALSE.
;OTHERWISE IT IS .TRUE. AND THE FILE IS RENAMED AND GIVEN PROTECTION
;<155>.  THE CALL IS:  VALUE = RENAME('NEWNA','M.EXT','OLDNA','M.EXT')
	ANS=0				;AC'S
	BPT=1
	CTR=2
	TAC=3
	BPT2=4
	CNT=5
	FIL=6
	FEL=7
	CHR=10
	DOT=16				;PERIOD
	PROT=155			;PROTECTION
	D=12				;CHANNEL
	DEFINE	TTYOUT	(ADR)<TTCALL 3,ADR>
	DEFINE 	TTYIN	(ADR)<TTCALL 4,ADR>
RENAME:	0
	MOVSI	1,2
	HRRI	1,ACSAV
	BLT	1,ACSAV+15		;SAVE AC'S
	INIT	D,17
	SIXBIT/DSK/
	0
	JRST	NOTAVL
	SETZM	ANS			;ASSUME IT'S NOT THERE
	MOVE	FIL,@2(16)		;GET OLDNAM.EXT
	MOVE	FEL,@3(16)
	JSR	NAME			;PACK FILENAME IN UFD BLOCK
	LOOKUP	D,UFD			;LOOKUP FILE
	JRST	BACK			;FILE NOT THERE...RETURN
	CLOSE	D,
	SETOM	ANS			;FILE THERE...RENAME IS .TRUE.
	MOVE	FIL,@(16)		;GET NEWNAM.EXT
	MOVE	FEL,@1(16)
	JSR	NAME			;STORE IT
	MOVE	TAC,[EXP<PROT>B8]
	MOVEM	TAC,UFD+2
	RENAME	D,UFD
	0
	CLOSE	D,
BACK:	MOVSI	1,ACSAV
	HRRI	1,2
	BLT	1,17
	JRA	16,(16)			;DONE
NAME:	0				;ROUTINE TO UNPACK NAME.EXT
	MOVE	BPT2,[POINT 7,FIL]	;POINT TO FILENAME
	MOVEI	CNT,12			;ONLY LOOK AT 10 CHARACTERS
	MOVEI	CTR,6			;TO STORE SIX CHARS
	MOVE	BPT,[POINT 6,UFD]
	CLEARM	UFD			;FILENAME
	CLEARM	UFD+1			;EXT
	CLEARM	UFD+2			;PROTECTION
	CLEARM	UFD+3
GETNAM:	ILDB	CHR,BPT2		;READ CHARACTER
	SUBI	CHR,40			;CONVERT TO SIXBIT
	JUMPE	CHR,COUNT		;SKIP BLANKS
	CAIN	CHR,DOT			;TEST FOR PERIOD
	JRST	EXT			;PERIOD--EXT FOLLOWS
	SOSL	CTR			;STORE ONLY LEGAL LIMIT
	IDPB	CHR,BPT			;ALPHANUMERIC--STORE
COUNT:	SOSG	CNT			;DECREMENT CHARACTER COUNTER
	JRST	@NAME			;DONE, GO BACK
	JRST 	GETNAM			;GET NEXT CHARACTER
EXT:	MOVE	BPT,[POINT 6,UFD+1]
	MOVEI	CTR,3			;TO STORE THREE CHARS
	JRST	COUNT			;GO GET EXT
NOTAVL:	TTYOUT	[ASCIZ"DEVICE NOT AVAILABLE"]
	CALLI	12
ACSAV:	BLOCK 17
UFD:	BLOCK 4
	END