diff options
author | Stefan Schmidt <s.schmidt@samsung.com> | 2020-03-17 17:08:40 +0100 |
---|---|---|
committer | Stefan Schmidt <s.schmidt@samsung.com> | 2020-03-20 12:04:37 +0100 |
commit | 2754bc93e684c6ed9a6c3ff6b81c759f830f6210 (patch) | |
tree | 76061bffaa4450b75292d8626690df39581ae74b | |
parent | b84694f5189f86e223c68695366c0d676d8fc6a4 (diff) | |
download | efl-2754bc93e684c6ed9a6c3ff6b81c759f830f6210.tar.gz |
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 <michael.blumenkrantz@gmail.com>
Differential Revision: https://phab.enlightenment.org/D11458
-rw-r--r-- | src/bin/exactness/player.c | 31 | ||||
-rw-r--r-- | 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; |