Fix logic in file open (should NOT allocate new ID if open fails.

This commit is contained in:
Michael Jumper 2013-07-29 12:47:08 -07:00
parent c31e3b38ad
commit 4bdbaceccc

View File

@ -55,34 +55,28 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path) {
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
/* If files available, allocate a new file ID */
if (data->open_files < GUAC_RDPDR_FS_MAX_FILES) {
int file_id;
guac_rdpdr_fs_file* file;
/* Get file ID */
int file_id = guac_pool_next_int(data->file_id_pool);
guac_rdpdr_fs_file* file = &(data->files[file_id]);
/* If no files available, return too many open */
if (data->open_files >= GUAC_RDPDR_FS_MAX_FILES)
return -1;
data->open_files++;
/* If path is empty, it refers to the volume itself */
/* If path is empty, the file does not exist */
if (path[0] == '\0')
return -2;
/* Otherwise, parse path */
else {
file->type = GUAC_RDPDR_FS_FILE;
/* STUB */
}
/* Get file ID */
file_id = guac_pool_next_int(data->file_id_pool);
file = &(data->files[file_id]);
data->open_files++;
return file_id;
}
/* Otherwise, no file IDs available */
return -1;
}
void guac_rdpdr_fs_close(guac_rdpdr_device* device, int file_id) {