Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!cbatt!ucbvax!fstop@trwspf.trw.com@trwrb.UUCP From: fstop@trwspf.trw.com@trwrb.UUCP Newsgroups: mod.computers.vax Subject: Submission for mod-computers-vax Message-ID: <8702232046.AA18845@trwspf.TRW.COM> Date: Mon, 23-Feb-87 15:46:31 EST Article-I.D.: trwspf.8702232046.AA18845 Posted: Mon Feb 23 15:46:31 1987 Date-Received: Thu, 26-Feb-87 21:35:52 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: The ARPA Internet Lines: 72 Approved: info-vax@sri-kl.arpa Path: trwspf!fstop From: fstop@trwspf.UUCP (Howard Siegel) Newsgroups: mod.computers.vax Subject: Determining if a file is a directory file Message-ID: <203@trwspf.UUCP> Date: 23 Feb 87 20:46:28 GMT Reply-To: fstop@trwspf.UUCP (Howard Siegel) Distribution: world Organization: TRW - Data Systems Lab., Redondo Beach, CA Lines: 61 In <8702151754.AA00913@ucbvax.Berkeley.EDU>, ezab066@CHPC.BRC.UTEXAS.EDU ("Albert Wu ", CEM-UT) writes, > Does anyone know if there is a way to distinguish between > 1) a "regular" VMS file that has type DIR, and > 2) a DIR file which corresponds to a subdirectory ? > [...] > Does anybody know of someway perhaps using lexical functions to find out > if a DIR-type file is indeed a subdirectory file ? A directory file name under VMS must have a file type of .DIR and a version number of 1 to be properly recognized. (Try renaming a dir file to version 2 and then do a directory of it... It don't fly!) Beyond that, just looking at the file spec won't help as .DIR;1 is valid for non-dir files. The directory file itself has a different record format than most files on the system, but not a format that is unique to directory files only (you could create a file of the same format with a name containing .DIR;1 but it would not inherently be a directory file.) Doing a DIR/FULL of a directory file will tell you that it is in fact a directory file. NOTE that this only works with VMS V4.x; earlier releases of VMS still had the information embedded in the apropriate data structure, but DIRECTORY would not report them. It would 'seem' obvious then that there must be a bit somewhere in the file system data structures that marks a file as being a directory file. And indeed there is. However it is not in the RMS data structures for the file (since the format of a dir file not unique). This information is available in the ACP data structures for the file. Specifically, you check the FCH$M_DIRECTORY bit in the ATR$C_UCHAR field of the file attributes which is returned when you do a QIO to the disk ACP. Getting this information is not difficult to do in MACRO. I don't know if it can be done directly in recent versions of the higher level languages. To get this information to a command procedure is more difficult though. Unless VMS 4.3 or higher has given you a lexical function do check this (perhaps more items in F$FILE_ATTRIBUTES or some such), under V4.2 and lower the is no built in way to get the information. You could do what DEC has done in some of it's layered product installation command procedures when it wnats to check if a directory exists and is writeable; which is to create a temporary file in the directory and trap any errors that occur should the directory not exist or not be writable. The other solution is to code up a small program to which you feed the name of the directory file. The program does the QIO to the ACP and checks the directory bit and returns the information into a symbol, logical name, or just via the programs final return status (symbol $STATUS) which you can trap on or just check for. If you need the appropriate code fragments (in MACRO) I can send them to you or post them if there is enough interest. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Howard Siegel - TRW Data Systems Laboratory - 213.535.1273 UUCP: ...{ucbvax,ihnp4,decvax}!trwrb!trwspf!fstop ARPA: fstop%trwspf.uucp@brand.usc.edu `This stuff is so warped even I understand it!' - Dr. Johnny Fever, WKRP =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=