(amd_open): Create directory if MU_STREAM_CREAT is given.
Showing
1 changed file
with
10 additions
and
0 deletions
... | @@ -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; | ... | ... |
-
Please register or sign in to post a comment