From: MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 12-MAR-1993 19:07:32.27 To: INFO-VAX@kl.sri.com CC: Subj: RE: vms c file attributes question Whenever a file is opened using the VMS C fopen function, it defaults to stream linefeed type. This can be changed by adding more parameters to the fopen call. However, suppose file.dat;1 exists with attributes X1 which may not be stream linefeed (eg, created by FORTRAN). Now suppose I write a program in C which modifies the data in file.dat;1 and creates file.dat;2. The fopen call will create the new version with stream linefeed unless I explicitly give it the new attributes [fopen(file.dat, "w", "rat=...", ...)]. However, suppose I do not know what the attributes of file.dat;1 are. How can I get this information in VMS C or how do I tell the fopen to use the previous version's file attributes? Short answer: You can't. No interface exists in the VAX C library that lets you determine the file attributes of an existing file; no method exists for telling fopen() to give a file "the same attributes" as some existing file, or as the previous version of a file. Longer answer: It's straightforward using RMS calls - well, as straight- forward as *anything* using RMS calls :-) - to determine the file attributes of an existing file. Then you can create any kind of file you want. An alternative to hacking with RMS is to use the callable FDL routines. The only problem then is that you'll have to parse the resulting information, which was not really intended for "program consumption". All in all, this is approach is probably not a win over just biting the bullet and using RMS. The REALLY easy way to do it, I suppose, is to use system() to get COPY to create a copy of the file (or use callable CONVERT to do the same thing), the modify the new copy in place. This approach is neither elegant nor efficient, and you do have to be careful to truncate the file as required. (Then again, you could use ANALYZE/FDL and CREATE/FDL to create an empty file with the right attributes - or, again, use the callable forms to avoid creating a subprocess.) Me, I'd use RMS. It's not nearly as hard as it's made out to be, and you'll learn how to use an important VMS facility. -- Jerry