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 de7f9a21a3bb96f61ec0787f919d3b24a59e668f
Author: Carsten Haitzler (Rasterman)
AuthorDate: Thu Apr 11 10:01:45 2024 +0100
more work on mv - file count scan, status infra etc
also clean up some #includes we dont need... get this into git so it
isnt lost
---
src/backends/default/meta.c | 1 -
src/backends/default/mv.c | 183 ++---
src/backends/default/open.c | 1 -
src/backends/default/status.c | 266 ++
src/backends/default/status.h | 32 +
src/efm/efm_graph.c | 1 -
6 files changed, 440 insertions(+), 44 deletions(-)
diff --git a/src/backends/default/meta.c b/src/backends/default/meta.c
index 6ac8ce8..46fddb9 100644
--- a/src/backends/default/meta.c
+++ b/src/backends/default/meta.c
@@ -4,7 +4,6 @@
#include
#include
#include
-#include "eina_types.h"
#include "sha.h"
#include "meta.h"
diff --git a/src/backends/default/mv.c b/src/backends/default/mv.c
index abc9873..bda92dd 100644
--- a/src/backends/default/mv.c
+++ b/src/backends/default/mv.c
@@ -5,35 +5,163 @@
#include
#include
-#include
#include
+#include
#include
#include
#include
+#include
-#include "cmd.h"
#include "eina_strbuf.h"
+#include "eina_thread.h"
#include "eina_types.h"
-#include "sha.h"
#include "meta.h"
#include "status.h"
static const char *config_dir = NULL;
+// this scans a tree to build a potential operation progress count. it may
+// not be 100% right as the fs can change while the scan happens and after
+// so any move that devolves into a cp + rm isn't going to be atomic and
+// handle a changing fs while it works anyway
+static Eina_Bool
+fs_scan(const char *src)
+{
+ Eina_Iterator *it;
+ const char *s;
+
+ if (strlen(src) < 1) return EINA_FALSE;
+ struct stat st;
+
+ if (lstat(src, ) != 0)
+{
+ switch (errno)
+{
+case EACCES:
+ status_error(src, NULL, "Move - Permission denied for source");
+ return EINA_FALSE;
+ break;
+case EFAULT:
+ status_error(src, NULL, "Move - Memory Fault");
+ return EINA_FALSE;
+ break;
+case ELOOP:
+ status_error(src, NULL, "Move - Too many symlinks");
+ return EINA_FALSE;
+ break;
+case ENAMETOOLONG:
+ status_error(src, NULL, "Move - Name too long");
+ return EINA_FALSE;
+ break;
+case ENOENT: // ignore this error - file removed during scan ?
+ return EINA_TRUE;
+ break;
+case ENOMEM:
+ status_error(src, NULL, "Move - Out of memory");
+ return EINA_FALSE;
+ break;
+case ENOTDIR:
+ status_error(src, NULL, "Move - Source path component is not a directory");
+ return EINA_FALSE;
+ break;
+case EOVERFLOW:
+ status_error(src, NULL, "Move - Overflow");
+ return EINA_FALSE;
+ break;
+default:
+ break;
+}
+}
+ if (S_ISDIR(st.st_mode))
+{ // it's a dir - scan this recursively
+ it = eina_file_ls(src);
+ if (it)
+{
+ Eina_Strbuf *buf;
+
+ buf = eina_strbuf_new();
+ EINA_ITERATOR_FOREACH(it, s)
+ {
+// build new path "src/s"
+eina_strbuf_reset(buf);
+eina_strbuf_append(buf, src);
+// add / if src doesn't end in /
+if (src[strlen(src) - 1] != '/') eina_strbuf_append(buf, "/");
+eina_strbuf_append(buf, s);
+eina_stringshare_del(s);
+// fs_scan this file (or dir)
+// yes - this returns. we make leak our eina_file_ls data, strbuf etc.
+// dont care - we're going to exit the whole process in a bit
+if (!fs_scan(eina_strbuf_string_get(buf))) return EINA_FALSE;
+ }
+ eina_strbuf_free(buf);
+}
+}
+ else
+{
+ // the file itself count as 1 progress item - useful if it's a symlink
+ // or a char or block device etc.
+ status_count(1, ecore_file_file_get(src));
+ // in addition each byte in the file count as a progress item too
+ if (st.st_size > 0)
+status_count(st.st_size, ecore_file_file_get(src));
+}
+ return EINA_TRUE;
+}
+
+static Eina_Bool
+fs_cp_rm(const char *src, const char *dst, Eina_Bool report_err)
+{
+ Eina_Bool res = EINA_TRUE;
+
+ if (!fs_scan(src)) return EINA_FALSE;
+
+ // if src is dir
+ // fs_mkdir(dst)
+ // for all files in src
+ // fs_cp_rm(src/file, dst/file, report_err)
+ // fs_utimes(src, dst)
+ // fs_chmod(src, dst)
+ // fs_chown(src, dst)
+ // fs_utimes(src, dst)
+ // fs_chmod(src, dst)
+ // fs_chown(src, dst)
+ // fs_rmdir(src)
+ // else
+ // if (src is file)
+ //