× 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.



Craig,

Take a look at: http://www.scottklement.com/rpg/ifs_ebook/recurse.html. I think 
you'll need to use the __errno function to get the actual error number.         
                             

Matt

-----Original Message-----
From: craigs@xxxxxxxxx [mailto:craigs@xxxxxxxxx]
Sent: Monday, March 01, 2004 8:18 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: getcwd() error-checking






How do you check for getcwd() errors (get current working directory IFS
procedure)?  In the below code, variable errno is not always the same even
though it is a valid current working directory.  For example, if working
directory from user profile does not exist, the root directory is used and
a different errno is returned.  Both are valid working directories but
errno is nonzero and is different based on root or not.  For my working
directory, errno = 1636341396 and for root = 1627406400.  Is it always
these two error numbers for valid current working directories?  How would I
check for any error if the errno is always nonzero?
Note: I am using getcwd() for cases where a path such as dir/file.ext is
used instead of /dir/file.ext.  Leaving off the '/' means to use the
current working directory.  This is determined by the home directory on the
user profile and if that directory does not exist then '/' (root) is used.
Any ideas?

* Get current working directory
D getcwd          PR              *   ExtProc('getcwd')
D  buf                            *   Value
D  size                         10U 0 Value

D p_CurDirDS      S               *
D CurDirDS        DS                  based(p_CurDirDS)
D  CurDir                      256
D CurDirSize      S             10I 0
D p_errno         S               *
D errno           S             10I 0 Based(p_errno)

  /free
  CurDirSize = %size(CurDirDS);
  p_CurDirDS = %alloc(CurDirSize);
  clear CurDirDS ;
  p_errno = getcwd(p_CurDirDS:%size(CurDirDS));
  dealloc p_CurDirDS;
 /end-free

Craig Strong

_______________________________________________
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...


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.