batch directory creation, part 1.

SVN revision: 39961
This commit is contained in:
Gustavo Sverzut Barbieri 2009-04-11 06:13:02 +00:00
parent c08930433c
commit 4467ac1c39
2 changed files with 42 additions and 0 deletions

View File

@ -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);

View File

@ -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