H 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  F 	Whenever a file is opened using the VMS C fopen function, it defaults= 	to stream linefeed type.  This can be changed by adding more G 	parameters to the fopen call.  However, suppose file.dat;1 exists with ? 	attributes X1 which may not be stream linefeed (eg, created by F 	FORTRAN).  Now suppose I write a program in C which modifies the dataF 	in file.dat;1 and creates file.dat;2.  The fopen call will create theE 	new version with stream linefeed unless I explicitly give it the new G 	attributes [fopen(file.dat, "w", "rat=...", ...)].  However, suppose I G 	do not know what the attributes of file.dat;1 are.  How can I get this D 	information in VMS C or how do I tell the fopen to use the previous 	version's file attributes?   M Short answer:  You can't.  No interface exists in the VAX C library that lets K you determine the file attributes of an existing file; no method exists for N telling fopen() to give a file "the same attributes" as some existing file, or" as the previous version of a file.  I Longer answer:  It's straightforward using RMS calls - well, as straight- L forward as *anything* using RMS calls :-) - to determine the file attributesD of an existing file.  Then you can create any kind of file you want.  L An alternative to hacking with RMS is to use the callable FDL routines.  TheI only problem then is that you'll have to parse the resulting information, J which was not really intended for "program consumption".  All in all, thisL is approach is probably not a win over just biting the bullet and using RMS.  J The REALLY easy way to do it, I suppose, is to use system() to get COPY toI create a copy of the file (or use callable CONVERT to do the same thing), G the modify the new copy in place.  This approach is neither elegant nor J efficient, and you do have to be careful to truncate the file as required.H (Then again, you could use ANALYZE/FDL and CREATE/FDL to create an emptyK file with the right attributes - or, again, use the callable forms to avoid  creating a subprocess.)   L 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   