× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I am trying to create a program to write directly to the IFS. I am using access() to determine the existence of a file in the IFS. But all I get are 'No such path or directory.' and when I try to use pathconf() I get the same.

Are you forgetting to trim trailing blanks off of the filename before calling access()? That's what it sounds like. Unless the files actually do have spaces as part of their names (which _is_ legal in the IFS) you'll want to make sure that you don't have the spaces in teh filename either.

That's the most common reason that someone has this problem. They forget that RPG's character fields are fixed-length (unless defined with VARYING) and that those blanks are added to the end automatically.

The other possibility is that your prototype for access() is wrong. Here's an example of using access():

     D F_OK            C                   0
     D R_OK            C                   4
     D W_OK            C                   2
     D X_OK            C                   1

     D access          PR            10I 0 ExtProc('access')
     D   Path                          *   Value Options(*string)
     D   amode                       10I 0 Value

     D test            s            500A

      /free

          test = '/tmp/scotttest.txt';

          if  access(%trimr(test): F_OK) = 0;
             // file exists.
          endif;

Make sure the %TRIMR is on the _same statement_ as the access() API, otherwise the blanks will simply be added back on. If you need to remove them ahead of time, you have to use a VARYING field (or a constant)


In order to access the directory and the file I have to use WRKLNK rather than WRKFLR. What is the difference between the two? And what routines do I use other than access() and pathconf()?

WRKLNK access the IFS. WRKFLR accesses the old "document library system" (QDLS) rather than the whole IFS.

Pathconf() should work fine as long as the prototype is correct and you're trimming the blanks. Just out of curiosity, what are you going to use it for? I've yet to find a compelling reason to use it.

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

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