#include "chdir-long.h"
#include "unistd--.h"
-#include "xgetcwd.h"
#include "cloexec.h"
#if GNULIB_FCNTL_SAFER
# define GNULIB_FCNTL_SAFER 0
#endif
-/* On systems without the fchdir function (WOE), pretend that open
- always returns -1 so that save_cwd resorts to using xgetcwd.
- Since chdir_long requires fchdir, use chdir instead. */
-#if !HAVE_FCHDIR
-# undef open
-# define open(File, Flags) (-1)
-# undef fchdir
-# define fchdir(Fd) (abort (), -1)
-# undef chdir_long
-# define chdir_long(Dir) chdir (Dir)
-#endif
-
/* Record the location of the current working directory in CWD so that
the program may change to other directories and later use restore_cwd
to return to the recorded location. This function may allocate
The `raison d'etre' for this interface is that the working directory
is sometimes inaccessible, and getcwd is not robust or as efficient.
So, we prefer to use the open/fchdir approach, but fall back on
- getcwd if necessary.
+ getcwd if necessary. This module works for most cases with just
+ the getcwd-lgpl module, but to be truly robust, use the getcwd module.
Some systems lack fchdir altogether: e.g., OS/2, pre-2001 Cygwin,
SCO Xenix. Also, SunOS 4 and Irix 5.3 provide the function, yet it