Fix logic in file open (should NOT allocate new ID if open fails.
This commit is contained in:
parent
c31e3b38ad
commit
4bdbaceccc
@ -55,36 +55,30 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path) {
|
|||||||
|
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
||||||
|
|
||||||
/* If files available, allocate a new file ID */
|
int file_id;
|
||||||
if (data->open_files < GUAC_RDPDR_FS_MAX_FILES) {
|
guac_rdpdr_fs_file* file;
|
||||||
|
|
||||||
/* Get file ID */
|
/* If no files available, return too many open */
|
||||||
int file_id = guac_pool_next_int(data->file_id_pool);
|
if (data->open_files >= GUAC_RDPDR_FS_MAX_FILES)
|
||||||
guac_rdpdr_fs_file* file = &(data->files[file_id]);
|
return -1;
|
||||||
|
|
||||||
data->open_files++;
|
/* If path is empty, the file does not exist */
|
||||||
|
|
||||||
/* If path is empty, it refers to the volume itself */
|
|
||||||
if (path[0] == '\0')
|
if (path[0] == '\0')
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
/* Otherwise, parse path */
|
|
||||||
else {
|
|
||||||
|
|
||||||
file->type = GUAC_RDPDR_FS_FILE;
|
file->type = GUAC_RDPDR_FS_FILE;
|
||||||
/* STUB */
|
/* 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;
|
return file_id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, no file IDs available */
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void guac_rdpdr_fs_close(guac_rdpdr_device* device, int file_id) {
|
void guac_rdpdr_fs_close(guac_rdpdr_device* device, int file_id) {
|
||||||
|
|
||||||
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
guac_rdpdr_fs_data* data = (guac_rdpdr_fs_data*) device->data;
|
||||||
|
Loading…
Reference in New Issue
Block a user