Syntax | #include <libgen.h> char *dirname(char *path); | ||||||||||||||
Description |
If path does not contain a slash, | ||||||||||||||
Return val. | pointer to the name of the parent directory If path does contain a slash. pointer to "." string If path does not contain a slash, is a null pointer or points to an empty string. | ||||||||||||||
Example |
The following code fragment reads a pathname, makes the parent directory into the current char path(MAXPATHLEN), *pathcopy; int fd; fgets(path, MAXPATHLEN, stdin); pathcopy = strup(path); chdir(dirname(pathcopy)); fd = open(basename(path), O_RDONLY); | ||||||||||||||
Notes |
| ||||||||||||||
See also |
|