The current working directory is a POSIX notion (but also used by ANSI functions, which are often build on top of POSIX) and provides for state that indicates a current file system path respective to which all file and directory operations are reckoned.
The following standard POSIX interfaces consume the current working directory:
The following standard ANSI interfaces consume the current working directory:
The following NovellĀ® additions to POSIX and ANSI interfaces manipulate or use the current working directory:
The Novell additions solve a couple of unique problems when running on the NetWare operating system. In implementing remote NetWare file system access as well as authenticated access to the local file system, LibC natively uses NKS, which uses a path context rather than a current working directory. A path context contains the current working directory, but it also contains additional information such as name space and user identity, which are important to LibC and the NetWare operating system (see Path Context). The setcwd and setcwd2 functions allow you to insert this additional information into the cwd and then continue using ANSI and POSIX functions. LibC transparently uses this additional information when it is needed. For lack of arguments in standard C functions, these problems cannot be solved in an explicit way for ANSI and POSIX functions.
LibC requires two functions for changing and setting the current working directory because a virtual machine can have
A setting for all its threads.
A temporarily and non-destructive setting for a single thread that has established its own current working directory independent of the one in use by the rest of the NKS virtual machine.
The chrdir2 and setcwd2 functions allow you to change or set the current working directory for a single thread, and the chrdir and setcwd functions allow you to change or set the current working directory for all threads in the virtual machine.
The getcwdpath function solves the NetWare full path problem. ANSI and POSIX functions assume that a full path includes just directory names from the root to the target directory. Full NetWare paths can also include the server and the volume name, and getcwdpath retrieves this additional information.
By using NXCreatePathContext, setcwd2, chdir2, and getcwdpath, it is possible to make a round trip from path to current working directory and back, something that would not be possible using only getcwd.