Commit d164254b d164254b12816149866b076cab4cd10f4a2ba3c4 by Sergey Poznyakoff

(amd_open): Create directory if MU_STREAM_CREAT is given.

1 parent 956a3c65
...@@ -332,7 +332,17 @@ amd_open (mu_mailbox_t mailbox, int flags) ...@@ -332,7 +332,17 @@ amd_open (mu_mailbox_t mailbox, int flags)
332 332
333 mailbox->flags = flags; 333 mailbox->flags = flags;
334 if (stat (amd->name, &st) < 0) 334 if (stat (amd->name, &st) < 0)
335 {
336 if ((flags & MU_STREAM_CREAT) && errno == ENOENT)
337 {
338 if (mkdir (amd->name, S_IRUSR|S_IWUSR|S_IXUSR))
339 return errno;
340 if (stat (amd->name, &st) < 0)
335 return errno; 341 return errno;
342 }
343 else
344 return errno;
345 }
336 346
337 if (!S_ISDIR (st.st_mode)) 347 if (!S_ISDIR (st.st_mode))
338 return EINVAL; 348 return EINVAL;
......