This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efm2.
View the commit online.
commit 72fea7759a3b294cda26237ece193d577ce11a3c
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
AuthorDate: Tue Mar 26 08:30:48 2024 +0000
more work on meta stuff and comments and mv
---
src/backends/default/meta.c | 17 ++++++-----
src/backends/default/mv.c | 73 +++++++++++++++++++++++----------------------
src/backends/default/open.c | 55 +++++++++++++++++-----------------
3 files changed, 74 insertions(+), 71 deletions(-)
diff --git a/src/backends/default/meta.c b/src/backends/default/meta.c
index 5870252..6ac8ce8 100644
--- a/src/backends/default/meta.c
+++ b/src/backends/default/meta.c
@@ -129,6 +129,7 @@ _meta_file_write(Meta_File *mf)
if (mf->list)
{
// XXX: should gain a lock!
+ // XXX: should write to tmp then rename atomically
f = fopen(meta_path, "w");
if (!f)
{ // can't write to dir - write to personal meta instead
@@ -137,7 +138,7 @@ _meta_file_write(Meta_File *mf)
if (!meta_path) return;
dir = ecore_file_dir_get(meta_path);
if (!dir) return;
- ecore_file_mkpath(dir);
+ if (!ecore_file_is_dir(dir)) ecore_file_mkpath(dir);
free(dir);
dir = NULL;
f = fopen(meta_path, "w");
@@ -145,7 +146,9 @@ _meta_file_write(Meta_File *mf)
}
fprintf(f, "[Efm Meta]\n");
EINA_LIST_FOREACH(mf->list, l, m)
- fprintf(f, "%s=%s\n", m->meta, m->data);
+ {
+ fprintf(f, "%s=%s\n", m->meta, m->data);
+ }
fclose(f);
}
else // no meta keys - delete it
@@ -170,7 +173,7 @@ _cb_meta_flush_timer(void *data EINA_UNUSED)
_meta_flush_timer = NULL;
_meta_writes_flush();
// XXX: if flush took too long - queue another timer and try flush again
- // in future. repeate until nothing left to flush
+ // in future. repeat until nothing left to flush
return EINA_FALSE;
}
@@ -394,7 +397,7 @@ meta_path_prepare(const char *path)
Eina_Bool
meta_path_can_write(const char *path)
-{ // can we write to the taget dir of "path" file for meta data?
+{ // can we write to the target dir of "path" file for meta data?
// yes - this is racey. but then again anything is. we could make a
// .efm dir then have permission removed before we make the subdiors
// or meta files. anything that involves more than a single file and
@@ -410,8 +413,8 @@ meta_path_can_write(const char *path)
if (!dir) return ret;
if (stat(dir, &st) == -1) goto err;
- // policy - we only cosider direst owned by the user writable. want to
- // avoid e.g. root browsing then modifying dirs owne by a user or dirs
+ // policy - we only consider dirs owned by the user writeable. want to
+ // avoid e.g. root browsing then modifying dirs ownee by a user or dirs
// that might have group write access being written to by multiple users
if ((st.st_uid == uid) && (st.st_mode & S_IWUSR))
{
@@ -440,4 +443,4 @@ meta_path_can_write(const char *path)
err:
free(dir);
return ret;
-}
+}
\ No newline at end of file
diff --git a/src/backends/default/mv.c b/src/backends/default/mv.c
index a015c54..ae40562 100644
--- a/src/backends/default/mv.c
+++ b/src/backends/default/mv.c
@@ -18,13 +18,14 @@
static const char *config_dir = NULL;
+
+
int
main(int argc, char **argv)
{
// mv [src] [dst]
const char *src, *dst, *fname, *home_dir;
- char *fdir;
- Eina_Strbuf *buf = NULL, *buf2 = NULL;
+ Eina_Strbuf *buf = NULL;
if (argc < 3) return -1;
src = ""
@@ -39,10 +40,10 @@ main(int argc, char **argv)
if (!home_dir) return 77; // no $HOME? definitely an error!
if (!config_dir)
{
- char buf[PATH_MAX];
+ char sbuf[PATH_MAX];
- snprintf(buf, sizeof(buf), "%s/.e/e", home_dir);
- config_dir = eina_stringshare_add(buf);
+ snprintf(sbuf, sizeof(sbuf), "%s/.e/e", home_dir);
+ config_dir = eina_stringshare_add(sbuf);
}
meta_init(config_dir);
@@ -121,49 +122,49 @@ main(int argc, char **argv)
break;
case EROFS: // read only disk
break;
- case EXDEV: // revert to cp -par
- break;
+ case EXDEV: // revert t640k
default: // WAT???
break;
}
}
else
{
+ Eina_Bool src_can_write, dst_can_write;
+ const char *dstfile;
+ char *src_meta, *dst_meta;
+
fprintf(stderr, "MV: OK\n");
- // XXX: use meta_path_find() or meta_path_user_find() based on
- // XXX: meta_path_can_write() and prep the dest with meta_path_prepare()
- fdir = ecore_file_dir_get(src);
- if (fdir)
+
+ dstfile = eina_strbuf_string_get(buf);
+
+ src_can_write = meta_path_can_write(src);
+ dst_can_write = meta_path_can_write(eina_strbuf_string_get(buf));
+
+ if (src_can_write) src_meta = meta_path_find(src, "meta.efm");
+ else src_meta = meta_path_user_find(src, "meta.efm");
+ if (dst_can_write) dst_meta = meta_path_find(dstfile, "meta.efm");
+ else dst_meta = meta_path_user_find(dstfile, "meta.efm");
+ if ((src_meta) && (dst_meta) && (meta_path_prepare(dstfile)))
{
- // mv the efm meta file if it exists...
- buf2 = eina_strbuf_new();
-
- // XXX" if buf2 is null?
- eina_strbuf_append(buf2, dst);
- eina_strbuf_append(buf2, "/.efm");
- ecore_file_mkdir(eina_strbuf_string_get(buf2));
-
- eina_strbuf_reset(buf2);
- eina_strbuf_append(buf2, fdir);
- eina_strbuf_append(buf2, "/.efm/");
- eina_strbuf_append(buf2, fname);
- eina_strbuf_append(buf2, ".efm");
-
- eina_strbuf_reset(buf);
- eina_strbuf_append(buf, dst);
- eina_strbuf_append(buf, "/.efm/");
- eina_strbuf_append(buf, fname);
- eina_strbuf_append(buf, ".efm");
- // XXX: what if the target meta file already exists???
- rename(eina_strbuf_string_get(buf2), eina_strbuf_string_get(buf));
- free(fdir);
- // XXX: mv meta if in ~/.e/e/efm/meta
- // XXX: mv thumb files in /.e/e/efm/thumbs
+ // XXX: use mv() rename wrapper than will cp
+ rename(src_meta, dst_meta);
}
+ free(src_meta);
+ free(dst_meta);
+ if (src_can_write) src_meta = meta_path_find(src, "thumb.efm");
+ else src_meta = meta_path_user_find(src, "thumb.efm");
+ if (dst_can_write) dst_meta = meta_path_find(dstfile, "thumb.efm");
+ else dst_meta = meta_path_user_find(dstfile, "thumb.efm");
+ if ((src_meta) && (dst_meta) && (meta_path_prepare(dstfile)))
+ {
+ // XXX: use mv() rename wrapper than will cp
+ rename(src_meta, dst_meta);
+ }
+ free(src_meta);
+ free(dst_meta);
}
err:
if (buf) eina_strbuf_free(buf);
- if (buf2) eina_strbuf_free(buf2);
// XXX: delete status file
meta_shutdown();
diff --git a/src/backends/default/open.c b/src/backends/default/open.c
index dedaa27..531ccb6 100644
--- a/src/backends/default/open.c
+++ b/src/backends/default/open.c
@@ -538,7 +538,7 @@ _file_thumb_handle(Eina_Strbuf *strbuf, const char *path, const char *mime,
else
{ // add the thumb property with full path to thumb
cmd_strbuf_append(strbuf, "thumb", thumb);
- // XXX: add if tumb has alpha or not...
+ // XXX: add if thumb has alpha or not...
free(thumb);
}
}
@@ -637,6 +637,17 @@ _mime_get(const char *file)
return efreet_mime_type_get(file);
}
+static void
+_file_add_mod_meta_append(const char *path, const char *meta, const char *key,
+ Eina_Strbuf *strbuf)
+{
+ Eina_Stringshare *s = meta_get(path, meta);
+
+ if (!s) return;
+ cmd_strbuf_append(strbuf, key, s);
+ eina_stringshare_del(s);
+}
+
static Eina_Bool
_file_add_mod_info(Eina_Strbuf *strbuf, const char *path, Eina_Bool delay)
{ // add file metadata info on file add or modfiy
@@ -648,8 +659,6 @@ _file_add_mod_info(Eina_Strbuf *strbuf, const char *path, Eina_Bool delay)
const char *mime, *ext, *icon;
Efreet_Desktop *desktop;
Eina_Bool have_label = EINA_FALSE;
- Eina_Stringshare *s;
- // XXX: x & y pos @ wxh view
if (lstat(path, &st) != 0) return EINA_FALSE;
if ((st.st_mode & S_IFMT) == S_IFLNK)
@@ -1051,18 +1060,9 @@ _file_add_mod_info(Eina_Strbuf *strbuf, const char *path, Eina_Bool delay)
cmd_strbuf_append(strbuf, "mtime", buf);
snprintf(buf, sizeof(buf), "%llu", (unsigned long long)st.st_ctime);
cmd_strbuf_append(strbuf, "ctime", buf);
- s = meta_get(path, "xy");
- if (s)
- {
- cmd_strbuf_append(strbuf, "meta.xy", s);
- eina_stringshare_del(s);
- }
- s = meta_get(path, "wh");
- if (s)
- {
- cmd_strbuf_append(strbuf, "meta.wh", s);
- eina_stringshare_del(s);
- }
+ // add extra meta keys that might be used for immediate icon/file display
+ _file_add_mod_meta_append(path, "xy", "meta.xy", strbuf);
+ _file_add_mod_meta_append(path, "wh", "meta.wh", strbuf);
return EINA_TRUE;
}
@@ -1197,7 +1197,7 @@ _monitor(const char *path)
can_write = meta_path_can_write(eina_strbuf_string_get(strbuf));
if (strbuf) eina_strbuf_free(strbuf);
- // tell the front end out listing is beginning
+ // tell the front end our listing is beginning
strbuf = cmd_strbuf_new("list-begin");
cmd_strbuf_print_consume(strbuf);
@@ -1211,7 +1211,7 @@ _monitor(const char *path)
EINA_ITERATOR_FOREACH(it, info) _file_add(info->path);
eina_iterator_free(it);
err:
- // tell the front end out listing is done
+ // tell the front end our listing is done
strbuf = cmd_strbuf_new("list-end");
cmd_strbuf_print_consume(strbuf);
}
@@ -1266,7 +1266,7 @@ _handle_drop_paste(const char *over, const char *action, const char *path)
mondir = ecore_file_monitor_path_get(mon);
if (!mondir) return;
if (over)
- { // if you are dropping over a dir then spint up a sub open and pass
+ { // if you are dropping over a dir then spin up a sub open and pass
// the dnd to it
Eina_Strbuf *strbuf;
Sub *sub;
@@ -1285,24 +1285,24 @@ _handle_drop_paste(const char *over, const char *action, const char *path)
fprintf(stderr, "DROP in [%s] action="" > [%s]\n", mondir, action,
path);
if ((!action) || (!strcmp(action, "copy")))
- {
+ { // XXX: implement
}
else if (!strcmp(action, "move"))
_op_run("mv", path, mondir);
else if (!strcmp(action, "ask"))
- {
+ { // XXX: implement
}
else if (!strcmp(action, "list"))
- {
+ { // XXX: implement
}
else if (!strcmp(action, "link"))
- {
+ { // XXX: implement
}
else if (!strcmp(action, "description"))
- {
+ { // XXX: implement
}
else
- {
+ { // XXX: implement
}
}
}
@@ -1407,8 +1407,7 @@ do_handle_cmd(Cmd *c)
KEY_WALK_END
}
else if (!strcmp(c->command, "dnd-drop"))
- {
- // "over" key means dnd was on that dir
+ { // "over" key means dnd was on that dir
const char *over = cmd_key_find(c, "over");
const char *action = "" "action");
@@ -1427,7 +1426,7 @@ do_handle_cmd(Cmd *c)
KEY_WALK_END
}
else if (!strcmp(c->command, "cnp-paste"))
- {
+ { // XXX: implement
}
// cmd_dump_sterr(c);
}
@@ -1453,7 +1452,7 @@ do_init(int argc EINA_UNUSED, const char **argv EINA_UNUSED)
config_dir = eina_stringshare_add(buf);
}
- // maximum number of back-end thumbnailer slaves is num cores - 2
+ // maximum number of back-end thumbnailer slaves is num_cores - 2
// with a minimum of 1 (so dual core systems will be limited to 1
// thumbnailer at once. quad core will run 2. 8 core will run 6, 16
// core will run 14, 32 core will run 30 etc. - this can get overidden
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.