diff options
-rw-r--r-- | src/util/disk.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/util/disk.c b/src/util/disk.c index 31e8f12c6..e0227be70 100644 --- a/src/util/disk.c +++ b/src/util/disk.c | |||
@@ -830,6 +830,12 @@ GNUNET_DISK_directory_create_for_file (const char *filename) | |||
830 | errno = EINVAL; | 830 | errno = EINVAL; |
831 | return GNUNET_SYSERR; | 831 | return GNUNET_SYSERR; |
832 | } | 832 | } |
833 | if (0 == ACCESS (rdir, W_OK)) | ||
834 | { | ||
835 | GNUNET_free (rdir); | ||
836 | return GNUNET_OK; | ||
837 | } | ||
838 | |||
833 | len = strlen (rdir); | 839 | len = strlen (rdir); |
834 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) | 840 | while ((len > 0) && (rdir[len] != DIR_SEPARATOR)) |
835 | len--; | 841 | len--; |
@@ -1686,16 +1692,19 @@ GNUNET_DISK_file_open (const char *fn, | |||
1686 | return NULL; | 1692 | return NULL; |
1687 | } | 1693 | } |
1688 | if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS) | 1694 | if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS) |
1689 | oflags |= (O_CREAT | O_EXCL); | 1695 | oflags |= (O_CREAT | O_EXCL); |
1690 | if (flags & GNUNET_DISK_OPEN_TRUNCATE) | 1696 | if (flags & GNUNET_DISK_OPEN_TRUNCATE) |
1691 | oflags |= O_TRUNC; | 1697 | oflags |= O_TRUNC; |
1692 | if (flags & GNUNET_DISK_OPEN_APPEND) | 1698 | if (flags & GNUNET_DISK_OPEN_APPEND) |
1693 | oflags |= O_APPEND; | 1699 | oflags |= O_APPEND; |
1694 | if (flags & GNUNET_DISK_OPEN_CREATE) | 1700 | if(GNUNET_NO == GNUNET_DISK_file_test(fn)) |
1695 | { | 1701 | { |
1696 | (void) GNUNET_DISK_directory_create_for_file (expfn); | 1702 | if (flags & GNUNET_DISK_OPEN_CREATE ) |
1697 | oflags |= O_CREAT; | 1703 | { |
1698 | mode = translate_unix_perms (perm); | 1704 | (void) GNUNET_DISK_directory_create_for_file (expfn); |
1705 | oflags |= O_CREAT; | ||
1706 | mode = translate_unix_perms (perm); | ||
1707 | } | ||
1699 | } | 1708 | } |
1700 | 1709 | ||
1701 | fd = open (expfn, oflags | 1710 | fd = open (expfn, oflags |