Ephoto: Properly identify symlinks and handle them accordingly.
This commit is contained in:
parent
d996dd64e3
commit
421483d5d7
|
@ -311,11 +311,13 @@ struct _Ephoto_Entry
|
||||||
double size;
|
double size;
|
||||||
Ephoto *ephoto;
|
Ephoto *ephoto;
|
||||||
Eio_Monitor *monitor;
|
Eio_Monitor *monitor;
|
||||||
|
Eio_Monitor *link_monitor;
|
||||||
Eina_List *monitor_handlers;
|
Eina_List *monitor_handlers;
|
||||||
Elm_Object_Item *item;
|
Elm_Object_Item *item;
|
||||||
Elm_Object_Item *parent;
|
Elm_Object_Item *parent;
|
||||||
Eina_List *free_listeners;
|
Eina_List *free_listeners;
|
||||||
Eina_Bool is_dir;
|
Eina_Bool is_dir;
|
||||||
|
Eina_Bool is_link;
|
||||||
Eina_Bool no_delete;
|
Eina_Bool no_delete;
|
||||||
Evas_Object *genlist;
|
Evas_Object *genlist;
|
||||||
};
|
};
|
||||||
|
|
|
@ -754,28 +754,37 @@ _delete_thread_cb(void *data, Ecore_Thread *et EINA_UNUSED)
|
||||||
{
|
{
|
||||||
char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX];
|
char dest[PATH_MAX], fp[PATH_MAX], extra[PATH_MAX];
|
||||||
int ret;
|
int ret;
|
||||||
|
struct stat s;
|
||||||
|
|
||||||
snprintf(fp, PATH_MAX, "%s", file);
|
lstat(file, &s);
|
||||||
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
|
if (S_ISLNK(s.st_mode))
|
||||||
if (ecore_file_exists(dest))
|
{
|
||||||
{
|
ret = ecore_file_unlink(file);
|
||||||
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
|
}
|
||||||
basename(fp));
|
|
||||||
if (ecore_file_exists(extra))
|
|
||||||
{
|
|
||||||
int count;
|
|
||||||
|
|
||||||
for (count = 2; ecore_file_exists(extra); count++)
|
|
||||||
{
|
|
||||||
memset(extra, 0, sizeof(extra));
|
|
||||||
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
|
|
||||||
destination, count, basename(fp));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ret = ecore_file_mv(file, extra);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
ret = ecore_file_mv(file, dest);
|
{
|
||||||
|
snprintf(fp, PATH_MAX, "%s", file);
|
||||||
|
snprintf(dest, PATH_MAX, "%s/%s", destination, basename(fp));
|
||||||
|
if (ecore_file_exists(dest))
|
||||||
|
{
|
||||||
|
snprintf(extra, PATH_MAX, "%s/CopyOf%s", destination,
|
||||||
|
basename(fp));
|
||||||
|
if (ecore_file_exists(extra))
|
||||||
|
{
|
||||||
|
int count;
|
||||||
|
|
||||||
|
for (count = 2; ecore_file_exists(extra); count++)
|
||||||
|
{
|
||||||
|
memset(extra, 0, sizeof(extra));
|
||||||
|
snprintf(extra, PATH_MAX, "%s/Copy%dOf%s",
|
||||||
|
destination, count, basename(fp));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = ecore_file_mv(file, extra);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ret = ecore_file_mv(file, dest);
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ephoto->file_errors++;
|
ephoto->file_errors++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1088,6 +1088,11 @@ ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label,
|
||||||
entry->is_dir = EINA_TRUE;
|
entry->is_dir = EINA_TRUE;
|
||||||
else
|
else
|
||||||
entry->is_dir = EINA_FALSE;
|
entry->is_dir = EINA_FALSE;
|
||||||
|
if (type == EINA_FILE_LNK)
|
||||||
|
entry->is_link = EINA_TRUE;
|
||||||
|
else
|
||||||
|
entry->is_link = EINA_FALSE;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1132,6 +1137,8 @@ ephoto_entry_free(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||||
eina_stringshare_del(entry->label);
|
eina_stringshare_del(entry->label);
|
||||||
if (entry->monitor)
|
if (entry->monitor)
|
||||||
{
|
{
|
||||||
|
if (entry->link_monitor)
|
||||||
|
eio_monitor_del(entry->link_monitor);
|
||||||
eio_monitor_del(entry->monitor);
|
eio_monitor_del(entry->monitor);
|
||||||
EINA_LIST_FREE(entry->monitor_handlers, handler)
|
EINA_LIST_FREE(entry->monitor_handlers, handler)
|
||||||
ecore_event_handler_del(handler);
|
ecore_event_handler_del(handler);
|
||||||
|
|
Loading…
Reference in New Issue