forked from enlightenment/enlightenment
fm: handle symbolic links.
Symbolic links are handled similar to "paste". If you "Copy" you'll get the "Link" menu item that will create a symbolic link instead of real copying the file. Drag and Drop works similarly, use "Alt" in order to get a popup and select "Link" there. Toma: we do miss icons for it! Mekius & Ptomaine: please review as I'm not that familiar with e_fm_op.c SVN revision: 39170
This commit is contained in:
parent
2ad48586df
commit
59cde6a762
154
src/bin/e_fm.c
154
src/bin/e_fm.c
|
@ -340,9 +340,11 @@ static void _e_fm_file_buffer_clear(void);
|
||||||
static void _e_fm2_file_cut(Evas_Object *obj);
|
static void _e_fm2_file_cut(Evas_Object *obj);
|
||||||
static void _e_fm2_file_copy(Evas_Object *obj);
|
static void _e_fm2_file_copy(Evas_Object *obj);
|
||||||
static void _e_fm2_file_paste(Evas_Object *obj);
|
static void _e_fm2_file_paste(Evas_Object *obj);
|
||||||
|
static void _e_fm2_file_symlink(Evas_Object *obj);
|
||||||
static void _e_fm2_file_cut_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
static void _e_fm2_file_cut_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
static void _e_fm2_file_copy_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
static void _e_fm2_file_copy_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
static void _e_fm2_file_paste_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
static void _e_fm2_file_paste_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
|
static void _e_fm2_file_symlink_menu(void *data, E_Menu *m, E_Menu_Item *mi);
|
||||||
|
|
||||||
static void _e_fm2_live_file_add(Evas_Object *obj, const char *file, const char *file_rel, int after, E_Fm2_Finfo *finf);
|
static void _e_fm2_live_file_add(Evas_Object *obj, const char *file, const char *file_rel, int after, E_Fm2_Finfo *finf);
|
||||||
static void _e_fm2_live_file_del(Evas_Object *obj, const char *file);
|
static void _e_fm2_live_file_del(Evas_Object *obj, const char *file);
|
||||||
|
@ -368,6 +370,7 @@ static int _e_fm2_client_file_mkdir(const char *path, const char *rel, int rel_t
|
||||||
static int _e_fm_client_file_move(const char *args);
|
static int _e_fm_client_file_move(const char *args);
|
||||||
static int _e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
|
static int _e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
|
||||||
static int _e_fm_client_file_copy(const char *args);
|
static int _e_fm_client_file_copy(const char *args);
|
||||||
|
static int _e_fm_client_file_symlink(const char *args);
|
||||||
|
|
||||||
static void _e_fm2_sel_rect_update(void *data);
|
static void _e_fm2_sel_rect_update(void *data);
|
||||||
static inline void _e_fm2_context_menu_append(Evas_Object *obj, const char *path, Eina_List *l, E_Menu *mn, E_Fm2_Icon *ic);
|
static inline void _e_fm2_context_menu_append(Evas_Object *obj, const char *path, Eina_List *l, E_Menu *mn, E_Fm2_Icon *ic);
|
||||||
|
@ -1829,6 +1832,7 @@ _e_fm_client_file_move(const char *args)
|
||||||
static int
|
static int
|
||||||
_e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h)
|
_e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
char *d;
|
char *d;
|
||||||
int l1, l2, l3, l;
|
int l1, l2, l3, l;
|
||||||
|
|
||||||
|
@ -1864,6 +1868,19 @@ _e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel,
|
||||||
}
|
}
|
||||||
|
|
||||||
return _e_fm_client_send_new(E_FM_OP_SYMLINK, (void *)d, l);
|
return _e_fm_client_send_new(E_FM_OP_SYMLINK, (void *)d, l);
|
||||||
|
#else
|
||||||
|
char *args = NULL;
|
||||||
|
size_t size = 0, length = 0;
|
||||||
|
|
||||||
|
args = _e_fm_string_append_quoted(args, &size, &length, path);
|
||||||
|
args = _e_fm_string_append_char(args, &size, &length, ' ');
|
||||||
|
args = _e_fm_string_append_quoted(args, &size, &length, dest);
|
||||||
|
|
||||||
|
fputs("WARNING: using new E_FM_OP_SYMLINK, remove deprecated ASAP\n", stderr);
|
||||||
|
int r = _e_fm_client_file_symlink(args);
|
||||||
|
free(args);
|
||||||
|
return r;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -1872,6 +1889,12 @@ _e_fm_client_file_copy(const char *args)
|
||||||
return _e_fm_client_send_new(E_FM_OP_COPY, (void *)args, strlen(args) + 1);
|
return _e_fm_client_send_new(E_FM_OP_COPY, (void *)args, strlen(args) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_e_fm_client_file_symlink(const char *args)
|
||||||
|
{
|
||||||
|
return _e_fm_client_send_new(E_FM_OP_SYMLINK, (void *)args, strlen(args) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
EAPI int
|
EAPI int
|
||||||
_e_fm2_client_mount(const char *udi, const char *mountpoint)
|
_e_fm2_client_mount(const char *udi, const char *mountpoint)
|
||||||
{
|
{
|
||||||
|
@ -2682,6 +2705,60 @@ _e_fm2_file_paste(Evas_Object *obj)
|
||||||
free(args);
|
free(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_fm2_file_symlink(Evas_Object *obj)
|
||||||
|
{
|
||||||
|
E_Fm2_Smart_Data *sd;
|
||||||
|
Eina_List *paths;
|
||||||
|
const char *filepath;
|
||||||
|
size_t length = 0;
|
||||||
|
size_t size = 0;
|
||||||
|
char *args = NULL;
|
||||||
|
|
||||||
|
sd = evas_object_smart_data_get(obj);
|
||||||
|
if (!sd) return;
|
||||||
|
|
||||||
|
/* Convert URI list to a list of real paths. */
|
||||||
|
paths = _e_fm2_uri_path_list_get(_e_fm_file_buffer);
|
||||||
|
|
||||||
|
while (paths)
|
||||||
|
{
|
||||||
|
/* Get file's full path. */
|
||||||
|
filepath = eina_list_data_get(paths);
|
||||||
|
if (!filepath)
|
||||||
|
{
|
||||||
|
paths = eina_list_remove_list(paths, paths);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if file is protected. */
|
||||||
|
if (e_filereg_file_protected(filepath))
|
||||||
|
{
|
||||||
|
eina_stringshare_del(filepath);
|
||||||
|
paths = eina_list_remove_list(paths, paths);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Put filepath into a string of args.
|
||||||
|
* If there are more files, put an additional space.
|
||||||
|
*/
|
||||||
|
args = _e_fm_string_append_quoted(args, &size, &length, filepath);
|
||||||
|
args = _e_fm_string_append_char(args, &size, &length, ' ');
|
||||||
|
|
||||||
|
eina_stringshare_del(filepath);
|
||||||
|
paths = eina_list_remove_list(paths, paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add destination to the arguments. */
|
||||||
|
args = _e_fm_string_append_quoted(args, &size, &length, sd->realpath);
|
||||||
|
|
||||||
|
/* Roll the operation! */
|
||||||
|
if (_e_fm_file_buffer_copying)
|
||||||
|
_e_fm_client_file_symlink(args);
|
||||||
|
|
||||||
|
free(args);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_fm2_file_cut_menu(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
_e_fm2_file_cut_menu(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
||||||
{
|
{
|
||||||
|
@ -2706,6 +2783,14 @@ _e_fm2_file_paste_menu(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSE
|
||||||
_e_fm2_file_paste(sd->obj);
|
_e_fm2_file_paste(sd->obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_fm2_file_symlink_menu(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
|
||||||
|
{
|
||||||
|
E_Fm2_Smart_Data *sd = data;
|
||||||
|
if (!sd) return;
|
||||||
|
_e_fm2_file_symlink(sd->obj);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_fm2_queue_process(Evas_Object *obj)
|
_e_fm2_queue_process(Evas_Object *obj)
|
||||||
{
|
{
|
||||||
|
@ -4908,6 +4993,16 @@ _e_fm_drop_menu_move_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||||
_e_fm_client_file_move(args);
|
_e_fm_client_file_move(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_e_fm_drop_menu_symlink_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||||
|
{
|
||||||
|
char *args = data;
|
||||||
|
|
||||||
|
if (!data) return;
|
||||||
|
|
||||||
|
_e_fm_client_file_symlink(args);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_e_fm_drop_menu_abort_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
_e_fm_drop_menu_abort_cb(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||||
{
|
{
|
||||||
|
@ -4952,6 +5047,17 @@ _e_fm_drop_menu(char *args)
|
||||||
"e/fileman/default/button/move"),
|
"e/fileman/default/button/move"),
|
||||||
"e/fileman/default/button/move");
|
"e/fileman/default/button/move");
|
||||||
|
|
||||||
|
item = e_menu_item_new(menu);
|
||||||
|
e_menu_item_label_set(item, _("Link"));
|
||||||
|
e_menu_item_callback_set(item, _e_fm_drop_menu_symlink_cb, args);
|
||||||
|
e_menu_item_icon_edje_set(item,
|
||||||
|
e_theme_edje_file_get("base/theme/fileman",
|
||||||
|
"e/fileman/default/button/symlink"),
|
||||||
|
"e/fileman/default/button/symlink");
|
||||||
|
|
||||||
|
item = e_menu_item_new(menu);
|
||||||
|
e_menu_item_separator_set(item, 1);
|
||||||
|
|
||||||
item = e_menu_item_new(menu);
|
item = e_menu_item_new(menu);
|
||||||
e_menu_item_label_set(item, _("Abort"));
|
e_menu_item_label_set(item, _("Abort"));
|
||||||
e_menu_item_callback_set(item, _e_fm_drop_menu_abort_cb, args);
|
e_menu_item_callback_set(item, _e_fm_drop_menu_abort_cb, args);
|
||||||
|
@ -6656,14 +6762,16 @@ _e_fm2_menu(Evas_Object *obj, unsigned int timestamp)
|
||||||
e_menu_item_callback_set(mi, _e_fm2_new_directory, sd);
|
e_menu_item_callback_set(mi, _e_fm2_new_directory, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE)) &&
|
if (((!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE)) ||
|
||||||
(eina_list_count(_e_fm_file_buffer) > 0))
|
(!(sd->icon_menu.flags & E_FM2_MENU_NO_SYMLINK))) &&
|
||||||
|
(eina_list_count(_e_fm_file_buffer) > 0) &&
|
||||||
|
ecore_file_can_write(sd->realpath))
|
||||||
{
|
{
|
||||||
if (ecore_file_can_write(sd->realpath))
|
mi = e_menu_item_new(mn);
|
||||||
|
e_menu_item_separator_set(mi, 1);
|
||||||
|
|
||||||
|
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE))
|
||||||
{
|
{
|
||||||
mi = e_menu_item_new(mn);
|
|
||||||
e_menu_item_separator_set(mi, 1);
|
|
||||||
|
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, _("Paste"));
|
e_menu_item_label_set(mi, _("Paste"));
|
||||||
e_menu_item_icon_edje_set(mi,
|
e_menu_item_icon_edje_set(mi,
|
||||||
|
@ -6672,8 +6780,19 @@ _e_fm2_menu(Evas_Object *obj, unsigned int timestamp)
|
||||||
"e/fileman/default/button/paste");
|
"e/fileman/default/button/paste");
|
||||||
e_menu_item_callback_set(mi, _e_fm2_file_paste_menu, sd);
|
e_menu_item_callback_set(mi, _e_fm2_file_paste_menu, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_SYMLINK))
|
||||||
|
{
|
||||||
|
mi = e_menu_item_new(mn);
|
||||||
|
e_menu_item_label_set(mi, _("Link"));
|
||||||
|
e_menu_item_icon_edje_set(mi,
|
||||||
|
e_theme_edje_file_get("base/theme/fileman",
|
||||||
|
"e/fileman/default/button/symlink"),
|
||||||
|
"e/fileman/default/button/symlink");
|
||||||
|
e_menu_item_callback_set(mi, _e_fm2_file_symlink_menu, sd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sd->icon_menu.end.func)
|
if (sd->icon_menu.end.func)
|
||||||
sd->icon_menu.end.func(sd->icon_menu.end.data, sd->obj, mn, NULL);
|
sd->icon_menu.end.func(sd->icon_menu.end.data, sd->obj, mn, NULL);
|
||||||
}
|
}
|
||||||
|
@ -6861,10 +6980,12 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
|
||||||
e_menu_item_callback_set(mi, _e_fm2_file_copy_menu, sd);
|
e_menu_item_callback_set(mi, _e_fm2_file_copy_menu, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE)) &&
|
if (((!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE)) ||
|
||||||
(eina_list_count(_e_fm_file_buffer) > 0))
|
(!(sd->icon_menu.flags & E_FM2_MENU_NO_SYMLINK))) &&
|
||||||
|
(eina_list_count(_e_fm_file_buffer) > 0) &&
|
||||||
|
ecore_file_can_write(sd->realpath))
|
||||||
{
|
{
|
||||||
if (ecore_file_can_write(sd->realpath))
|
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_PASTE))
|
||||||
{
|
{
|
||||||
mi = e_menu_item_new(mn);
|
mi = e_menu_item_new(mn);
|
||||||
e_menu_item_label_set(mi, _("Paste"));
|
e_menu_item_label_set(mi, _("Paste"));
|
||||||
|
@ -6874,8 +6995,19 @@ _e_fm2_icon_menu(E_Fm2_Icon *ic, Evas_Object *obj, unsigned int timestamp)
|
||||||
"e/fileman/default/button/paste");
|
"e/fileman/default/button/paste");
|
||||||
e_menu_item_callback_set(mi, _e_fm2_file_paste_menu, sd);
|
e_menu_item_callback_set(mi, _e_fm2_file_paste_menu, sd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(sd->icon_menu.flags & E_FM2_MENU_NO_SYMLINK))
|
||||||
|
{
|
||||||
|
mi = e_menu_item_new(mn);
|
||||||
|
e_menu_item_label_set(mi, _("Link"));
|
||||||
|
e_menu_item_icon_edje_set(mi,
|
||||||
|
e_theme_edje_file_get("base/theme/fileman",
|
||||||
|
"e/fileman/default/button/symlink"),
|
||||||
|
"e/fileman/default/button/symlink");
|
||||||
|
e_menu_item_callback_set(mi, _e_fm2_file_symlink_menu, sd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
can_w = 0;
|
can_w = 0;
|
||||||
can_w2 = 1;
|
can_w2 = 1;
|
||||||
if (ic->sd->order_file)
|
if (ic->sd->order_file)
|
||||||
|
|
|
@ -30,8 +30,9 @@ typedef enum _E_Fm2_Menu_Flags
|
||||||
E_FM2_MENU_NO_CUT = (1 << 6),
|
E_FM2_MENU_NO_CUT = (1 << 6),
|
||||||
E_FM2_MENU_NO_COPY = (1 << 7),
|
E_FM2_MENU_NO_COPY = (1 << 7),
|
||||||
E_FM2_MENU_NO_PASTE = (1 << 8),
|
E_FM2_MENU_NO_PASTE = (1 << 8),
|
||||||
E_FM2_MENU_NO_VIEW_MENU = (1 << 9),
|
E_FM2_MENU_NO_SYMLINK = (1 << 9),
|
||||||
E_FM2_MENU_NO_INHERIT_PARENT = (1 << 10)
|
E_FM2_MENU_NO_VIEW_MENU = (1 << 10),
|
||||||
|
E_FM2_MENU_NO_INHERIT_PARENT = (1 << 11)
|
||||||
} E_Fm2_Menu_Flags;
|
} E_Fm2_Menu_Flags;
|
||||||
|
|
||||||
typedef struct _E_Fm2_Config E_Fm2_Config;
|
typedef struct _E_Fm2_Config E_Fm2_Config;
|
||||||
|
|
|
@ -1340,6 +1340,11 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
|
||||||
_e_fm_slave_run(E_FM_OP_COPY, (const char *)e->data, e->ref);
|
_e_fm_slave_run(E_FM_OP_COPY, (const char *)e->data, e->ref);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case E_FM_OP_SYMLINK: /* fop ln -s */
|
||||||
|
{
|
||||||
|
_e_fm_slave_run(E_FM_OP_SYMLINK, (const char *)e->data, e->ref);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case E_FM_OP_MKDIR: /* fop mkdir */
|
case E_FM_OP_MKDIR: /* fop mkdir */
|
||||||
{
|
{
|
||||||
const char *src, *rel;
|
const char *src, *rel;
|
||||||
|
@ -1422,21 +1427,6 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case E_FM_OP_SYMLINK: /* dop ln -s */
|
|
||||||
{
|
|
||||||
const char *src, *dst, *rel;
|
|
||||||
int rel_to, x, y;
|
|
||||||
|
|
||||||
src = e->data;
|
|
||||||
dst = src + strlen(src) + 1;
|
|
||||||
rel = dst + strlen(dst) + 1;
|
|
||||||
memcpy(&rel_to, rel + strlen(rel) + 1, sizeof(int));
|
|
||||||
memcpy(&x, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
|
|
||||||
memcpy(&y, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
|
|
||||||
ecore_file_symlink(src, dst);
|
|
||||||
/* FIXME: send back file add if succeeded */
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
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:
|
||||||
case E_FM_OP_ERROR_RESPONSE_ABORT:
|
case E_FM_OP_ERROR_RESPONSE_ABORT:
|
||||||
|
@ -2151,14 +2141,18 @@ _e_prepare_command(E_Fm_Op_Type type, const char *args)
|
||||||
{
|
{
|
||||||
char *buffer;
|
char *buffer;
|
||||||
unsigned int length = 0;
|
unsigned int length = 0;
|
||||||
char command[3];
|
char command[4];
|
||||||
|
|
||||||
if (type == E_FM_OP_MOVE)
|
if (type == E_FM_OP_MOVE)
|
||||||
strcpy(command, "mv");
|
strcpy(command, "mv");
|
||||||
else if (type == E_FM_OP_REMOVE)
|
else if (type == E_FM_OP_REMOVE)
|
||||||
strcpy(command, "rm");
|
strcpy(command, "rm");
|
||||||
else
|
else if (type == E_FM_OP_COPY)
|
||||||
strcpy(command, "cp");
|
strcpy(command, "cp");
|
||||||
|
else if (type == E_FM_OP_SYMLINK)
|
||||||
|
strcpy(command, "lns");
|
||||||
|
else
|
||||||
|
strcpy(command, "???");
|
||||||
|
|
||||||
length = 256 + strlen(getenv("E_LIB_DIR")) + strlen(args);
|
length = 256 + strlen(getenv("E_LIB_DIR")) + strlen(args);
|
||||||
buffer = malloc(length);
|
buffer = malloc(length);
|
||||||
|
|
|
@ -66,6 +66,7 @@ static int _e_fm_op_copy_chunk(E_Fm_Op_Task *task);
|
||||||
static int _e_fm_op_copy_atom(E_Fm_Op_Task * task);
|
static int _e_fm_op_copy_atom(E_Fm_Op_Task * task);
|
||||||
static int _e_fm_op_scan_atom(E_Fm_Op_Task * task);
|
static int _e_fm_op_scan_atom(E_Fm_Op_Task * task);
|
||||||
static int _e_fm_op_copy_stat_info_atom(E_Fm_Op_Task * task);
|
static int _e_fm_op_copy_stat_info_atom(E_Fm_Op_Task * task);
|
||||||
|
static int _e_fm_op_symlink_atom(E_Fm_Op_Task * task);
|
||||||
static int _e_fm_op_remove_atom(E_Fm_Op_Task * task);
|
static int _e_fm_op_remove_atom(E_Fm_Op_Task * task);
|
||||||
|
|
||||||
Ecore_Fd_Handler *_e_fm_op_stdin_handler = NULL;
|
Ecore_Fd_Handler *_e_fm_op_stdin_handler = NULL;
|
||||||
|
@ -152,9 +153,11 @@ main(int argc, char **argv)
|
||||||
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;
|
||||||
|
else if (strcmp(argv[1], "lns") == 0)
|
||||||
|
type = E_FM_OP_SYMLINK;
|
||||||
else return 0;
|
else return 0;
|
||||||
|
|
||||||
if ((type == E_FM_OP_COPY) || (type == E_FM_OP_MOVE))
|
if ((type == E_FM_OP_COPY) || (type == E_FM_OP_MOVE) || (type == E_FM_OP_SYMLINK))
|
||||||
{
|
{
|
||||||
if (argc < 4) goto quit;
|
if (argc < 4) goto quit;
|
||||||
|
|
||||||
|
@ -189,6 +192,9 @@ main(int argc, char **argv)
|
||||||
if ((type == E_FM_OP_MOVE) &&
|
if ((type == E_FM_OP_MOVE) &&
|
||||||
(rename(task->src.name, task->dst.name) == 0))
|
(rename(task->src.name, task->dst.name) == 0))
|
||||||
_e_fm_op_task_free(task);
|
_e_fm_op_task_free(task);
|
||||||
|
else if ((type == E_FM_OP_SYMLINK) &&
|
||||||
|
(symlink(task->src.name, task->dst.name) == 0))
|
||||||
|
_e_fm_op_task_free(task);
|
||||||
else
|
else
|
||||||
_e_fm_op_scan_queue =
|
_e_fm_op_scan_queue =
|
||||||
eina_list_append(_e_fm_op_scan_queue, task);
|
eina_list_append(_e_fm_op_scan_queue, task);
|
||||||
|
@ -214,7 +220,10 @@ main(int argc, char **argv)
|
||||||
/* Try a rename */
|
/* Try a rename */
|
||||||
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;
|
||||||
|
else if ((type == E_FM_OP_SYMLINK) &&
|
||||||
|
(symlink(task->src.name, task->dst.name) == 0))
|
||||||
|
goto quit;
|
||||||
|
|
||||||
/* If that does work, setup a copy and delete operation.
|
/* If that does work, setup a copy and delete operation.
|
||||||
It's not atomic, but it's the best we can do. */
|
It's not atomic, but it's the best we can do. */
|
||||||
task = _e_fm_op_task_new();
|
task = _e_fm_op_task_new();
|
||||||
|
@ -613,6 +622,8 @@ _e_fm_op_work_idler(void *data)
|
||||||
_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);
|
||||||
|
else if (task->type == E_FM_OP_SYMLINK)
|
||||||
|
_e_fm_op_symlink_atom(task);
|
||||||
|
|
||||||
if (task->finished)
|
if (task->finished)
|
||||||
{
|
{
|
||||||
|
@ -1338,6 +1349,19 @@ _e_fm_op_scan_atom(E_Fm_Op_Task * task)
|
||||||
|
|
||||||
ctask->link = _e_fm_op_separator->next;
|
ctask->link = _e_fm_op_separator->next;
|
||||||
}
|
}
|
||||||
|
else if (task->type == E_FM_OP_SYMLINK)
|
||||||
|
{
|
||||||
|
_e_fm_op_update_progress(NULL, 0, REMOVECHUNKSIZE);
|
||||||
|
|
||||||
|
rtask = _e_fm_op_task_new();
|
||||||
|
rtask->src.name = eina_stringshare_add(task->src.name);
|
||||||
|
memcpy(&(rtask->src.st), &(task->src.st), sizeof(struct stat));
|
||||||
|
if (task->dst.name)
|
||||||
|
rtask->dst.name = eina_stringshare_add(task->dst.name);
|
||||||
|
rtask->type = E_FM_OP_SYMLINK;
|
||||||
|
|
||||||
|
_e_fm_op_work_queue = eina_list_prepend(_e_fm_op_work_queue, rtask);
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1356,6 +1380,23 @@ _e_fm_op_copy_stat_info_atom(E_Fm_Op_Task * task)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_e_fm_op_symlink_atom(E_Fm_Op_Task *task)
|
||||||
|
{
|
||||||
|
if (_e_fm_op_abort) return 1;
|
||||||
|
|
||||||
|
E_FM_OP_DEBUG("Symlink: %s -> %s\n", task->src.name, task->dst.name);
|
||||||
|
|
||||||
|
if (symlink(task->src.name, task->dst.name) != 0)
|
||||||
|
_E_FM_OP_ERROR_SEND_WORK(task, E_FM_OP_ERROR, "Cannot create link from '%s' to '%s': %s.", task->src.name, task->dst.name);
|
||||||
|
|
||||||
|
task->dst.done += REMOVECHUNKSIZE;
|
||||||
|
_e_fm_op_update_progress(task, REMOVECHUNKSIZE, 0);
|
||||||
|
task->finished = 1;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_e_fm_op_remove_atom(E_Fm_Op_Task * task)
|
_e_fm_op_remove_atom(E_Fm_Op_Task * task)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue