11-12-2012 02:42 PM
I am having issue reading files from C-program using RMS call sys$get when RAB buffer size is 32767 bytes and file information report that max record size is 32767 bytes.
For example this file:
$ dir /fu SYS$SYSDEVICE:[SYS0.SYSCOMMON.SYSFONT.DECW.100DPI]
TERMINAL_BOLD36_100DPI.PCF;1 File ID: (594,1,0)
Size: 91/96 Owner: [SYSTEM]
Created: 30-AUG-2007 11:35:01.48
Revised: 30-AUG-2007 11:35:01.49 (1)
File organization: Sequential
Shelved state: Online
Caching attribute: Writethrough
File attributes: Allocation: 96, Extend: 0, Global buffer count: 0
No version limit
Record format: Stream_LF, maximum 0 bytes, longest 32767 bytes
Record attributes: Carriage return carriage control
RMS attributes: None
Journaling enabled: None
File protection: System:RWED, Owner:RWED, Group:RE, World:RE
Access Cntrl List: None
Client attributes: None
Total of 1 file, 91/96 blocks.
When I am reading this file, i am getting error RMS$_RTB and rab$l_stv shows 41070 bytes.
I guess, this and other files with a similar error are just a binary files.
I could try to read them using fopen/fread but I need to know this up-front and before I start reading data; not after sys$get call failed.
Is there is a way to tell if file is really a binary file?
11-13-2012 08:24 AM - edited 11-13-2012 08:25 AM
Take a look at the arguments for F$FILE_ATTRIBUTES. RAT, RFM, and ORG come to mind as options that might help narrow down a file type.
If by binary file you mean an executable image, the file extension (.exe) is a clue, although not a guaranty. Some of the ANALYZE file options might also be useful.
11-13-2012 08:56 AM
I did check all the attributes, but I don't think it will help in all case.
It would be nice if all the files are created with appropriate attributes.
The disturbing thing is, the OS installed files has inconsistent attributes too (SYS$SYSDEVICE:[SYS0.SYSCOMMON.SYSFONT.DECW.100DPI
I am wondering if combination of attribute's values can help.
For example, for above file, the LRL (Longest record length) shows 32767, and MRS (Maximum record size) is 0.
While reading, one of the records is 41070 bytes long (much longer than 32767).
11-13-2012 09:05 AM
11-13-2012 09:34 AM
The file must be created with fixed records attribute in a first place and it is outside by control.
11-13-2012 11:05 AM
RMS record I/O using SYS$GET can only handle a maximum record size of 32767 bytes...as you found out.
Either use Unix I/O functions i.e. open without parameter "rfm=..." or, open the file with RMS specifying UFO in the FAB and access the file with SYS$QIO[W].
Btw, the "Carriage return carriage control" means if RMS ouputs records to a printing device (i.e. terminal) each record should have a CR/LF added. The "Carriage return" is NOT stored in the file.
11-13-2012 11:16 AM - edited 11-13-2012 11:17 AM
>>>The file in question was created by OS installation and based on file information it should use LF as a field separator.