1/* mkdirs.c 2 Create any directories needed for a file name. */ 3 4#include "uucp.h" 5 6#include "uudefs.h" 7#include "sysdep.h" 8#include "system.h" 9 10#include <errno.h> 11 12boolean 13fsysdep_make_dirs (zfile, fpublic) 14 const char *zfile; 15 boolean fpublic; 16{ 17 char *zcopy, *z; 18 int imode; 19 20 zcopy = zbufcpy (zfile); 21 22 if (fpublic) 23 imode = IPUBLIC_DIRECTORY_MODE; 24 else 25 imode = IDIRECTORY_MODE; 26 27 for (z = zcopy; *z != '\0'; z++) 28 { 29 if (*z == '/' && z != zcopy) 30 { 31 /* Some versions of uuto will send a double slash. Some 32 systems will fail to create a directory ending in a 33 slash. */ 34 if (z[-1] == '/') 35 continue; 36 *z = '\0'; 37 if (mkdir (zcopy, imode) != 0) 38 { 39 int ierr; 40 41 ierr = errno; 42 if (ierr != EEXIST 43 && ierr != EISDIR 44#ifdef EROFS 45 && ierr != EROFS 46#endif 47 && (ierr != EACCES || ! fsysdep_directory (zcopy))) 48 { 49 ulog (LOG_ERROR, "mkdir (%s): %s", zcopy, 50 strerror (ierr)); 51 ubuffree (zcopy); 52 return FALSE; 53 } 54 } 55 *z = '/'; 56 } 57 } 58 59 ubuffree (zcopy); 60 61 return TRUE; 62} 63