'\" te .\" Copyright 1989 AT&T. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved. .TH mkdirp 3GEN "14 Oct 2003" "SunOS 5.11" "String Pattern-Matching Library Functions" .SH NAME mkdirp, rmdirp \- create or remove directories in a path .SH SYNOPSIS .LP .nf cc [ \fIflag\fR ... ] \fIfile\fR ... \fB-lgen\fR [ \fIlibrary\fR ... ] #include \fBint\fR \fBmkdirp\fR(\fBconst char *\fR\fIpath\fR, \fBmode_t\fR \fImode\fR); .fi .LP .nf \fBint\fR \fBrmdirp\fR(\fBchar *\fR\fIdir\fR, \fBchar *\fR\fIdir1\fR); .fi .SH DESCRIPTION .sp .LP The \fBmkdirp()\fR function creates all the missing directories in \fIpath\fR with \fImode\fR. See \fBchmod\fR(2) for the values of \fImode\fR. .sp .LP The \fBrmdirp()\fR function removes directories in path \fIdir\fR. This removal begins at the end of the path and moves backward toward the root as far as possible. If an error occurs, the remaining path is stored in \fIdir1\fR. .SH RETURN VALUES .sp .LP If \fIpath\fR already exists or if a needed directory cannot be created, \fBmkdirp()\fR returns \fB\(mi1\fR and sets \fBerrno\fR to one of the error values listed for \fBmkdir\fR(2). It returns zero if all the directories are created. .sp .LP The \fBrmdirp()\fR function returns \fB0\fR if it is able to remove every directory in the path. It returns \fB\(mi2\fR if a ``\fB\&.\fR'' or ``\fB\&..\fR'' is in the path and \fB\(mi3\fR if an attempt is made to remove the current directory. Otherwise it returns \fB\(mi1\fR\&. .SH EXAMPLES .LP \fBExample 1 \fRExample of creating scratch directories. .sp .LP The following example creates scratch directories. .sp .in +2 .nf /* create scratch directories */ if(mkdirp("/tmp/sub1/sub2/sub3", 0755) == \(mi1) { fprintf(stderr, "cannot create directory"); exit(1); } chdir("/tmp/sub1/sub2/sub3"); \&. \&. \&. /* cleanup */ chdir("/tmp"); rmdirp("sub1/sub2/sub3"); .fi .in -2 .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ MT-LevelMT-Safe .TE .SH SEE ALSO .sp .LP \fBchmod\fR(2), \fBmkdir\fR(2), \fBrmdir\fR(2), \fBmalloc\fR(3C), \fBattributes\fR(5) .SH NOTES .sp .LP The \fBmkdirp()\fR function uses \fBmalloc\fR(3C) to allocate temporary space for the string.