From 117e9053f4bcbfb59a1aac969f9a5d681c235e86 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Thu, 1 Aug 2013 13:44:30 -0700 Subject: [PATCH] Pull file type during open. --- src/protocols/rdp/guac_rdpdr/rdpdr_fs.c | 10 ++++++++++ src/protocols/rdp/guac_rdpdr/rdpdr_fs.h | 22 ++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c index 5187ab30..ace0c180 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.c @@ -210,10 +210,19 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path, /* Attempt to pull file information */ if (fstat(fd, &file_stat) == 0) { + + /* Load size and times */ file->size = file_stat.st_size; file->ctime = file_stat.st_ctime; file->mtime = file_stat.st_mtime; file->atime = file_stat.st_atime; + + /* Set type */ + if (S_ISDIR(file_stat.st_mode)) + file->type = GUAC_RDPDR_FS_DIRECTORY; + else + file->type = GUAC_RDPDR_FS_FILE; + } /* If information cannot be retrieved, fake it */ @@ -227,6 +236,7 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path, file->ctime = 0; file->mtime = 0; file->atime = 0; + file->type = GUAC_RDPDR_FS_FILE; } diff --git a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h index b645acf2..a736f219 100644 --- a/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h +++ b/src/protocols/rdp/guac_rdpdr/rdpdr_fs.h @@ -138,11 +138,33 @@ */ #define WINDOWS_TIME(t) ((t - ((uint64_t) 11644473600)) * 10000000) +/** + * Enumeration of all supported file types. + */ +typedef enum guac_rdpdr_fs_file_type { + + /** + * A regular file. + */ + GUAC_RDPDR_FS_FILE, + + /** + * A directory. + */ + GUAC_RDPDR_FS_DIRECTORY + +} guac_rdpdr_fs_file_type; + /** * An arbitrary file on the virtual filesystem of the Guacamole drive. */ typedef struct guac_rdpdr_fs_file { + /** + * The type of this file. + */ + guac_rdpdr_fs_file_type type; + /** * Associated local file descriptor. */