Working directoryIn computing, the working directory of a process is a directory of a hierarchical file system, if any,[nb 1] dynamically associated with the process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd[1] function, or just current directory.[2] When a process refers to a file using a path that is a relative path, such as a path on a Unix-like system that does not begin with a / (forward slash) or a path on Windows that does not begin with a \ (backward slash), the path is interpreted as relative to the process's working directory. So, for example a process on a Unix-like system with working directory /rabbit-shoes that attempts to create the file foo.txt will end up creating the file /rabbit-shoes/foo.txt. In operating systemsIn most computer file systems, every directory has an entry (usually named ".") which points to the directory itself. In most DOS and UNIX command shells, as well as in the Microsoft Windows command line interpreters cmd.exe and Windows PowerShell, the working directory can be changed by using the CD or CHDIR commands. In Unix shells, the pwd command outputs a full pathname of the working directory; the equivalent command in DOS and Windows is CD or CHDIR without arguments (whereas in Unix, cd used without arguments takes the user back to their home directory). The environment variable PWD (in Unix/Linux shells), or the pseudo-environment variables CD (in Windows COMMAND.COM and cmd.exe, but not in OS/2 and DOS), or _CWD, _CWDS, _CWP and _CWPS (under 4DOS, 4OS2, 4NT etc.)[3] can be used in scripts, so that one need not start an external program. Microsoft Windows file shortcuts have the ability to store the working directory. COMMAND.COM in DR-DOS 7.02 and higher provides ECHOS, a variant of the ECHO command omitting the terminating linefeed.[4][3] This can be used to create a temporary batchjob storing the working directory in an environment variable like CD for later use, for example: ECHOS SET CD=> SETCD.BAT CHDIR >> SETCD.BAT CALL SETCD.BAT DEL SETCD.BAT Alternatively, under Multiuser DOS and DR-DOS 7.02 and higher, various internal and external commands support a parameter /B (for "Batch").[5] This modifies the output of commands to become suitable for direct command line input (when redirecting it into a batch file) or usage as a parameter for other commands (using it as input for another command). Where CHDIR would issue a directory path like The working directory is also displayed by the $P[nb 2] token of the Under DOS, the absolute paths of the working directories of all logical volumes are internally stored in an array-like data structure called the Current Directory Structure (CDS), which gets dynamically allocated at boot time to hold the necessary number of slots for all logical drives (or as defined by LASTDRIVE).[7][8][9] This structure imposes a length-limit of 66 characters on the full path of each working directory, and thus implicitly also limits the maximum possible depth of subdirectories.[7] DOS Plus and older issues of DR DOS (up to DR DOS 6.0, with BDOS 6.7 in 1991) had no such limitation[8][10][3] due to their implementation using a DOS emulation on top of a Concurrent DOS- (and thus CP/M-86-)derived kernel, which internally organized subdirectories as relative links to parent directories instead of as absolute paths.[8][10] Since PalmDOS (with BDOS 7.0) and DR DOS 6.0 (1992 update with BDOS 7.1) and higher switched to use a CDS for maximum compatibility with DOS programs as well, they faced the same limitations as present in other DOSes.[8][10] In programming languagesMost programming languages provide an interface to the file system functions of the operating system, including the ability to set (change) the working directory of the program. In the C language, the POSIX function There are similar functions in other languages. For example, in Visual Basic it is usually spelled In Java, the working directory can be obtained through the See also
Notes
References
Further reading
External links
|