Hi all,
here is a patch for the randomization in
e/src/bin/e_fm_op.c.
I. Simplification, andif we cannot stat(), the best
thing to do is toswitch to a copy-delete operation.
II.Just stuff...
III. There is a problem with _e_fm_op_random_char().
When wewant to randomize a string we do srand(time())
foreachcharacter, so if the file is small enough
to be deleted inless than a second, it's not randomized.
And even if it's bigger, it's not goodly randomized.Sorry.
Thanks
--- e_fm_op.c Sat Oct 20 16:28:10 2012
+++ e_fm_op.c Sat Oct 20 16:26:55 2012
@@ -106,7 +106,7 @@
static int _e_fm_op_rename_atom(E_Fm_Op_Task *task);
static int _e_fm_op_destroy_atom(E_Fm_Op_Task *task);
static void _e_fm_op_random_buf(char *buf, ssize_t len);
-static char _e_fm_op_random_char();
+static void _e_fm_op_random_char(char *buf, size_t len);
Eina_List *_e_fm_op_work_queue = NULL, *_e_fm_op_scan_queue = NULL;
Ecore_Idler *_e_fm_op_work_idler_p = NULL, *_e_fm_op_scan_idler_p = NULL;
@@ -311,12 +311,11 @@
if ((stat(argv[i], &st1) == 0) &&
(stat(buf, &st2) == 0))
{
- /* if files are on the same device */
- if (st1.st_dev == st2.st_dev)
- type = E_FM_OP_RENAME;
- else
+ /* if files are not on the same device */
+ if (st1.st_dev != st2.st_dev)
type = E_FM_OP_MOVE;
}
+ else type = E_FM_OP_MOVE;
}
}
@@ -1661,7 +1660,6 @@
return 0;
}
-/* EXPERIMENTAL */
static int
_e_fm_op_destroy_atom(E_Fm_Op_Task *task)
{
@@ -1691,7 +1689,7 @@
if (st2.st_dev != task->src.st.st_dev ||
st2.st_ino != task->src.st.st_ino ||
- !S_ISREG(st2.st_mode))
+ st2.st_mode != task->src.st.st_mode)
goto finish;
if ((buf = malloc(READBUFSIZE)) == NULL)
@@ -1744,32 +1742,28 @@
_e_fm_op_random_buf(char *buf, ssize_t len)
{
int f = -1;
- ssize_t i;
if ((f = open("/dev/urandom", O_RDONLY)) == -1)
{
- for (i = 0; i < len; i++)
- {
- buf[i] = _e_fm_op_random_char();
- }
- return;
+ _e_fm_op_random_char(buf, len);
+ return;
}
if (read(f, buf, len) != len)
- {
- for (i = 0; i < len; i++)
- {
- buf[i] = _e_fm_op_random_char();
- }
- }
+ _e_fm_op_random_char(buf, len);
close(f);
return;
}
-static char
-_e_fm_op_random_char()
+static void
+_e_fm_op_random_char(char *buf, size_t len)
{
+ size_t i;
srand((unsigned int)time(NULL));
- return (rand() % 256) + 'a';
+
+ for (i = 0; i < len; i++)
+ {
+ buf[i] = (rand() % 256) + 'a';
+ }
}
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_sfd2d_oct
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel