Add error codes for open.
This commit is contained in:
parent
f3ef451527
commit
f24d4b58fa
@ -60,11 +60,11 @@ int guac_rdpdr_fs_open(guac_rdpdr_device* device, const char* path) {
|
||||
|
||||
/* If no files available, return too many open */
|
||||
if (data->open_files >= GUAC_RDPDR_FS_MAX_FILES)
|
||||
return -1;
|
||||
return GUAC_RDPDR_FS_ENFILE;
|
||||
|
||||
/* If path is empty, the file does not exist */
|
||||
if (path[0] == '\0')
|
||||
return -2;
|
||||
return GUAC_RDPDR_FS_ENOENT;
|
||||
|
||||
file->type = GUAC_RDPDR_FS_FILE;
|
||||
/* STUB */
|
||||
|
@ -60,6 +60,16 @@
|
||||
*/
|
||||
#define GUAC_RDPDR_FS_MAX_FILES 128
|
||||
|
||||
/**
|
||||
* Error code returned when no more file IDs can be allocated.
|
||||
*/
|
||||
#define GUAC_RDPDR_FS_ENFILE -1
|
||||
|
||||
/**
|
||||
* Error code returned with no such file exists.
|
||||
*/
|
||||
#define GUAC_RDPDR_FS_ENOENT -2
|
||||
|
||||
/*
|
||||
* Information constants.
|
||||
*/
|
||||
|
@ -89,19 +89,23 @@ void guac_rdpdr_fs_process_create(guac_rdpdr_device* device,
|
||||
Stream_Write_UINT32(output_stream, completion_id);
|
||||
|
||||
/* If no file IDs available, notify server */
|
||||
if (file_id == -1) {
|
||||
if (file_id == GUAC_RDPDR_FS_ENFILE) {
|
||||
guac_client_log_error(device->rdpdr->client, "File open refused - too many open files");
|
||||
Stream_Write_UINT32(output_stream, STATUS_TOO_MANY_OPENED_FILES);
|
||||
Stream_Write_UINT32(output_stream, 0); /* fileId */
|
||||
Stream_Write_UINT8(output_stream, 0); /* information */
|
||||
}
|
||||
else if (file_id == -2) {
|
||||
|
||||
/* If file does not exist, notify server */
|
||||
else if (file_id == GUAC_RDPDR_FS_ENOENT) {
|
||||
guac_client_log_error(device->rdpdr->client,
|
||||
"File open refused - does not exist: \"%s\"", path);
|
||||
Stream_Write_UINT32(output_stream, STATUS_NO_SUCH_FILE);
|
||||
Stream_Write_UINT32(output_stream, 0); /* fileId */
|
||||
Stream_Write_UINT8(output_stream, 0); /* information */
|
||||
}
|
||||
|
||||
/* Otherwise, open succeeded */
|
||||
else {
|
||||
|
||||
guac_client_log_info(device->rdpdr->client, "Opened file \"%s\" ... new id=%i", path, file_id);
|
||||
|
Loading…
Reference in New Issue
Block a user