HP-UX Reference (11i v1 00/12) - 3 Library Functions A-M (vol 6)

__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man3/!!!intro.3c
________________________________________________________________
___ ___
m
mkdirp(3G) mkdirp(3G)
NAME
mkdirp(), rmdirp() - create, remove directories in a path
SYNOPSIS
#include <libgen.h>
int mkdirp (const char *
path, mode_t mode);
int rmdirp (char *
d, char *d1);
DESCRIPTION
mkdirp creates all the missing directories in the given path with the given mode. [See chmod(2) for the
values of mode.] The protection part of the mode argument is modified by the process’s file creation mask
(see umask(2)).
rmdirp removes directories in path d. This removal starts at the end of the path and moves back toward
the root as far as possible. If an error occurs, the remaining path is stored in d1. rmdirp returns a 0 only
if it is able to remove every directory in the path.
RETURN VALUE
If a needed directory cannot be created, mkdirp returns -1 and sets
errno to one of the mkdir error
numbers. If all the directories are created, or existed to begin with, it returns zero.
APPLICATION USAGE
mkdirp is thread-safe. It is not async-cancel-safe. A cancellation point may occur when a thread is exe-
cuting mkdirp. rmdirp is thread-safe and async-cancel-safe.
EXAMPLES
/ create scratch directories /
if(mkdirp("/tmp/sub1/sub2/sub3", 0755) == -1) {
fprintf(stderr, "cannot create directory");
exit(1);
}
chdir("/tmp/sub1/sub2/sub3");
.
.
.
/ cleanup /
chdir( /tmp");"
rmdirp("sub1/sub2/sub3");
WARNINGS
mkdirp uses malloc to allocate temporary space for the string.
rmdirp returns -2 if a ‘‘ .’’ or ‘‘ ..’’ is in the path and -3 if an attempt is made to remove the current
directory. If an error occurs other than one of the above, -1 is returned.
SEE ALSO
mkdir(2), rmdir(2), umask(2).
Section 3520 1 HP-UX Release 11i: December 2000
___
___