home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Fred Fish Collection 1.5
/
ffcollection-1-5-1992-11.iso
/
ff_disks
/
300-399
/
ff319.lzh
/
CNewsSrc
/
cnews.src.lzh
/
relay
/
mkdirs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-07-09
|
944b
|
50 lines
/*
* mkdirs - make the directories implied by `name'
*/
#include <stdio.h>
#ifndef AMIGA
# include <sys/types.h>
# include <sys/stat.h>
#else
# include <libraries/dos.h>
#endif /* AMIGA */
#include "libc.h"
#include "news.h"
/*
* Given a/b/c/d, try to make any of a, a/b, a/b/c, and a/b/c/d which
* are missing; stop on first failure.
* Returns success.
*/
boolean mkdirs(name, uid, gid)
register char *name;
int uid, gid;
{
register char *cp;
register int isthere = YES;
#ifndef AMIGA
struct stat stbuf;
#else
struct FileLock *lock, *Lock();
#endif /* AMIGA */
for (cp = name; isthere && *cp != '\0'; cp++)
if (*cp == FNDELIM) {
*cp = '\0';
#ifdef AMIGA
if (lock = Lock(name)) UnLock(lock);
else isthere = NO;
#else
isthere = stat(name, &stbuf) >= 0;
#endif /* AMIGA */
if (!isthere) {
isthere = mkdir(name /* , 0777 */) >= 0;
(void) chown(name, uid, gid);
}
*cp = FNDELIM;
}
return isthere;
}