/* 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 #include #include #include #include #include "symdir.h" #include "lib.h" extern int errno; int mkdir(_path, mode) const char *_path; unsigned int mode; { int rv, name_munged; char path[FILENAME_MAX]; /* * _unx2dos indicates whether the name has been modified in some way * in its return value. In this case, we try to create an * automatic symbolic link which gives the "real" name, which is put * in the global variable __link_name[]. */ name_munged = (_unx2dos(_path, path) == _NM_CHANGE); rv = Fattrib(path, 0, 0); /* Get file attributes */ if (rv >= 0) { /* Does it exist ? */ errno = EEXIST; /* Yes, so tell user. */ return -1; } if (rv != -ENOENT) { /* Return stat error, if other than */ errno = -rv; /* File not found. */ return -1; } rv = Dcreate(path); if (rv < 0) { errno = -rv; return -1; } if (name_munged) _make_autolink(path, __link_name); return 0; }