Implement deletion.

This commit is contained in:
Michael Jumper 2013-11-04 16:37:29 -08:00
parent 9d85704f03
commit 52e65e043a
3 changed files with 42 additions and 3 deletions

View File

@ -191,9 +191,24 @@ void guac_rdpdr_fs_process_set_allocation_info(guac_rdpdr_device* device,
void guac_rdpdr_fs_process_set_disposition_info(guac_rdpdr_device* device, void guac_rdpdr_fs_process_set_disposition_info(guac_rdpdr_device* device,
wStream* input_stream, int file_id, int completion_id, int length) { wStream* input_stream, int file_id, int completion_id, int length) {
/* STUB */
guac_client_log_error(device->rdpdr->client, wStream* output_stream;
"Unimplemented stub: %s", __func__);
/* Delete file */
int result = guac_rdp_fs_delete((guac_rdp_fs*) device->data, file_id);
if (result < 0)
output_stream = guac_rdpdr_new_io_completion(device,
completion_id, guac_rdp_fs_get_status(result), 4);
else
output_stream = guac_rdpdr_new_io_completion(device,
completion_id, STATUS_SUCCESS, 4);
Stream_Write_UINT32(output_stream, length);
svc_plugin_send((rdpSvcPlugin*) device->rdpdr, output_stream);
GUAC_RDP_DEBUG(2, "Sent STATUS_SUCCESS for completion_id=%i",
completion_id);
} }
void guac_rdpdr_fs_process_set_end_of_file_info(guac_rdpdr_device* device, void guac_rdpdr_fs_process_set_end_of_file_info(guac_rdpdr_device* device,

View File

@ -410,6 +410,25 @@ int guac_rdp_fs_rename(guac_rdp_fs* fs, int file_id,
} }
int guac_rdp_fs_delete(guac_rdp_fs* fs, int file_id) {
/* Get file */
guac_rdp_fs_file* file = guac_rdp_fs_get_file(fs, file_id);
if (file == NULL) {
GUAC_RDP_DEBUG(1, "Delete of bad file_id: %i", file_id);
return GUAC_RDP_FS_EINVAL;
}
/* Attempt deletion */
if (unlink(file->real_path)) {
GUAC_RDP_DEBUG(1, "unlink() failed: \"%s\"", file->real_path);
return guac_rdp_fs_get_errorcode(errno);
}
return 0;
}
void guac_rdp_fs_close(guac_rdp_fs* fs, int file_id) { void guac_rdp_fs_close(guac_rdp_fs* fs, int file_id) {
guac_rdp_fs_file* file = guac_rdp_fs_get_file(fs, file_id); guac_rdp_fs_file* file = guac_rdp_fs_get_file(fs, file_id);

View File

@ -341,6 +341,11 @@ int guac_rdp_fs_write(guac_rdp_fs* fs, int file_id, int offset,
int guac_rdp_fs_rename(guac_rdp_fs* fs, int file_id, int guac_rdp_fs_rename(guac_rdp_fs* fs, int file_id,
const char* new_path); const char* new_path);
/**
* Deletes the gile with the given ID.
*/
int guac_rdp_fs_delete(guac_rdp_fs* fs, int file_id);
/** /**
* Frees the given file ID, allowing future open operations to reuse it. * Frees the given file ID, allowing future open operations to reuse it.
*/ */