From 4467ac1c39eddda223ac491ac2c08b46af0501a7 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Sat, 11 Apr 2009 06:13:02 +0000 Subject: [PATCH] batch directory creation, part 1. SVN revision: 39961 --- legacy/ecore/src/lib/ecore_file/Ecore_File.h | 2 + legacy/ecore/src/lib/ecore_file/ecore_file.c | 40 ++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/legacy/ecore/src/lib/ecore_file/Ecore_File.h b/legacy/ecore/src/lib/ecore_file/Ecore_File.h index 5bb8f0b1da..cf656cc66d 100644 --- a/legacy/ecore/src/lib/ecore_file/Ecore_File.h +++ b/legacy/ecore/src/lib/ecore_file/Ecore_File.h @@ -69,9 +69,11 @@ extern "C" { EAPI int ecore_file_exists (const char *file); EAPI int ecore_file_is_dir (const char *file); EAPI int ecore_file_mkdir (const char *dir); + EAPI int ecore_file_mkdirs (const char **dirs); EAPI int ecore_file_rmdir (const char *dir); EAPI int ecore_file_recursive_rm (const char *dir); EAPI int ecore_file_mkpath (const char *path); + EAPI int ecore_file_mkpaths (const char **paths); EAPI int ecore_file_cp (const char *src, const char *dst); EAPI int ecore_file_mv (const char *src, const char *dst); EAPI int ecore_file_symlink (const char *src, const char *dest); diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index 6efe5e0502..7593e2c3e6 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -154,6 +154,25 @@ ecore_file_mkdir(const char *dir) return 1; } +/** + * Create complete directory in a batch. + * + * @param dirs list of directories, null terminated. + * @return number of successfull directories created, -1 if dirs is NULL. + * + * @see ecore_file_mkdir() and ecore_file_mkpaths() + */ +EAPI int +ecore_file_mkdirs(const char **dirs) +{ + if (!dirs) return -1; + int i = 0; + for (; *dirs != NULL; dirs++) + if (ecore_file_mkdir(*dirs)) + i++; + return i; +} + /** * Delete the given dir * @param dir The name of the directory to delete @@ -235,6 +254,8 @@ ecore_file_recursive_rm(const char *dir) * Create a complete path * @param path The path to create * @return 1 on success, 0 on failure + * + * @see ecore_file_mkpaths() and ecore_file_mkdir() */ EAPI int ecore_file_mkpath(const char *path) @@ -263,6 +284,25 @@ ecore_file_mkpath(const char *path) return 1; } +/** + * Create complete paths in a batch. + * + * @param paths list of paths, null terminated. + * @return number of successfull paths created, -1 if paths is NULL. + * + * @see ecore_file_mkpath() and ecore_file_mkdirs() + */ +EAPI int +ecore_file_mkpaths(const char **paths) +{ + if (!paths) return -1; + int i = 0; + for (; *paths != NULL; paths++) + if (ecore_file_mkpath(*paths)) + i++; + return i; +} + /** * Copy a file * @param src The name of the source file