Fix directory creation.

This commit is contained in:
Michael Jumper 2013-10-25 12:43:57 -07:00
parent dfd55f0ba4
commit b5af07aee2
2 changed files with 13 additions and 1 deletions

View File

@ -257,11 +257,16 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path,
} }
/* Create directory first, if necessary */ /* Create directory first, if necessary */
if (file_attributes & FILE_ATTRIBUTE_DIRECTORY && (flags & O_CREAT)) { if ((create_options & FILE_DIRECTORY_FILE) && (flags & O_CREAT)) {
if (mkdir(real_path, S_IRWXU)) { if (mkdir(real_path, S_IRWXU)) {
GUAC_RDP_DEBUG(1, "mkdir() failed: %s", strerror(errno)); GUAC_RDP_DEBUG(1, "mkdir() failed: %s", strerror(errno));
return guac_rdpdr_fs_get_errorcode(errno); return guac_rdpdr_fs_get_errorcode(errno);
} }
/* Unset O_CREAT and O_EXCL as directory must exist before open() */
flags &= ~(O_CREAT | O_EXCL);
} }
/* Open file */ /* Open file */

View File

@ -175,6 +175,13 @@
#define FILE_UNICODE_ON_DISK 0x00000004 #define FILE_UNICODE_ON_DISK 0x00000004
/*
* File create options.
*/
#define FILE_DIRECTORY_FILE 0x00000001
#define FILE_NON_DIRECTORY_FILE 0x00000040
#define SEC_TO_UNIX_EPOCH 11644473600 #define SEC_TO_UNIX_EPOCH 11644473600
/** /**