!+ ! NAME ! FILE_UTILS.SCN ! ! DESCRIPTION ! This module contains a series of SCAN file utilities. ! ! RETURN VALUE ! ! HISTORY ! 11/16/88 Bauer Initial version. ! !- MODULE scan$file_utils IDENT 'v1.0'; ! ! Type Declarations ! TYPE ITEM_TYPE : RECORD ctrl : INTEGER, data_ptr : POINTER TO FIXED STRING(100), END RECORD; TYPE ITEM_ARGS_TYPE : RECORD node : ITEM_TYPE, device : ITEM_TYPE, directory : ITEM_TYPE, filename : ITEM_TYPE, extension : ITEM_TYPE, version : ITEM_TYPE, end_flag : INTEGER, END RECORD; ! ! Constant Declarations ! CONSTANT f$scn_node = 2 * 65536; CONSTANT f$scn_device = 3 * 65536; CONSTANT f$scn_directory = 5 * 65536; CONSTANT f$scn_filename = 6 * 65536; CONSTANT f$scn_extension = 7 * 65536; CONSTANT f$scn_version = 8 * 65536; EXTERNAL PROCEDURE sys$filescan (DESCRIPTOR DYNAMIC STRING, REFERENCE ITEM_ARGS_TYPE, REFERENCE INTEGER ) OF INTEGER; !+ ! NAME ! FILESCAN ! ! DESCRIPTION ! This module invokes the SYS$FILESCAN system service to parse a ! passed VAX/VMS file specification. This has been copied from the ! VAX SCAN Language REference Manual V1.0,. pages 14-23, 14-24. ! ! RETURN VALUE ! ! HISTORY ! 11/16/88 Bauer Initial version. ! !- PROCEDURE filescan (what_file : STRING, node : STRING, disk : STRING, directory : STRING, filename : STRING, extension : STRING, version : STRING ); DECLARE args : ITEM_ARGS_TYPE; DECLARE status : INTEGER; args.node.ctrl = f$scn_node; args.device.ctrl = f$scn_device; args.directory.ctrl = f$scn_directory; args.filename.ctrl = f$scn_filename; args.extension.ctrl = f$scn_extension; args.version.ctrl = f$scn_version; args.end_flag = 0; what_file=TRIM(what_file); status = sys$filescan (what_file, args, *); IF (status AND 1) = 0 THEN WRITE '%UTIL-E-FILESCAN, Error return from SYS$FILESCAN call: ', status; RETURN; END IF; disk = args.device.data_ptr->[1..(args.device.ctrl AND 65535)]; directory = args.directory.data_ptr->[1..(args.directory.ctrl AND 65535)]; filename = args.filename.data_ptr->[1..(args.filename.ctrl AND 65535)]; extension = args.extension.data_ptr->[1..(args.extension.ctrl AND 65535)]; version = args.version.data_ptr->[1..(args.version.ctrl AND 65535)]; ! WRITE 'Parsing > ', what_file; ! For debug ! WRITE 'Disk = ', disk; ! WRITE 'Directory = ', directory; ! WRITE 'Filename = ', filename; ! WRITE 'Extension = ', extension; ! WRITE 'Version = ', version; END PROCEDURE; !+ ! NAME ! ! DESCRIPTION ! ! RETURN VALUE ! ! HISTORY ! 10/20/88 Bauer Initial version. ! !- PROCEDURE file_exists (what_file : STRING) OF BOOLEAN; EXTERNAL PROCEDURE lib$find_file( STRING, STRING, INTEGER ) OF BOOLEAN; ! For searching *.EQF EXTERNAL PROCEDURE lib$find_file_end( INTEGER ); DECLARE full_file_name : STRING; ! Used to get full file name from lib$search DECLARE context : INTEGER; ! Used in lib$search IF lib$find_file( what_file, full_file_name, context ) THEN CALL lib$find_file_end( context ); RETURN TRUE; ELSE CALL lib$find_file_end( context ); RETURN FALSE; END IF; END PROCEDURE; END MODULE;