summaryrefslogtreecommitdiff
path: root/legacy/ecore/src/lib/ecore_file/ecore_file.c
diff options
context:
space:
mode:
authorChristopher Michael <cpmichael1@comcast.net>2010-01-03 21:50:23 +0000
committerChristopher Michael <cpmichael1@comcast.net>2010-01-03 21:50:23 +0000
commit741a72588973c943868c1a05cbc49c76d7b9a7a6 (patch)
tree4bc4eddf540201232299e75635b229c13c1e0b4e /legacy/ecore/src/lib/ecore_file/ecore_file.c
parent36e6b34070fa280168da7ca16c95cee8d9896428 (diff)
Remove wasted whitespace & fix some formatting.
SVN revision: 44861
Diffstat (limited to '')
-rw-r--r--legacy/ecore/src/lib/ecore_file/ecore_file.c60
1 files changed, 29 insertions, 31 deletions
diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c
index b04b35ee6f..fc61fa4f39 100644
--- a/legacy/ecore/src/lib/ecore_file/ecore_file.c
+++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c
@@ -178,7 +178,9 @@ EAPI int
178ecore_file_mkdirs(const char **dirs) 178ecore_file_mkdirs(const char **dirs)
179{ 179{
180 if (!dirs) return -1; 180 if (!dirs) return -1;
181
181 int i = 0; 182 int i = 0;
183
182 for (; *dirs != NULL; dirs++) 184 for (; *dirs != NULL; dirs++)
183 if (ecore_file_mkdir(*dirs)) 185 if (ecore_file_mkdir(*dirs))
184 i++; 186 i++;
@@ -323,17 +325,14 @@ ecore_file_remove(const char *file)
323EAPI int 325EAPI int
324ecore_file_recursive_rm(const char *dir) 326ecore_file_recursive_rm(const char *dir)
325{ 327{
326 DIR *dirp; 328 DIR *dirp;
327 struct dirent *dp; 329 struct dirent *dp;
328 char path[PATH_MAX]; 330 char path[PATH_MAX], buf[PATH_MAX];
329 char buf[PATH_MAX]; 331 struct stat st;
330 struct stat st; 332 int ret;
331 int ret;
332 333
333 if (readlink(dir, buf, sizeof(buf)) > 0) 334 if (readlink(dir, buf, sizeof(buf)) > 0)
334 { 335 return ecore_file_unlink(dir);
335 return ecore_file_unlink(dir);
336 }
337 336
338 ret = stat(dir, &st); 337 ret = stat(dir, &st);
339 if ((ret == 0) && (S_ISDIR(st.st_mode))) 338 if ((ret == 0) && (S_ISDIR(st.st_mode)))
@@ -370,6 +369,7 @@ static inline int
370_ecore_file_mkpath_if_not_exists(const char *path) 369_ecore_file_mkpath_if_not_exists(const char *path)
371{ 370{
372 struct stat st; 371 struct stat st;
372
373 if (stat(path, &st) < 0) 373 if (stat(path, &st) < 0)
374 return ecore_file_mkdir(path); 374 return ecore_file_mkdir(path);
375 else if (!S_ISDIR(st.st_mode)) 375 else if (!S_ISDIR(st.st_mode))
@@ -419,8 +419,11 @@ ecore_file_mkpath(const char *path)
419EAPI int 419EAPI int
420ecore_file_mkpaths(const char **paths) 420ecore_file_mkpaths(const char **paths)
421{ 421{
422
422 if (!paths) return -1; 423 if (!paths) return -1;
424
423 int i = 0; 425 int i = 0;
426
424 for (; *paths != NULL; paths++) 427 for (; *paths != NULL; paths++)
425 if (ecore_file_mkpath(*paths)) 428 if (ecore_file_mkpath(*paths))
426 i++; 429 i++;
@@ -436,12 +439,11 @@ ecore_file_mkpaths(const char **paths)
436EAPI int 439EAPI int
437ecore_file_cp(const char *src, const char *dst) 440ecore_file_cp(const char *src, const char *dst)
438{ 441{
439 FILE *f1, *f2; 442 FILE *f1, *f2;
440 char buf[16384]; 443 char buf[16384];
441 char realpath1[PATH_MAX]; 444 char realpath1[PATH_MAX], realpath2[PATH_MAX];
442 char realpath2[PATH_MAX]; 445 size_t num;
443 size_t num; 446 int ret = 1;
444 int ret = 1;
445 447
446 if (!realpath(src, realpath1)) return 0; 448 if (!realpath(src, realpath1)) return 0;
447 if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) return 0; 449 if (realpath(dst, realpath2) && !strcmp(realpath1, realpath2)) return 0;
@@ -489,6 +491,7 @@ ecore_file_mv(const char *src, const char *dst)
489 if (S_ISREG(st.st_mode)) 491 if (S_ISREG(st.st_mode))
490 { 492 {
491 char *dir; 493 char *dir;
494
492 dir = ecore_file_dir_get(dst); 495 dir = ecore_file_dir_get(dst);
493 // Since we can't directly rename, try to 496 // Since we can't directly rename, try to
494 // copy to temp file in the dst directory 497 // copy to temp file in the dst directory
@@ -559,7 +562,7 @@ ecore_file_symlink(const char *src, const char *dest)
559EAPI char * 562EAPI char *
560ecore_file_realpath(const char *file) 563ecore_file_realpath(const char *file)
561{ 564{
562 char buf[PATH_MAX]; 565 char buf[PATH_MAX];
563 566
564 /* 567 /*
565 * Some implementations of realpath do not conform to the SUS. 568 * Some implementations of realpath do not conform to the SUS.
@@ -595,15 +598,12 @@ ecore_file_file_get(const char *path)
595EAPI char * 598EAPI char *
596ecore_file_dir_get(const char *file) 599ecore_file_dir_get(const char *file)
597{ 600{
598 char *p; 601 char *p;
599 char buf[PATH_MAX]; 602 char buf[PATH_MAX];
600 603
601 strncpy(buf, file, PATH_MAX); 604 strncpy(buf, file, PATH_MAX);
602 p = strrchr(buf, '/'); 605 p = strrchr(buf, '/');
603 if (!p) 606 if (!p) return strdup(file);
604 {
605 return strdup(file);
606 }
607 607
608 if (p == buf) return strdup("/"); 608 if (p == buf) return strdup("/");
609 609
@@ -658,8 +658,8 @@ ecore_file_can_exec(const char *file)
658EAPI char * 658EAPI char *
659ecore_file_readlink(const char *link) 659ecore_file_readlink(const char *link)
660{ 660{
661 char buf[PATH_MAX]; 661 char buf[PATH_MAX];
662 int count; 662 int count;
663 663
664 if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL; 664 if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL;
665 buf[count] = 0; 665 buf[count] = 0;
@@ -679,10 +679,10 @@ ecore_file_readlink(const char *link)
679EAPI Eina_List * 679EAPI Eina_List *
680ecore_file_ls(const char *dir) 680ecore_file_ls(const char *dir)
681{ 681{
682 char *f; 682 char *f;
683 DIR *dirp; 683 DIR *dirp;
684 struct dirent *dp; 684 struct dirent *dp;
685 Eina_List *list = NULL; 685 Eina_List *list = NULL;
686 686
687 dirp = opendir(dir); 687 dirp = opendir(dir);
688 if (!dirp) return NULL; 688 if (!dirp) return NULL;
@@ -902,9 +902,7 @@ ecore_file_strip_ext(const char *path)
902 902
903 p = strrchr(path, '.'); 903 p = strrchr(path, '.');
904 if (!p) 904 if (!p)
905 { 905 file = strdup(path);
906 file = strdup(path);
907 }
908 else if (p != path) 906 else if (p != path)
909 { 907 {
910 file = malloc(((p - path) + 1) * sizeof(char)); 908 file = malloc(((p - path) + 1) * sizeof(char));