On 22/03/2005, at 8:53 AM, Stephen More wrote:

I have not gotten it to work yet, but I think I may have found the answer:

http://www-1.ibm.com/servers/enable/site/porting/iseries/overview/ faq_files.html

In ILE, when I tried fopen(), fclose(), etc. on IFS stream files in
QOpenSys they do not seem to work, but the low level calls do not have
any problems. Is there any difference in these two types of calls?

Yes. The two types of calls are different in the ILE environment. The
calls like fopen(), fclose(), fread() work on the database files
whereas low-level calls like open(), close(), read() work on the
stream files. The low level calls can work on the database files by
specifying the full qualified name (i.e. /qsys.lib/< library>.lib/<
file>.file/< mbr>.mbr). Calls like fopen(), fclose, and fread() can
also work on the stream files in QOpenSys if *IFSIO is specified for
"System Interface Option" on CRTCMOD command. Once the program is
created with *IFSIO option absolute or relative path names can be
specified with fopen(), fclose() etc calls. However, after specifying
*IFSIO these call will not work on the native database file system
even if fully qualified path name is specified.

This is normal behaviour and is described in the C Programmers Guide.

The default behaviour of the fopen(), fread(), etc. functions is to map C stream file concepts over OS/400 record files. This is done for historical reasons because stream files did not exist in OS/400 when C was first released on OS/400. This actually has very limited use because most OS/400 data files are database files with a record oriented structure.

If you need to process stream files and database files in the same program then you have a few approaches:
1) Put stream file functions in one module and compile with SYSIFCOPT(*IFSIO). Put the non-stream file functions in a different module and compile normally. Bind both modules into the same program.
2) Use the Unix stream file functions (open, read, write, close) for stream file processing and reserve fopen() etc. for non-stream file processing. You can mix them both in the same program.
3) Use SYSIFCOPT(*IFSIO) for stream file processing and use the record I/O functions (i.e., those that start with _R like _Ropen()) for database access. These are more like traditional OS/400 database functions anyway and support all the normal things like sequential read and write, keyed reads, record positioning, record updates, and keyed deletes.


I've not done it but I think you can use the Unix stream file functions to process flat files in QSYS.LIB file system.

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists

   http://www.flybynight.com.au/
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\
   Fax:   +61 3 9419 0175                                   \ /
                                                             X
                 ASCII Ribbon campaign against HTML E-Mail  / \
--------------------------------------------------------------------



This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].