tldm-universe/Ardent/UV/APP.PROGS/CREATE.LDIR.B
2024-09-09 17:51:08 -04:00

153 lines
3.9 KiB
Plaintext
Executable File

******************************************************************************
*
* Transaction Logging Routine to Create a Log Directory
*
* Module %M% Version %I% Date %H%
*
* (c) Copyright 1998 Ardent Software Inc. - All Rights Reserved
* This is unpublished proprietary source code of Ardent Software Inc.
* The copyright notice above does not evidence any actual or intended
* publication of such source code.
*
*******************************************************************************
*
* Maintenence log - insert most recent change descriptions at top
*
* Date.... GTAR# WHO Description........................................
* 11/03/98 23924 RGA Create dummy entry for rawdisk.
* 10/14/98 23801 SAP Change copyrights.
* 08/05/96 19000 JC Fix creation of log directory.
* 06/03/96 18426 LA Re-implemented special sys admin option
* 03/25/96 18212 LAG Windows NT port
* 10/21/94 15120 DTM added changes for support of susp/shut inprogress
* 05/15/94 13286 DTM Initial Programming
*
*******************************************************************************
id = "%W%"
*******************************************************************************
$INCLUDE UNIVERSE.INCLUDE MTF.INCL.H
$INCLUDE UNIVERSE.INCLUDE TLOG.H
$INCLUDE UNIVERSE.INCLUDE FILENAMES.H
$INCLUDE UNIVERSE.INCLUDE MACHINE.NAME
* Equate tokens for return values for sysadmin option
EQU LDIR$DIREXISTS TO "0"
EQU LDIR$BADPATH TO "1"
******************
** Windows NT port
**
DEFFUN GET.DIRNAME(FILESPEC) CALLING "*GET.DIRNAME"
**
******************
temp = ""
CALL *ISUSER.B(0, temp)
IF temp = 0 THEN
TPRINT UVREADMSG(071000,"")
SLEEP 3
STOP
END
State =""
RECIO( State, FINFO$AI.STATE, RECIO$FINFO )
IF State = AI$INITIAL OR State = AI$WARM.START OR State = AI$LOGGING OR State = AI$SUSPENDED OR State = AI$SUSP.PROG OR State = AI$SHUT.PROG THEN
PRINT "Cannot Create Logging Directory... Logging must be SHUTDOWN"
STOP
END
IF State = AI$FULL THEN
Cpt = ""
RECIO( Cpt, FINFO$AI.CHECKPOINT, RECIO$FINFO )
IF Cpt = 1 THEN
PRINT "Cannot Create Logging Directory... Logging must be SHUTDOWN"
STOP
END
END
File.Name = FIELD( @SENTENCE, " ", 2 ) ;* get file name from command line
Option = FIELD( @SENTENCE, " ", 3 ) ;* see if we are from SysAdm
IF Option = "" THEN
Option = 0
END
;* First, open file
OPEN "DICT", LOGS.FILE to Log.File ELSE ;* open D_UV_LOGS files
PRINT ERR.OPEN.D
STOP
END
;* Second, make sure we can create the directory
******************
** Windows NT port
**
IF OS.TYPE NE "UNIX" THEN
File.Name = CONVERT("/", "\", File.Name)
END
**
******************
Exec.uvfile = OS.EXEC:" '":UV.BIN:"/UVfile ":File.Name:"'"
Exec.mkdir = OS.EXEC:" '":"mkdir ":File.Name:"'"
;* Make sure it does not already exist
EXECUTE Exec.uvfile CAPTURING trashcan
IF INDEX(trashcan, ": directory", 1) THEN
IF Option = 0 THEN
PRINT ERR.DIR:File.Name:")"
PRINT "File already exists"
END ELSE ;* called from sysadmin
PRINT LDIR$DIREXISTS
END
GOTO EXIT
END
;* Try and create the directory
EXECUTE Exec.mkdir CAPTURING trashcan
;* See if it exists
EXECUTE Exec.uvfile CAPTURING trashcan
IF NOT(INDEX(trashcan, ": directory", 1)) THEN
IF Option = 0 THEN
PRINT ERR.DIR:File.Name:")"
path = GET.DIRNAME(File.Name)
PRINT "Path (":path:") not found"
END ELSE ;* called from sysadmin
PRINT LDIR$BADPATH
END
GOTO EXIT
END
REC = "" ;* initialize dynamic array
REC<1> = "X"
REC<2> = File.Name
;* Ok, now update record
WRITE REC ON Log.File, LOGS.DIR ELSE
PRINT ERR.WRITE.D
GOTO EXIT
END
;* Create a dummy entry for rawdisk
REC = "" ;* initialize dynamic array
REC<1> = "X"
REC<2> = ""
;* Ok, now update record
WRITE REC ON Log.File, LOGS.RAWDIR ELSE
PRINT ERR.WRITE.D
GOTO EXIT
END
EXIT:
CLOSE Log.File
END