fix err handling to contain correct operation
This commit is contained in:
parent
887f89748c
commit
9413ca2e62
|
@ -19,80 +19,46 @@
|
|||
// pretty insane - so handle non-errors in switches and otherwise pass to
|
||||
// this tio handle the reast in a generic way.
|
||||
static void
|
||||
_error_handle(const char *src, const char *dst, int errno_in)
|
||||
_error_handle(const char *src, const char *dst, const char *op, int errno_in)
|
||||
{
|
||||
// XXX: Fix str to be Move, Copy or Delete as it can handle any
|
||||
Eina_Strbuf *buf = eina_strbuf_new();
|
||||
|
||||
if (!buf) abort();
|
||||
eina_strbuf_append(buf, op);
|
||||
eina_strbuf_append(buf, ": ");
|
||||
#define HNDL(_err, _str) \
|
||||
_err: \
|
||||
eina_strbuf_append(buf, _str); \
|
||||
status_error(src, dst, eina_strbuf_string_get(buf)); \
|
||||
break
|
||||
switch (errno_in)
|
||||
{
|
||||
case EACCES:
|
||||
status_error(src, dst, "Move - Access denied");
|
||||
return;
|
||||
case EFAULT:
|
||||
status_error(src, dst, "Move - Memory Fault");
|
||||
return;
|
||||
case ELOOP:
|
||||
status_error(src, dst, "Move - Too many symlinks");
|
||||
return;
|
||||
case ENAMETOOLONG:
|
||||
status_error(src, dst, "Move - Name too long");
|
||||
return;
|
||||
case ENOMEM:
|
||||
status_error(src, dst, "Move - Out of memory");
|
||||
return;
|
||||
case ENOTDIR:
|
||||
status_error(src, dst, "Move - Path component is not a directory");
|
||||
return;
|
||||
case EOVERFLOW:
|
||||
status_error(src, dst, "Move - Overflow");
|
||||
return;
|
||||
case EDQUOT:
|
||||
status_error(src, dst, "Move - Over quota");
|
||||
return;
|
||||
case EINVAL:
|
||||
status_error(src, dst, "Move - Inmvalid value");
|
||||
return;
|
||||
case EMLINK:
|
||||
status_error(src, dst, "Move - Too many source links");
|
||||
return;
|
||||
case ENOENT:
|
||||
status_error(src, dst, "Move - File does not exist");
|
||||
return;
|
||||
case ENOSPC:
|
||||
status_error(src, dst, "Move - Disk full");
|
||||
return;
|
||||
case EPERM:
|
||||
status_error(src, dst, "Move - Permission denied");
|
||||
return;
|
||||
case EROFS:
|
||||
status_error(src, dst, "Move - Read only filesystem");
|
||||
return;
|
||||
case EBADF:
|
||||
status_error(src, dst, "Move - Bad file descriptor");
|
||||
return;
|
||||
case EIO:
|
||||
status_error(src, dst, "Move - I/O error");
|
||||
return;
|
||||
case EISDIR:
|
||||
status_error(src, dst, "Move - Destination is dir");
|
||||
return;
|
||||
case EFBIG:
|
||||
status_error(src, dst, "Move - File too big");
|
||||
return;
|
||||
case ETXTBSY:
|
||||
status_error(src, dst, "Move - Text file busy");
|
||||
return;
|
||||
case EBUSY:
|
||||
status_error(src, dst, "Move - File busy");
|
||||
return;
|
||||
case ENOTEMPTY:
|
||||
status_error(src, dst, "Move - Destination not empty");
|
||||
return;
|
||||
case EEXIST:
|
||||
status_error(src, dst, "Move - File exists");
|
||||
return;
|
||||
default: // WAT? we should not get here - we handled everything...
|
||||
status_error(src, dst, "Move - Unknown error");
|
||||
break;
|
||||
HNDL(case EACCES, "Access denied");
|
||||
HNDL(case EFAULT, "Memory Fault");
|
||||
HNDL(case ELOOP, "Too many symlinks");
|
||||
HNDL(case ENAMETOOLONG, "Name too long");
|
||||
HNDL(case ENOMEM, "Out of memory");
|
||||
HNDL(case ENOTDIR, "Path component is not a directory");
|
||||
HNDL(case EOVERFLOW, "Overflow");
|
||||
HNDL(case EDQUOT, "Over quota");
|
||||
HNDL(case EINVAL, "Invalid value");
|
||||
HNDL(case EMLINK, "Too many links");
|
||||
HNDL(case ENOENT, "Does not exist");
|
||||
HNDL(case ENOSPC, "Disk full");
|
||||
HNDL(case EPERM, "Permission denied");
|
||||
HNDL(case EROFS, "Read only filesystem");
|
||||
HNDL(case EBADF, "Bad file descriptor");
|
||||
HNDL(case EIO, "I/O error");
|
||||
HNDL(case EISDIR, "Destination is a directory");
|
||||
HNDL(case EFBIG, "File too big");
|
||||
HNDL(case ETXTBSY, "Text file busy");
|
||||
HNDL(case EBUSY, "File busy");
|
||||
HNDL(case ENOTEMPTY, "Destination is not empty");
|
||||
HNDL(case EEXIST, "File exists");
|
||||
HNDL(default, "Unknown error");
|
||||
}
|
||||
eina_strbuf_free(buf);
|
||||
}
|
||||
|
||||
// this scans a tree to build a potential operation progress count. it may
|
||||
|
@ -106,6 +72,7 @@ fs_scan(const char *src)
|
|||
Eina_Iterator *it;
|
||||
const char *s;
|
||||
struct stat st;
|
||||
const char *op = "Scan";
|
||||
|
||||
if (strlen(src) < 1) return EINA_FALSE;
|
||||
|
||||
|
@ -116,7 +83,7 @@ fs_scan(const char *src)
|
|||
case ENOENT: // ignore this error - file removed during scan ?
|
||||
return EINA_TRUE;
|
||||
default:
|
||||
_error_handle(src, NULL, errno);
|
||||
_error_handle(src, NULL, op, errno);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -157,14 +124,17 @@ fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err, Eina_Bool cp,
|
|||
struct stat st;
|
||||
mode_t old_umask;
|
||||
struct timeval times[2];
|
||||
const char *op = "";
|
||||
|
||||
if (strlen(src) < 1) return EINA_FALSE;
|
||||
|
||||
// first count how much work needs doing
|
||||
if (!fs_scan(src)) return EINA_FALSE;
|
||||
|
||||
fprintf(stderr, "cp_rm [%s] -> [%s]\n", src, dst);
|
||||
fflush(stderr);
|
||||
if (rm && cp) op = "Move";
|
||||
else if (!rm && cp) op = "Copy";
|
||||
else if (rm && !cp) op = "Delete";
|
||||
|
||||
if (lstat(src, &st) != 0)
|
||||
{
|
||||
switch (errno)
|
||||
|
@ -173,7 +143,7 @@ fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err, Eina_Bool cp,
|
|||
status_pos(1, "Move - File vanished");
|
||||
break;
|
||||
default:
|
||||
_error_handle(src, dst, errno);
|
||||
_error_handle(src, dst, op, errno);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -189,7 +159,7 @@ fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err, Eina_Bool cp,
|
|||
case EEXIST: // ignore - mv would mv over this anyway
|
||||
break;
|
||||
default: // WAT
|
||||
_error_handle(NULL, dst, errno);
|
||||
_error_handle(NULL, dst, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err;
|
||||
}
|
||||
|
@ -229,7 +199,7 @@ fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err, Eina_Bool cp,
|
|||
case ENOENT: // ignore missing
|
||||
break;
|
||||
default:
|
||||
_error_handle(src, NULL, errno);
|
||||
_error_handle(src, NULL, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err;
|
||||
}
|
||||
|
@ -259,7 +229,7 @@ fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err, Eina_Bool cp,
|
|||
status_pos(1, "Move - File vanished");
|
||||
break;
|
||||
default:
|
||||
_error_handle(src, dst, errno);
|
||||
_error_handle(src, dst, op, errno);
|
||||
return EINA_FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +303,7 @@ again_read:
|
|||
case EINTR:
|
||||
goto again_read;
|
||||
default:
|
||||
_error_handle(src, NULL, errno);
|
||||
_error_handle(src, NULL, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err_copy;
|
||||
}
|
||||
|
@ -351,7 +321,7 @@ again_write:
|
|||
case EINTR:
|
||||
goto again_write;
|
||||
default:
|
||||
_error_handle(NULL, dst, errno);
|
||||
_error_handle(NULL, dst, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err_copy;
|
||||
}
|
||||
|
@ -377,7 +347,7 @@ again_write:
|
|||
break;
|
||||
case EBADF:
|
||||
default: // WAT
|
||||
_error_handle(src, dst, errno);
|
||||
_error_handle(src, dst, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err_copy;
|
||||
}
|
||||
|
@ -400,7 +370,7 @@ err_copy:
|
|||
case ENOENT: // ignore missing
|
||||
break;
|
||||
default:
|
||||
_error_handle(src, NULL, errno);
|
||||
_error_handle(src, NULL, op, errno);
|
||||
res = EINA_FALSE;
|
||||
goto err_unlink;
|
||||
}
|
||||
|
@ -439,6 +409,7 @@ fs_mv(const char *src, const char *dst, Eina_Bool report_err)
|
|||
{ // mv /path/to/src/filename /path/to/dst/filename
|
||||
Eina_Bool res = EINA_TRUE;
|
||||
int ret;
|
||||
const char *op = "Move";
|
||||
|
||||
status_op("mv");
|
||||
status_count(1, src);
|
||||
|
@ -452,7 +423,7 @@ fs_mv(const char *src, const char *dst, Eina_Bool report_err)
|
|||
return fs_cp_rm(src, dst, report_err, EINA_TRUE, EINA_TRUE);
|
||||
break;
|
||||
default:
|
||||
if (report_err) _error_handle(src, dst, errno);
|
||||
if (report_err) _error_handle(src, dst, op, errno);
|
||||
res = EINA_FALSE;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define EFM_DND_H 1
|
||||
|
||||
#include <Elementary.h>
|
||||
#include "efm_structs.h"
|
||||
|
||||
void _drop_init(Smart_Data *sd);
|
||||
void _drag_start(Icon *icon);
|
||||
|
|
Loading…
Reference in New Issue