forked from enlightenment/efl
- add method to delete dirs recursively
SVN revision: 17848
This commit is contained in:
parent
1d3bec0505
commit
0be8326d89
|
@ -48,26 +48,27 @@ extern "C" {
|
|||
} Ecore_File_Event;
|
||||
|
||||
|
||||
EAPI int ecore_file_init (void);
|
||||
EAPI int ecore_file_shutdown (void);
|
||||
EAPI time_t ecore_file_mod_time (const char *file);
|
||||
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_rmdir (const char *dir);
|
||||
EAPI int ecore_file_mkpath (const char *path);
|
||||
EAPI int ecore_file_cp (const char *src, const char *dst);
|
||||
EAPI int ecore_file_mv (const char *src, const char *dst);
|
||||
EAPI char *ecore_file_realpath (const char *file);
|
||||
EAPI int ecore_file_unlink (const char *file);
|
||||
EAPI char *ecore_file_get_file (char *path);
|
||||
EAPI char *ecore_file_get_dir (char *path);
|
||||
EAPI int ecore_file_init (void);
|
||||
EAPI int ecore_file_shutdown (void);
|
||||
EAPI time_t ecore_file_mod_time (const char *file);
|
||||
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_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_cp (const char *src, const char *dst);
|
||||
EAPI int ecore_file_mv (const char *src, const char *dst);
|
||||
EAPI char *ecore_file_realpath (const char *file);
|
||||
EAPI int ecore_file_unlink (const char *file);
|
||||
EAPI char *ecore_file_get_file (char *path);
|
||||
EAPI char *ecore_file_get_dir (char *path);
|
||||
|
||||
EAPI int ecore_file_can_exec (const char *file);
|
||||
EAPI char *ecore_file_readlink (const char *link);
|
||||
EAPI Ecore_List *ecore_file_ls (const char *dir);
|
||||
EAPI char *ecore_file_app_exe_get (const char *app);
|
||||
EAPI char *ecore_file_strip_ext (const char *file);
|
||||
EAPI int ecore_file_can_exec (const char *file);
|
||||
EAPI char *ecore_file_readlink (const char *link);
|
||||
EAPI Ecore_List *ecore_file_ls (const char *dir);
|
||||
EAPI char *ecore_file_app_exe_get (const char *app);
|
||||
EAPI char *ecore_file_strip_ext (const char *file);
|
||||
|
||||
EAPI Ecore_File_Monitor *ecore_file_monitor_add(const char *path,
|
||||
void (*func) (void *data,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "ecore_file_private.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
||||
static int init = 0;
|
||||
|
||||
/* externally accessible functions */
|
||||
|
@ -93,6 +94,47 @@ ecore_file_unlink(const char *file)
|
|||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_recursive_rm(const char *dir)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
Ecore_List *list;
|
||||
int ret;
|
||||
|
||||
ret = 0;
|
||||
dirp = opendir(dir);
|
||||
if (!dirp) return ret;
|
||||
|
||||
while ((dp = readdir(dirp)))
|
||||
{
|
||||
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
|
||||
{
|
||||
char path[PATH_MAX];
|
||||
struct stat st;
|
||||
|
||||
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
|
||||
if (stat(path, &st) == -1) { ret = 0; continue; }
|
||||
|
||||
if(S_ISDIR(st.st_mode))
|
||||
{
|
||||
ecore_file_recursive_rm(path);
|
||||
ecore_file_rmdir(path);
|
||||
}
|
||||
else if(S_ISREG(st.st_mode)||S_ISLNK(st.st_mode))
|
||||
{
|
||||
ecore_file_unlink(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dirp);
|
||||
|
||||
if(ecore_file_rmdir(dir))
|
||||
ret = 1;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int
|
||||
ecore_file_mkpath(const char *path)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue