×

Good News Everybody!

The new search engine is LIVE!

Please report any problems to david (at) midrange.com.





I am using the IFS IO API's and am having a problem creating a file in an RPG IV program. I am getting back a -1 in the File Descriptor when using the OPEN.

The system will set errno to tell you what failed. More info about checking errno can be found at the following link:
http://www.scottklement.com/rpg/ifs_ebook/errors.html

My file name is \root\ifsreports\JEFF\corbtch.xls,

problems:

a) The root of the IFS is simply "/" you do not need/want to specify the word "root".

b) You have the slashes backward. You've mistakenly used the Windows-style backslashes (that look like this "\") instead of the Unix-style forward slashes ("/")

Therefore, I think your path should probably look like this:

     /ifsreports/JEFF/corbtch.xls

Also, please make sure that you trim any trailing blanks from the filename before passing it to open(). (That seems to be a common gotcha for people who are new to the IFS... they leave the blanks in and think that they won't matter -- they do, and the file that it creates WILL have the blanks at the end, which makes it very difficult to work with!)

Open_Flag is O_CREAT + O_WRONLY + O_CODEPAGE, Mode_Flag is S_IWUSR + S_IRUSR + S_IRGRP + S_IROTH. Is there any way to determine what it does not like?

That's what errno is for. Though, I'm pretty sure it's the pathname -- but you should NEVER write a program that doesn't give a meaningful error message when something fails. ALWAYS have code that checks errno if open() fails, and tells the user what went wrong.

        fd = open('/blah/blah': O_CREAT+O_WRONLY+O_CODEPAGE
                              : S_IWUSR + S_IRGRP + S_IROTH
                              : 1252 );
        if ( fd = -1 );
           ptrToErrno = syserrno();
           msg = %str(strerror(errno));
           // SHOW MESSAGE TO USER!
        endif;

Seriously, you'll have a lot of headaches down the road if you don't give your users helpful information about the reasons why the APIs fail.


This thread ...

Follow-Ups:
Replies:

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

This mailing list archive is Copyright 1997-2026 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].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.