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






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


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

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.