2 .\" Copyright 1989 AT&T. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH MKDIRP 3GEN "Oct 14, 2003"
8 mkdirp, rmdirp \- create or remove directories in a path
12 cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ]
15 \fBint\fR \fBmkdirp\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR);
20 \fBint\fR \fBrmdirp\fR(\fBchar *\fR\fIdir\fR, \fBchar *\fR\fIdir1\fR);
26 The \fBmkdirp()\fR function creates all the missing directories in \fIpath\fR
27 with \fImode\fR. See \fBchmod\fR(2) for the values of \fImode\fR.
30 The \fBrmdirp()\fR function removes directories in path \fIdir\fR. This removal
31 begins at the end of the path and moves backward toward the root as far as
32 possible. If an error occurs, the remaining path is stored in \fIdir1\fR.
36 If \fIpath\fR already exists or if a needed directory cannot be created,
37 \fBmkdirp()\fR returns \fB\(mi1\fR and sets \fBerrno\fR to one of the error
38 values listed for \fBmkdir\fR(2). It returns zero if all the directories are
42 The \fBrmdirp()\fR function returns \fB0\fR if it is able to remove every
43 directory in the path. It returns \fB\(mi2\fR if a ``\fB\&.\fR'' or
44 ``\fB\&..\fR'' is in the path and \fB\(mi3\fR if an attempt is made to remove
45 the current directory. Otherwise it returns \fB\(mi1\fR\&.
48 \fBExample 1 \fRExample of creating scratch directories.
51 The following example creates scratch directories.
56 /* create scratch directories */
57 if(mkdirp("/tmp/sub1/sub2/sub3", 0755) == \(mi1) {
58 fprintf(stderr, "cannot create directory");
61 chdir("/tmp/sub1/sub2/sub3");
67 rmdirp("sub1/sub2/sub3");
74 See \fBattributes\fR(5) for descriptions of the following attributes:
82 ATTRIBUTE TYPE ATTRIBUTE VALUE
90 \fBchmod\fR(2), \fBmkdir\fR(2), \fBrmdir\fR(2), \fBmalloc\fR(3C),
95 The \fBmkdirp()\fR function uses \fBmalloc\fR(3C) to allocate temporary space