char * FSgetcwd( char * path, int numbchars );
The FSgetcwd function will get the name of the current working directory and return it to the user. The name will be copied into the buffer pointed to by 'path,' starting at the root directory and copying as many chars as possible before the end of the buffer. The buffer size is indicated by the 'numchars' argument. The first thing this function will do is load the name of the current working directory, if it isn't already present. This could occur if the user switched to the dotdot entry of a subdirectory immediately before calling this function. The function will then copy the current working directory name into the buffer backwards, and insert a backslash character. Next, the function will continuously switch to the previous directories and copy their names backwards into the buffer until it reaches the root. If the buffer overflows, it will be treated as a circular buffer, and data will be copied over existing characters, starting at the beginning. Once the root directory is reached, the text in the buffer will be swapped, so that the buffer contains as much of the current working directory name as possible, starting at the root.
None
Parameters |
Description |
path |
Pointer to the array to return the cwd name in |
numchars |
Number of chars in the path |
Return Values |
Description |
char * |
The cwd name string pointer (path or defaultArray) |
NULL |
The current working directory name could not be loaded. |
The FSerrno variable will be changed
None