GUAC-515: Add new RDP setting, create-drive-path, to create the drive.

This commit is contained in:
Daryl Borth 2015-07-28 14:09:38 -07:00 committed by Michael Jumper
parent cf0265ecf7
commit 52084f4f1f
4 changed files with 29 additions and 3 deletions

View File

@ -111,6 +111,7 @@ const char* GUAC_CLIENT_ARGS[] = {
"enable-printing",
"enable-drive",
"drive-path",
"create-drive-path",
"console",
"console-audio",
"server-layout",
@ -158,6 +159,7 @@ enum RDP_ARGS_IDX {
IDX_ENABLE_PRINTING,
IDX_ENABLE_DRIVE,
IDX_DRIVE_PATH,
IDX_CREATE_DRIVE_PATH,
IDX_CONSOLE,
IDX_CONSOLE_AUDIO,
IDX_SERVER_LAYOUT,
@ -303,7 +305,8 @@ BOOL rdp_freerdp_pre_connect(freerdp* instance) {
/* Load filesystem if drive enabled */
if (guac_client_data->settings.drive_enabled) {
guac_client_data->filesystem =
guac_rdp_fs_alloc(client, guac_client_data->settings.drive_path);
guac_rdp_fs_alloc(client, guac_client_data->settings.drive_path,
guac_client_data->settings.create_drive_path);
client->file_handler = guac_rdp_upload_file_handler;
}
@ -773,6 +776,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_client_data->settings.drive_path = strdup(argv[IDX_DRIVE_PATH]);
guac_client_data->settings.create_drive_path =
(strcmp(argv[IDX_CREATE_DRIVE_PATH], "true") == 0);
/* Store client data */
guac_client_data->rdp_inst = rdp_inst;
guac_client_data->mouse_button_mask = 0;

View File

@ -40,7 +40,22 @@
#include <guacamole/object.h>
#include <guacamole/pool.h>
guac_rdp_fs* guac_rdp_fs_alloc(guac_client* client, const char* drive_path) {
guac_rdp_fs* guac_rdp_fs_alloc(guac_client* client, const char* drive_path, int create_drive_path) {
/* Create drive path if it does not exist */
if (create_drive_path) {
guac_client_log(client, GUAC_LOG_DEBUG,
"%s: Creating directory \"%s\".",
__func__, drive_path);
if (mkdir(drive_path, S_IRWXU)) {
if (errno != EEXIST) {
guac_client_log(client, GUAC_LOG_DEBUG,
"%s: mkdir() failed: %s",
__func__, strerror(errno));
}
}
}
guac_rdp_fs* fs = malloc(sizeof(guac_rdp_fs));

View File

@ -325,7 +325,7 @@ typedef struct guac_rdp_fs_info {
/**
* Allocates a new filesystem given a root path.
*/
guac_rdp_fs* guac_rdp_fs_alloc(guac_client* client, const char* drive_path);
guac_rdp_fs* guac_rdp_fs_alloc(guac_client* client, const char* drive_path, int create_drive_path);
/**
* Frees the given filesystem.

View File

@ -155,6 +155,11 @@ typedef struct guac_rdp_settings {
*/
char* drive_path;
/**
* Whether to automatically create the local system path if it does not exist.
*/
int create_drive_path;
/**
* Whether this session is a console session.
*/