summaryrefslogtreecommitdiff
path: root/src/bin/exactness/player.c
diff options
context:
space:
mode:
authorStefan Schmidt <s.schmidt@samsung.com>2020-03-17 17:08:40 +0100
committerStefan Schmidt <s.schmidt@samsung.com>2020-03-20 12:04:37 +0100
commit2754bc93e684c6ed9a6c3ff6b81c759f830f6210 (patch)
tree76061bffaa4450b75292d8626690df39581ae74b /src/bin/exactness/player.c
parentb84694f5189f86e223c68695366c0d676d8fc6a4 (diff)
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
Diffstat (limited to 'src/bin/exactness/player.c')
-rw-r--r--src/bin/exactness/player.c31
1 files changed, 7 insertions, 24 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()
803 return EINA_TRUE; 803 return EINA_TRUE;
804} 804}
805 805
806static Eina_Bool
807_mkdir(const char *path, Eina_Bool skip_last)
808{
809 if (!ecore_file_exists(path))
810 {
811 const char *cur = path + 1;
812 do
813 {
814 char *slash = strchr(cur, '/');
815 if (slash) *slash = '\0';
816 else if (skip_last) return EINA_TRUE;
817 if (!ecore_file_exists(path) && !ecore_file_mkdir(path)) return EINA_FALSE;
818 if (slash) *slash = '/';
819 if (slash) cur = slash + 1;
820 else cur = NULL;
821 }
822 while (cur);
823 }
824 return EINA_TRUE;
825}
826
827static void 806static void
828_old_shots_rm_cb(const char *name, const char *path, void *data) 807_old_shots_rm_cb(const char *name, const char *path, void *data)
829{ 808{
@@ -988,16 +967,20 @@ int main(int argc, char **argv)
988 if (!strcmp(_dest + strlen(_dest) - 4,".exu")) 967 if (!strcmp(_dest + strlen(_dest) - 4,".exu"))
989 { 968 {
990 _dest_type = FTYPE_EXU; 969 _dest_type = FTYPE_EXU;
991 if (!_mkdir(_dest, EINA_TRUE)) 970 /* Cut path at the beginning of the file name */
971 char *file_start = strrchr(dest, '/');
972 *file_start = '\0';
973
974 if (!ecore_file_mkpath(dest))
992 { 975 {
993 fprintf(stderr, "Path for %s cannot be created\n", _dest); 976 fprintf(stderr, "Path for %s cannot be created\n", dest);
994 goto end; 977 goto end;
995 } 978 }
996 } 979 }
997 else 980 else
998 { 981 {
999 _dest_type = FTYPE_DIR; 982 _dest_type = FTYPE_DIR;
1000 if (!_mkdir(_dest, EINA_FALSE)) 983 if (!ecore_file_mkpath(_dest))
1001 { 984 {
1002 fprintf(stderr, "Directory %s cannot be created\n", _dest); 985 fprintf(stderr, "Directory %s cannot be created\n", _dest);
1003 goto end; 986 goto end;