stefan pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=2754bc93e684c6ed9a6c3ff6b81c759f830f6210
commit 2754bc93e684c6ed9a6c3ff6b81c759f830f6210 Author: Stefan Schmidt <[email protected]> Date: Tue Mar 17 17:08:40 2020 +0100 exactness: factor out the special _mkdir() handling We have an ecore function to handle most of this already. For the case where we give a file name cut off that part before handing it off to creation. Reviewed-by: Mike Blumenkrantz <[email protected]> Differential Revision: https://phab.enlightenment.org/D11458 --- src/bin/exactness/player.c | 31 +++++++------------------------ src/bin/exactness/recorder.c | 22 +--------------------- 2 files changed, 8 insertions(+), 45 deletions(-) diff --git a/src/bin/exactness/player.c b/src/bin/exactness/player.c index ff500fcd8d..f95008f616 100644 --- a/src/bin/exactness/player.c +++ b/src/bin/exactness/player.c @@ -803,27 +803,6 @@ _src_open() return EINA_TRUE; } -static Eina_Bool -_mkdir(const char *path, Eina_Bool skip_last) -{ - if (!ecore_file_exists(path)) - { - const char *cur = path + 1; - do - { - char *slash = strchr(cur, '/'); - if (slash) *slash = '\0'; - else if (skip_last) return EINA_TRUE; - if (!ecore_file_exists(path) && !ecore_file_mkdir(path)) return EINA_FALSE; - if (slash) *slash = '/'; - if (slash) cur = slash + 1; - else cur = NULL; - } - while (cur); - } - return EINA_TRUE; -} - static void _old_shots_rm_cb(const char *name, const char *path, void *data) { @@ -988,16 +967,20 @@ int main(int argc, char **argv) if (!strcmp(_dest + strlen(_dest) - 4,".exu")) { _dest_type = FTYPE_EXU; - if (!_mkdir(_dest, EINA_TRUE)) + /* Cut path at the beginning of the file name */ + char *file_start = strrchr(dest, '/'); + *file_start = '\0'; + + if (!ecore_file_mkpath(dest)) { - fprintf(stderr, "Path for %s cannot be created\n", _dest); + fprintf(stderr, "Path for %s cannot be created\n", dest); goto end; } } else { _dest_type = FTYPE_DIR; - if (!_mkdir(_dest, EINA_FALSE)) + if (!ecore_file_mkpath(_dest)) { fprintf(stderr, "Directory %s cannot be created\n", _dest); goto end; diff --git a/src/bin/exactness/recorder.c b/src/bin/exactness/recorder.c index 965a88fb24..57c0b208c0 100644 --- a/src/bin/exactness/recorder.c +++ b/src/bin/exactness/recorder.c @@ -235,26 +235,6 @@ _my_evas_new(int w EINA_UNUSED, int h EINA_UNUSED) return e; } -static Eina_Bool -_mkdir(const char *dir) -{ - if (!ecore_file_exists(dir)) - { - const char *cur = dir + 1; - do - { - char *slash = strchr(cur, '/'); - if (slash) *slash = '\0'; - if (!ecore_file_exists(dir) && !ecore_file_mkdir(dir)) return EINA_FALSE; - if (slash) *slash = '/'; - if (slash) cur = slash + 1; - else cur = NULL; - } - while (cur); - } - return EINA_TRUE; -} - static const Ecore_Getopt optdesc = { "exactness_record", "%prog [options] <-v|-t|-h> command", @@ -343,7 +323,7 @@ int main(int argc, char **argv) if (slash) { *slash = '\0'; - if (!_mkdir(_out_filename)) + if (!ecore_file_mkpath(_out_filename)) { fprintf(stderr, "Can't create %s\n", _out_filename); goto end; --
