summaryrefslogtreecommitdiff
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
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
-rw-r--r--src/bin/exactness/player.c31
-rw-r--r--src/bin/exactness/recorder.c22
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()
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;
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)
235 return e; 235 return e;
236} 236}
237 237
238static Eina_Bool
239_mkdir(const char *dir)
240{
241 if (!ecore_file_exists(dir))
242 {
243 const char *cur = dir + 1;
244 do
245 {
246 char *slash = strchr(cur, '/');
247 if (slash) *slash = '\0';
248 if (!ecore_file_exists(dir) && !ecore_file_mkdir(dir)) return EINA_FALSE;
249 if (slash) *slash = '/';
250 if (slash) cur = slash + 1;
251 else cur = NULL;
252 }
253 while (cur);
254 }
255 return EINA_TRUE;
256}
257
258static const Ecore_Getopt optdesc = { 238static const Ecore_Getopt optdesc = {
259 "exactness_record", 239 "exactness_record",
260 "%prog [options] <-v|-t|-h> command", 240 "%prog [options] <-v|-t|-h> command",
@@ -343,7 +323,7 @@ int main(int argc, char **argv)
343 if (slash) 323 if (slash)
344 { 324 {
345 *slash = '\0'; 325 *slash = '\0';
346 if (!_mkdir(_out_filename)) 326 if (!ecore_file_mkpath(_out_filename))
347 { 327 {
348 fprintf(stderr, "Can't create %s\n", _out_filename); 328 fprintf(stderr, "Can't create %s\n", _out_filename);
349 goto end; 329 goto end;