home *** CD-ROM | disk | FTP | other *** search
- /* mkdir: make a new directory
- * written by Eric R. Smith and placed in the public domain
- * modified by Alan Hourihane, to check for directory and return EEXIST.
- */
-
- #include <errno.h>
- #include <limits.h>
- #include <osbind.h>
- #include <mintbind.h>
- #include <stat.h>
- #include "lib.h"
-
- extern int errno;
- extern int __mint;
-
- int mkdir(_path, mode)
- const char *_path;
- unsigned mode;
- {
- struct stat statbuf;
- int rv;
- char path[PATH_MAX];
-
- _unx2dos(_path, path);
-
- rv = stat(path, &statbuf); /* Stat directory */
- if (rv == 0) { /* Does it exist ? */
- errno = EEXIST; /* Yes, so tell user. */
- return -1;
- }
-
- if (errno != ENOENT) { /* Return stat error, if other than */
- return -1; /* File not found. */
- }
-
- rv = Dcreate(path);
- if (rv < 0) {
- errno = -rv;
- return -1;
- }
- if (__mint >= 9) {
- (void)Fchmod(path, mode);
- }
- return 0;
- }
-