(amd_open): Create directory if MU_STREAM_CREAT is given.
Showing
1 changed file
with
12 additions
and
2 deletions
... | @@ -332,8 +332,18 @@ amd_open (mu_mailbox_t mailbox, int flags) | ... | @@ -332,8 +332,18 @@ 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 | return errno; | 335 | { |
336 | 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) | ||
341 | return errno; | ||
342 | } | ||
343 | else | ||
344 | return errno; | ||
345 | } | ||
346 | |||
337 | if (!S_ISDIR (st.st_mode)) | 347 | if (!S_ISDIR (st.st_mode)) |
338 | return EINVAL; | 348 | return EINVAL; |
339 | 349 | ... | ... |
-
Please register or sign in to post a comment