Fix lots of nasty formatting problems & remove whitespace.

SVN revision: 37667
This commit is contained in:
Christopher Michael 2008-11-15 19:44:31 +00:00
parent dd8b7db82c
commit 25102ccbcb
1 changed files with 133 additions and 232 deletions

View File

@ -96,7 +96,6 @@ struct _E_Fm_Op_Task
struct struct
{ {
const char *name; const char *name;
struct stat st; struct stat st;
} src; } src;
@ -141,33 +140,21 @@ main(int argc, char **argv)
ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ, _e_fm_op_stdin_data, NULL, ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ, _e_fm_op_stdin_data, NULL,
NULL, NULL); NULL, NULL);
if (argc <= 2) if (argc <= 2) return 0;
{
return 0;
}
last = argc - 1; last = argc - 1;
i = 2; i = 2;
if (strcmp(argv[1], "cp") == 0) if (strcmp(argv[1], "cp") == 0)
{
type = E_FM_OP_COPY; type = E_FM_OP_COPY;
}
else if (strcmp(argv[1], "mv") == 0) else if (strcmp(argv[1], "mv") == 0)
{
type = E_FM_OP_MOVE; type = E_FM_OP_MOVE;
}
else if (strcmp(argv[1], "rm") == 0) else if (strcmp(argv[1], "rm") == 0)
{
type = E_FM_OP_REMOVE; type = E_FM_OP_REMOVE;
}
if (type == E_FM_OP_COPY || type == E_FM_OP_MOVE) if ((type == E_FM_OP_COPY) || (type == E_FM_OP_MOVE))
{ {
if (argc < 4) if (argc < 4) goto quit;
{
goto quit;
}
if (type == E_FM_OP_MOVE) if (type == E_FM_OP_MOVE)
{ {
@ -175,7 +162,7 @@ main(int argc, char **argv)
_e_fm_op_separator = _e_fm_op_work_queue; _e_fm_op_separator = _e_fm_op_work_queue;
} }
if (argc >= 4 && ecore_file_is_dir(argv[last])) if ((argc >= 4) && (ecore_file_is_dir(argv[last])))
{ {
if (argv[last][strlen(argv[last]) - 1] == '/') byte = ""; if (argv[last][strlen(argv[last]) - 1] == '/') byte = "";
@ -189,17 +176,19 @@ main(int argc, char **argv)
snprintf(buf, PATH_MAX, "%s%s%s", argv[last], byte, name); snprintf(buf, PATH_MAX, "%s%s%s", argv[last], byte, name);
task->dst.name = eina_stringshare_add(buf); task->dst.name = eina_stringshare_add(buf);
if (type == E_FM_OP_MOVE && rename(task->src.name, task->dst.name) == 0) if ((type == E_FM_OP_MOVE) &&
(rename(task->src.name, task->dst.name) == 0))
_e_fm_op_task_free(task); _e_fm_op_task_free(task);
else else
_e_fm_op_scan_queue = eina_list_append(_e_fm_op_scan_queue, task); _e_fm_op_scan_queue =
eina_list_append(_e_fm_op_scan_queue, task);
i++; i++;
} }
} }
else if (argc == 4) else if (argc == 4)
{ {
if (type == E_FM_OP_MOVE && rename(argv[2], argv[3]) == 0) if ((type == E_FM_OP_MOVE) && (rename(argv[2], argv[3]) == 0))
goto quit; goto quit;
task = _e_fm_op_task_new(); task = _e_fm_op_task_new();
@ -210,16 +199,11 @@ main(int argc, char **argv)
_e_fm_op_scan_queue = eina_list_append(_e_fm_op_scan_queue, task); _e_fm_op_scan_queue = eina_list_append(_e_fm_op_scan_queue, task);
} }
else else
{
goto quit; goto quit;
} }
}
else if (type == E_FM_OP_REMOVE) else if (type == E_FM_OP_REMOVE)
{ {
if (argc < 3) if (argc < 3) return 0;
{
return 0;
}
while (i <= last) while (i <= last)
{ {
@ -228,7 +212,6 @@ main(int argc, char **argv)
task->src.name = eina_stringshare_add(argv[i]); task->src.name = eina_stringshare_add(argv[i]);
_e_fm_op_scan_queue = eina_list_append(_e_fm_op_scan_queue, task); _e_fm_op_scan_queue = eina_list_append(_e_fm_op_scan_queue, task);
i++; i++;
} }
} }
@ -250,10 +233,12 @@ quit:
/* Create new task. */ /* Create new task. */
static E_Fm_Op_Task *_e_fm_op_task_new() static E_Fm_Op_Task *
_e_fm_op_task_new()
{ {
E_Fm_Op_Task *t = malloc(sizeof(E_Fm_Op_Task)); E_Fm_Op_Task *t;
t = malloc(sizeof(E_Fm_Op_Task));
t->src.name = NULL; t->src.name = NULL;
memset(&(t->src.st), 0, sizeof(struct stat)); memset(&(t->src.st), 0, sizeof(struct stat));
@ -281,33 +266,21 @@ _e_fm_op_task_free(void *t)
E_Fm_Op_Task *task = t; E_Fm_Op_Task *task = t;
E_Fm_Op_Copy_Data *data; E_Fm_Op_Copy_Data *data;
if (!task) if (!task) return;
return;
if (task->src.name) if (task->src.name) eina_stringshare_del(task->src.name);
eina_stringshare_del(task->src.name); if (task->dst.name) eina_stringshare_del(task->dst.name);
if (task->dst.name)
eina_stringshare_del(task->dst.name);
if (task->data) if (task->data)
{ {
data = task->data; data = task->data;
if (task->type == E_FM_OP_COPY) if (task->type == E_FM_OP_COPY)
{ {
if (data->from) if (data->from) fclose(data->from);
{ if (data->to) fclose(data->to);
fclose(data->from);
}
if (data->to)
{
fclose(data->to);
}
} }
FREE(task->data); FREE(task->data);
} }
FREE(task); FREE(task);
} }
@ -318,11 +291,13 @@ _e_fm_op_task_free(void *t)
* queue with this functions. * queue with this functions.
*/ */
static void _e_fm_op_remove_link_task(E_Fm_Op_Task *task) static void
_e_fm_op_remove_link_task(E_Fm_Op_Task *task)
{ {
if (task->link) if (task->link)
{ {
_e_fm_op_work_queue = eina_list_remove_list(_e_fm_op_work_queue, task->link); _e_fm_op_work_queue =
eina_list_remove_list(_e_fm_op_work_queue, task->link);
_e_fm_op_task_free(task->link); _e_fm_op_task_free(task->link);
task->link = NULL; task->link = NULL;
} }
@ -344,7 +319,7 @@ static void _e_fm_op_remove_link_task(E_Fm_Op_Task *task)
static int static int
_e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler) _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
{ {
int fd = ecore_main_fd_handler_fd_get(fd_handler); int fd;
static void *buf = NULL; static void *buf = NULL;
static int length = 0; static int length = 0;
void *begin = NULL; void *begin = NULL;
@ -352,6 +327,7 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
int msize; int msize;
int identity; int identity;
fd = ecore_main_fd_handler_fd_get(fd_handler);
if (!buf) if (!buf)
{ {
buf = _e_fm_op_stdin_buffer; buf = _e_fm_op_stdin_buffer;
@ -397,13 +373,13 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
memcpy(&msize, buf, sizeof(int)); memcpy(&msize, buf, sizeof(int));
buf += sizeof(int); buf += sizeof(int);
if (length - 3*sizeof(int) < msize) if ((length - 3 * sizeof(int)) < msize)
{ {
/* There is not enough data to read the whole message. */ /* There is not enough data to read the whole message. */
break; break;
} }
length -= 3*sizeof(int); length -= (3 * sizeof(int));
/* You may want to read msize bytes of data too, /* You may want to read msize bytes of data too,
* but currently commands here do not have any data. * but currently commands here do not have any data.
@ -416,7 +392,6 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
_e_fm_op_abort = 1; _e_fm_op_abort = 1;
E_FM_OP_DEBUG("Aborted.\n"); E_FM_OP_DEBUG("Aborted.\n");
break; break;
case E_FM_OP_ERROR_RESPONSE_ABORT: case E_FM_OP_ERROR_RESPONSE_ABORT:
case E_FM_OP_ERROR_RESPONSE_IGNORE_THIS: case E_FM_OP_ERROR_RESPONSE_IGNORE_THIS:
case E_FM_OP_ERROR_RESPONSE_IGNORE_ALL: case E_FM_OP_ERROR_RESPONSE_IGNORE_ALL:
@ -424,7 +399,6 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
_e_fm_op_error_response = identity; _e_fm_op_error_response = identity;
_e_fm_op_set_up_idlers(); _e_fm_op_set_up_idlers();
break; break;
case E_FM_OP_OVERWRITE_RESPONSE_NO: case E_FM_OP_OVERWRITE_RESPONSE_NO:
case E_FM_OP_OVERWRITE_RESPONSE_NO_ALL: case E_FM_OP_OVERWRITE_RESPONSE_NO_ALL:
case E_FM_OP_OVERWRITE_RESPONSE_YES: case E_FM_OP_OVERWRITE_RESPONSE_YES:
@ -436,10 +410,7 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
} }
} }
if (length > 0) if (length > 0) memmove(_e_fm_op_stdin_buffer, begin, length);
{
memmove(_e_fm_op_stdin_buffer, begin, length);
}
buf = _e_fm_op_stdin_buffer + length; buf = _e_fm_op_stdin_buffer + length;
} }
@ -447,11 +418,11 @@ _e_fm_op_stdin_data(void *data, Ecore_Fd_Handler * fd_handler)
return 1; return 1;
} }
static void _e_fm_op_set_up_idlers() static void
_e_fm_op_set_up_idlers()
{ {
if (!_e_fm_op_scan_idler_p) if (!_e_fm_op_scan_idler_p)
_e_fm_op_scan_idler_p = ecore_idler_add(_e_fm_op_scan_idler, NULL); _e_fm_op_scan_idler_p = ecore_idler_add(_e_fm_op_scan_idler, NULL);
if (!_e_fm_op_work_idler_p) if (!_e_fm_op_work_idler_p)
_e_fm_op_work_idler_p = ecore_idler_add(_e_fm_op_work_idler, NULL); _e_fm_op_work_idler_p = ecore_idler_add(_e_fm_op_work_idler, NULL);
} }
@ -476,7 +447,8 @@ static void _e_fm_op_set_up_idlers()
}\ }\
while (0) while (0)
static void _e_fm_op_delete_idler(int *mark) static void
_e_fm_op_delete_idler(int *mark)
{ {
if (mark == &_e_fm_op_work_error) if (mark == &_e_fm_op_work_error)
{ {
@ -495,7 +467,8 @@ static void _e_fm_op_delete_idler(int *mark)
* Returns 1 if we did; otherwise checks it and does what needs to be done. * Returns 1 if we did; otherwise checks it and does what needs to be done.
*/ */
static int _e_fm_op_idler_handle_error(int *mark, Eina_List **queue, Eina_List **node, E_Fm_Op_Task *task) static int
_e_fm_op_idler_handle_error(int *mark, Eina_List **queue, Eina_List **node, E_Fm_Op_Task *task)
{ {
if (_e_fm_op_overwrite) if (_e_fm_op_overwrite)
{ {
@ -562,12 +535,11 @@ static int _e_fm_op_idler_handle_error(int *mark, Eina_List **queue, Eina_List *
} }
} }
} }
else if ( _e_fm_op_work_error || _e_fm_op_scan_error) else if (( _e_fm_op_work_error) || (_e_fm_op_scan_error))
{
return 1; return 1;
}
return 0; return 0;
} }
/* This works very simple. Take a task from queue and run appropriate _atom() on it. /* This works very simple. Take a task from queue and run appropriate _atom() on it.
* If after _atom() is done, task->finished is 1 remove the task from queue. Otherwise, * If after _atom() is done, task->finished is 1 remove the task from queue. Otherwise,
* run _atom() on the same task on next call. * run _atom() on the same task on next call.
@ -593,9 +565,7 @@ _e_fm_op_work_idler(void *data)
E_Fm_Op_Task *task = NULL; E_Fm_Op_Task *task = NULL;
if (!node) node = _e_fm_op_work_queue; if (!node) node = _e_fm_op_work_queue;
task = eina_list_data_get(node); task = eina_list_data_get(node);
if (!task) if (!task)
{ {
node = _e_fm_op_work_queue; node = _e_fm_op_work_queue;
@ -613,9 +583,7 @@ _e_fm_op_work_idler(void *data)
} }
if (_e_fm_op_scan_idler_p == NULL && !_e_fm_op_work_error && !_e_fm_op_scan_error) if (_e_fm_op_scan_idler_p == NULL && !_e_fm_op_work_error && !_e_fm_op_scan_error)
{
ecore_main_loop_quit(); ecore_main_loop_quit();
}
return 1; return 1;
} }
@ -625,17 +593,11 @@ _e_fm_op_work_idler(void *data)
task->started = 1; task->started = 1;
if (task->type == E_FM_OP_COPY) if (task->type == E_FM_OP_COPY)
{
_e_fm_op_copy_atom(task); _e_fm_op_copy_atom(task);
}
else if (task->type == E_FM_OP_REMOVE) else if (task->type == E_FM_OP_REMOVE)
{
_e_fm_op_remove_atom(task); _e_fm_op_remove_atom(task);
}
else if (task->type == E_FM_OP_COPY_STAT_INFO) else if (task->type == E_FM_OP_COPY_STAT_INFO)
{
_e_fm_op_copy_stat_info_atom(task); _e_fm_op_copy_stat_info_atom(task);
}
if (task->finished) if (task->finished)
{ {
@ -658,7 +620,6 @@ _e_fm_op_work_idler(void *data)
* if this is a dir, then look into its contents and create a task * if this is a dir, then look into its contents and create a task
* for those files. And we don't have _e_fm_op_separator here. * for those files. And we don't have _e_fm_op_separator here.
*/ */
int int
_e_fm_op_scan_idler(void *data) _e_fm_op_scan_idler(void *data)
{ {
@ -670,9 +631,7 @@ _e_fm_op_scan_idler(void *data)
E_Fm_Op_Task *ntask = NULL; E_Fm_Op_Task *ntask = NULL;
if (!node) node = _e_fm_op_scan_queue; if (!node) node = _e_fm_op_scan_queue;
task = eina_list_data_get(node); task = eina_list_data_get(node);
if (!task) if (!task)
{ {
node = _e_fm_op_scan_queue; node = _e_fm_op_scan_queue;
@ -707,9 +666,7 @@ _e_fm_op_scan_idler(void *data)
else if (!dir && !task->started) else if (!dir && !task->started)
{ {
if (lstat(task->src.name, &(task->src.st)) < 0) if (lstat(task->src.name, &(task->src.st)) < 0)
{
_E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR, "Cannot lstat '%s': %s.", task->src.name); _E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR, "Cannot lstat '%s': %s.", task->src.name);
}
if (S_ISDIR(task->src.st.st_mode)) if (S_ISDIR(task->src.st.st_mode))
{ {
@ -717,10 +674,8 @@ _e_fm_op_scan_idler(void *data)
dir = opendir(task->src.name); dir = opendir(task->src.name);
if (!dir) if (!dir)
{
_E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR, "Cannot open directory '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_SCAN(task, E_FM_OP_ERROR, "Cannot open directory '%s': %s.", task->dst.name);
} }
}
else else
task->started = 1; task->started = 1;
} }
@ -731,20 +686,14 @@ _e_fm_op_scan_idler(void *data)
if (!de) if (!de)
{ {
ntask = _e_fm_op_task_new(); ntask = _e_fm_op_task_new();
ntask->type = E_FM_OP_COPY_STAT_INFO; ntask->type = E_FM_OP_COPY_STAT_INFO;
ntask->src.name = eina_stringshare_add(task->src.name); ntask->src.name = eina_stringshare_add(task->src.name);
memcpy(&(ntask->src.st), &(task->src.st), sizeof(struct stat)); memcpy(&(ntask->src.st), &(task->src.st), sizeof(struct stat));
if (task->dst.name) if (task->dst.name)
{
ntask->dst.name = eina_stringshare_add(task->dst.name); ntask->dst.name = eina_stringshare_add(task->dst.name);
}
else else
{
ntask->dst.name = NULL; ntask->dst.name = NULL;
}
if (task->type == E_FM_OP_REMOVE) if (task->type == E_FM_OP_REMOVE)
_e_fm_op_scan_queue = eina_list_prepend(_e_fm_op_scan_queue, ntask); _e_fm_op_scan_queue = eina_list_prepend(_e_fm_op_scan_queue, ntask);
@ -758,29 +707,21 @@ _e_fm_op_scan_idler(void *data)
return 1; return 1;
} }
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) if ((!strcmp(de->d_name, ".") || (!strcmp(de->d_name, ".."))))
{
return 1; return 1;
}
ntask = _e_fm_op_task_new(); ntask = _e_fm_op_task_new();
ntask->type = task->type; ntask->type = task->type;
snprintf(buf, sizeof(buf), "%s/%s", task->src.name, de->d_name);
snprintf(buf, sizeof(buf), "%s/%s", task->src.name,
de->d_name);
ntask->src.name = eina_stringshare_add(buf); ntask->src.name = eina_stringshare_add(buf);
if (task->dst.name) if (task->dst.name)
{ {
snprintf(buf, sizeof(buf), "%s/%s", task->dst.name, snprintf(buf, sizeof(buf), "%s/%s", task->dst.name, de->d_name);
de->d_name);
ntask->dst.name = eina_stringshare_add(buf); ntask->dst.name = eina_stringshare_add(buf);
} }
else else
{
ntask->dst.name = NULL; ntask->dst.name = NULL;
}
if (task->type == E_FM_OP_REMOVE) if (task->type == E_FM_OP_REMOVE)
_e_fm_op_scan_queue = eina_list_prepend(_e_fm_op_scan_queue, ntask); _e_fm_op_scan_queue = eina_list_prepend(_e_fm_op_scan_queue, ntask);
@ -806,7 +747,6 @@ _e_fm_op_scan_idler(void *data)
* fmt is a printf format string, the other arguments * fmt is a printf format string, the other arguments
* are for this format string, * are for this format string,
*/ */
static void static void
_e_fm_op_send_error(E_Fm_Op_Task * task, E_Fm_Op_Type type, const char *fmt, ...) _e_fm_op_send_error(E_Fm_Op_Task * task, E_Fm_Op_Type type, const char *fmt, ...)
{ {
@ -840,16 +780,13 @@ _e_fm_op_send_error(E_Fm_Op_Task * task, E_Fm_Op_Type type, const char *fmt, ...
va_end(ap); va_end(ap);
} }
/* Unrolls task: makes a clean up and updates progress info. /* Unrolls task: makes a clean up and updates progress info. */
*/
static void static void
_e_fm_op_rollback(E_Fm_Op_Task *task) _e_fm_op_rollback(E_Fm_Op_Task *task)
{ {
E_Fm_Op_Copy_Data *data; E_Fm_Op_Copy_Data *data;
if (!task) if (!task) return;
return;
if (task->type == E_FM_OP_COPY) if (task->type == E_FM_OP_COPY)
{ {
@ -887,20 +824,16 @@ _e_fm_op_rollback(E_Fm_Op_Task * task)
* If either of them changes from their previuos values, then the are * If either of them changes from their previuos values, then the are
* packed and written to STDOUT. * packed and written to STDOUT.
*/ */
static void static void
_e_fm_op_update_progress(E_Fm_Op_Task *task, long long _plus_e_fm_op_done, long long _plus_e_fm_op_total) _e_fm_op_update_progress(E_Fm_Op_Task *task, long long _plus_e_fm_op_done, long long _plus_e_fm_op_total)
{ {
static int ppercent = -1; static int ppercent = -1;
int percent; int percent;
static double ctime = 0; static double ctime = 0;
static double stime = 0; static double stime = 0;
double eta = 0; double eta = 0;
static int peta = -1; static int peta = -1;
static E_Fm_Op_Task *ptask = NULL; static E_Fm_Op_Task *ptask = NULL;
void *data; void *data;
void *p; void *p;
int magic = E_FM_OP_MAGIC; int magic = E_FM_OP_MAGIC;
@ -967,9 +900,7 @@ _e_fm_op_update_progress(E_Fm_Op_Task *task, long long _plus_e_fm_op_done, long
} }
} }
/* We just use this code in several places. /* We just use this code in several places. */
*/
static void static void
_e_fm_op_copy_stat_info(E_Fm_Op_Task *task) _e_fm_op_copy_stat_info(E_Fm_Op_Task *task)
{ {
@ -978,8 +909,7 @@ _e_fm_op_copy_stat_info(E_Fm_Op_Task *task)
if (!task->dst.name) return; if (!task->dst.name) return;
chmod(task->dst.name, task->src.st.st_mode); chmod(task->dst.name, task->src.st.st_mode);
chown(task->dst.name, task->src.st.st_uid, chown(task->dst.name, task->src.st.st_uid, task->src.st.st_gid);
task->src.st.st_gid);
ut.actime = task->src.st.st_atime; ut.actime = task->src.st.st_atime;
ut.modtime = task->src.st.st_mtime; ut.modtime = task->src.st.st_mtime;
utime(task->dst.name, &ut); utime(task->dst.name, &ut);
@ -990,21 +920,21 @@ _e_fm_op_handle_overwrite(E_Fm_Op_Task *task)
{ {
struct stat st; struct stat st;
if (task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_YES_ALL if ((task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_YES_ALL)
|| _e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_YES_ALL) || (_e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_YES_ALL))
{ {
_e_fm_op_overwrite = 0; _e_fm_op_overwrite = 0;
return 0; return 0;
} }
else if (task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_YES else if ((task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_YES)
|| _e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_YES) || (_e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_YES))
{ {
_e_fm_op_overwrite_response = E_FM_OP_NONE; _e_fm_op_overwrite_response = E_FM_OP_NONE;
_e_fm_op_overwrite = 0; _e_fm_op_overwrite = 0;
return 0; return 0;
} }
else if (task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_NO else if ((task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_NO)
|| _e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_NO) || (_e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_NO))
{ {
task->finished = 1; task->finished = 1;
_e_fm_op_rollback(task); _e_fm_op_rollback(task);
@ -1013,8 +943,8 @@ _e_fm_op_handle_overwrite(E_Fm_Op_Task *task)
_e_fm_op_overwrite = 0; _e_fm_op_overwrite = 0;
return 1; return 1;
} }
else if (task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_NO_ALL else if ((task->overwrite == E_FM_OP_OVERWRITE_RESPONSE_NO_ALL)
|| _e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_NO_ALL) || (_e_fm_op_overwrite_response == E_FM_OP_OVERWRITE_RESPONSE_NO_ALL))
{ {
task->finished = 1; task->finished = 1;
_e_fm_op_rollback(task); _e_fm_op_rollback(task);
@ -1046,9 +976,9 @@ static int
_e_fm_op_copy_dir(E_Fm_Op_Task * task) _e_fm_op_copy_dir(E_Fm_Op_Task * task)
{ {
struct stat st; struct stat st;
/* Directory. Just create one in destatation. */ /* Directory. Just create one in destatation. */
if (mkdir if (mkdir(task->dst.name,
(task->dst.name,
S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH |
S_IXOTH) == -1) S_IXOTH) == -1)
{ {
@ -1066,10 +996,8 @@ _e_fm_op_copy_dir(E_Fm_Op_Task * task)
} }
} }
else else
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make directory '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make directory '%s': %s.", task->dst.name);
} }
}
task->dst.done += task->src.st.st_size; task->dst.done += task->src.st.st_size;
_e_fm_op_update_progress(task, task->src.st.st_size, 0); _e_fm_op_update_progress(task, task->src.st.st_size, 0);
@ -1099,14 +1027,12 @@ _e_fm_op_copy_link(E_Fm_Op_Task *task)
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name);
} }
else else
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", path, task->dst.name);
} }
}
task->dst.done += task->src.st.st_size; task->dst.done += task->src.st.st_size;
_e_fm_op_update_progress(task, task->src.st.st_size, 0);
_e_fm_op_update_progress(task, task->src.st.st_size, 0);
_e_fm_op_copy_stat_info(task); _e_fm_op_copy_stat_info(task);
task->finished = 1; task->finished = 1;
@ -1127,10 +1053,8 @@ _e_fm_op_copy_fifo(E_Fm_Op_Task *task)
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make FIFO at '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make FIFO at '%s': %s.", task->dst.name);
} }
else else
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make FIFO at '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot make FIFO at '%s': %s.", task->dst.name);
} }
}
_e_fm_op_copy_stat_info(task); _e_fm_op_copy_stat_info(task);
@ -1160,21 +1084,16 @@ _e_fm_op_open_files(E_Fm_Op_Task *task)
{ {
data->from = fopen(task->src.name, "rb"); data->from = fopen(task->src.name, "rb");
if (data->from == NULL) if (data->from == NULL)
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot open file '%s' for reading: %s.", task->src.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot open file '%s' for reading: %s.", task->src.name);
} }
}
if (!data->to) if (!data->to)
{ {
data->to = fopen(task->dst.name, "wb"); data->to = fopen(task->dst.name, "wb");
if (data->to == NULL) if (data->to == NULL)
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot open file '%s' for writing: %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot open file '%s' for writing: %s.", task->dst.name);
} }
}
return 0; return 0;
} }
@ -1199,9 +1118,7 @@ _e_fm_op_copy_chunk(E_Fm_Op_Task *task)
if (dread <= 0) if (dread <= 0)
{ {
if (!feof(data->from)) if (!feof(data->from))
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read data from '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot read data from '%s': %s.", task->dst.name);
}
fclose(data->from); fclose(data->from);
fclose(data->to); fclose(data->to);
@ -1222,15 +1139,14 @@ _e_fm_op_copy_chunk(E_Fm_Op_Task *task)
dwrite = fwrite(buf, 1, dread, data->to); dwrite = fwrite(buf, 1, dread, data->to);
if (dwrite < dread) if (dwrite < dread)
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot write data to '%s': %s.", task->dst.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot write data to '%s': %s.", task->dst.name);
}
task->dst.done += dread; task->dst.done += dread;
_e_fm_op_update_progress(task, dwrite, 0); _e_fm_op_update_progress(task, dwrite, 0);
return 0; return 0;
} }
/* /*
* _e_fm_op_copy_atom(), _e_fm_op_remove_atom() and _e_fm_op_scan_atom() are functions that * _e_fm_op_copy_atom(), _e_fm_op_remove_atom() and _e_fm_op_scan_atom() are functions that
* perform very small operations. * perform very small operations.
@ -1251,20 +1167,16 @@ _e_fm_op_copy_chunk(E_Fm_Op_Task *task)
* *
* Return value does not matter. It's there only to _E_FM_OP_ERROR_SEND macro to work correctly. (Well, it works fine, just don't want GCC to produce a warning.) * Return value does not matter. It's there only to _E_FM_OP_ERROR_SEND macro to work correctly. (Well, it works fine, just don't want GCC to produce a warning.)
*/ */
static int static int
_e_fm_op_copy_atom(E_Fm_Op_Task * task) _e_fm_op_copy_atom(E_Fm_Op_Task * task)
{ {
E_Fm_Op_Copy_Data *data; E_Fm_Op_Copy_Data *data;
if (!task) if (!task) return 1;
{
return 1;
}
data = task->data; data = task->data;
if (!data || !data->to || !data->from) /* Did not touch the files yet. */ if ((!data) || (!data->to) || (!data->from)) /* Did not touch the files yet. */
{ {
E_FM_OP_DEBUG("Copy: %s --> %s\n", task->src.name, task->dst.name); E_FM_OP_DEBUG("Copy: %s --> %s\n", task->src.name, task->dst.name);
@ -1309,10 +1221,7 @@ _e_fm_op_scan_atom(E_Fm_Op_Task * task)
{ {
E_Fm_Op_Task *ctask, *rtask; E_Fm_Op_Task *ctask, *rtask;
if (!task) if (!task) return 1;
{ /* Error. */
return 1;
}
task->finished = 1; task->finished = 1;
@ -1356,7 +1265,6 @@ _e_fm_op_scan_atom(E_Fm_Op_Task * task)
rtask->type = E_FM_OP_REMOVE; rtask->type = E_FM_OP_REMOVE;
_e_fm_op_work_queue = eina_list_prepend(_e_fm_op_work_queue, rtask); _e_fm_op_work_queue = eina_list_prepend(_e_fm_op_work_queue, rtask);
} }
else if (task->type == E_FM_OP_MOVE) else if (task->type == E_FM_OP_MOVE)
{ {
@ -1417,10 +1325,7 @@ _e_fm_op_copy_stat_info_atom(E_Fm_Op_Task * task)
static int static int
_e_fm_op_remove_atom(E_Fm_Op_Task * task) _e_fm_op_remove_atom(E_Fm_Op_Task * task)
{ {
if (_e_fm_op_abort) if (_e_fm_op_abort) return 1;
{
return 1;
}
E_FM_OP_DEBUG("Remove: %s\n", task->src.name); E_FM_OP_DEBUG("Remove: %s\n", task->src.name);
@ -1437,15 +1342,11 @@ _e_fm_op_remove_atom(E_Fm_Op_Task * task)
return 1; return 1;
} }
else else
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot remove directory '%s': %s.", task->src.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot remove directory '%s': %s.", task->src.name);
} }
} }
}
else if (unlink(task->src.name) == -1) else if (unlink(task->src.name) == -1)
{
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot remove file '%s': %s.", task->src.name); _E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot remove file '%s': %s.", task->src.name);
}
task->dst.done += REMOVECHUNKSIZE; task->dst.done += REMOVECHUNKSIZE;
_e_fm_op_update_progress(task, REMOVECHUNKSIZE, 0); _e_fm_op_update_progress(task, REMOVECHUNKSIZE, 0);