From 98fe13e6aa74dbff60170b84be383e9eabb72090 Mon Sep 17 00:00:00 2001 From: sebastid Date: Mon, 21 Feb 2005 16:03:08 +0000 Subject: [PATCH] Update when func is called. SVN revision: 13453 --- legacy/ecore/src/lib/ecore_file/Ecore_File.h | 32 +++++++++---------- legacy/ecore/src/lib/ecore_file/ecore_file.c | 26 +++++++-------- .../lib/ecore_file/ecore_file_monitor_poll.c | 17 ++-------- 3 files changed, 32 insertions(+), 43 deletions(-) diff --git a/legacy/ecore/src/lib/ecore_file/Ecore_File.h b/legacy/ecore/src/lib/ecore_file/Ecore_File.h index 86d7306421..a5c647b9f6 100644 --- a/legacy/ecore/src/lib/ecore_file/Ecore_File.h +++ b/legacy/ecore/src/lib/ecore_file/Ecore_File.h @@ -29,21 +29,21 @@ #include #include -EAPI int ecore_file_init(void); -EAPI int ecore_file_shutdown(void); -EAPI time_t ecore_file_mod_time(char *file); -EAPI int ecore_file_exists(char *file); -EAPI int ecore_file_is_dir(char *file); -EAPI int ecore_file_mkdir(char *dir); -EAPI int ecore_file_mkpath(char *path); -EAPI int ecore_file_cp(char *src, char *dst); -EAPI char *ecore_file_realpath(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_mkpath (const char *path); +EAPI int ecore_file_cp (const char *src, const char *dst); +EAPI char *ecore_file_realpath (const char *file); +EAPI char *ecore_file_get_file (const char *path); +EAPI char *ecore_file_get_dir (const char *path); -EAPI int ecore_file_can_exec(char *file); -EAPI char *ecore_file_readlink(char *link); -EAPI Evas_List *ecore_file_ls(char *dir); +EAPI int ecore_file_can_exec (const char *file); +EAPI char *ecore_file_readlink (const char *link); +EAPI Evas_List *ecore_file_ls (const char *dir); typedef struct _Ecore_File_Monitor Ecore_File_Monitor; typedef struct _Ecore_File_Monitor_Event Ecore_File_Monitor_Event; @@ -56,10 +56,10 @@ typedef enum { typedef enum { ECORE_FILE_EVENT_NONE, + ECORE_FILE_EVENT_EXISTS, ECORE_FILE_EVENT_CREATED, ECORE_FILE_EVENT_DELETED, - ECORE_FILE_EVENT_CHANGED, - ECORE_FILE_EVENT_EXISTS + ECORE_FILE_EVENT_CHANGED } Ecore_File_Event; struct _Ecore_File_Monitor { diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file.c b/legacy/ecore/src/lib/ecore_file/ecore_file.c index 1ddac152aa..93db05f93c 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file.c @@ -1,8 +1,8 @@ /* * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 */ -#include "Ecore_File.h" #include "ecore_file_private.h" +#include "Ecore_File.h" /* externally accessible functions */ int @@ -22,7 +22,7 @@ ecore_file_shutdown() } time_t -ecore_file_mod_time(char *file) +ecore_file_mod_time(const char *file) { struct stat st; @@ -31,7 +31,7 @@ ecore_file_mod_time(char *file) } int -ecore_file_exists(char *file) +ecore_file_exists(const char *file) { struct stat st; @@ -40,7 +40,7 @@ ecore_file_exists(char *file) } int -ecore_file_is_dir(char *file) +ecore_file_is_dir(const char *file) { struct stat st; @@ -52,14 +52,14 @@ ecore_file_is_dir(char *file) static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; int -ecore_file_mkdir(char *dir) +ecore_file_mkdir(const char *dir) { if (mkdir(dir, default_mode) < 0) return 0; return 1; } int -ecore_file_mkpath(char *path) +ecore_file_mkpath(const char *path) { char ss[PATH_MAX]; int i, ii; @@ -85,7 +85,7 @@ ecore_file_mkpath(char *path) } int -ecore_file_cp(char *src, char *dst) +ecore_file_cp(const char *src, const char *dst) { FILE *f1, *f2; char buf[16384]; @@ -106,7 +106,7 @@ ecore_file_cp(char *src, char *dst) } char * -ecore_file_realpath(char *file) +ecore_file_realpath(const char *file) { char buf[PATH_MAX]; struct stat st; @@ -116,7 +116,7 @@ ecore_file_realpath(char *file) } char * -ecore_file_get_file(char *path) +ecore_file_get_file(const char *path) { char *result = NULL; @@ -127,7 +127,7 @@ ecore_file_get_file(char *path) } char * -ecore_file_get_dir(char *file) +ecore_file_get_dir(const char *file) { char *p; char buf[PATH_MAX]; @@ -143,7 +143,7 @@ ecore_file_get_dir(char *file) } int -ecore_file_can_exec(char *file) +ecore_file_can_exec(const char *file) { static int have_uid = 0; static uid_t uid = -1; @@ -174,7 +174,7 @@ ecore_file_can_exec(char *file) } char * -ecore_file_readlink(char *link) +ecore_file_readlink(const char *link) { char buf[PATH_MAX]; int count; @@ -185,7 +185,7 @@ ecore_file_readlink(char *link) } Evas_List * -ecore_file_ls(char *dir) +ecore_file_ls(const char *dir) { DIR *dirp; struct dirent *dp; diff --git a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c index c7e54f1cc3..ebbd9acc5e 100644 --- a/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c +++ b/legacy/ecore/src/lib/ecore_file/ecore_file_monitor_poll.c @@ -11,6 +11,7 @@ * - Implement recursive as an option! * - Keep whole path or just name of file? (Memory or CPU...) * - Remove requests without files? + * - Change poll time */ typedef struct _Ecore_File_Monitor_Poll Ecore_File_Monitor_Poll; @@ -93,7 +94,7 @@ ecore_file_monitor_add(const char *path, em->path = strdup(path); len = strlen(em->path); if (em->path[len - 1] == '/') - em->path[len - 1] = '\0'; + em->path[len - 1] = 0; em->func = func; em->data = data; @@ -105,9 +106,7 @@ ecore_file_monitor_add(const char *path, ECORE_FILE_TYPE_DIRECTORY : ECORE_FILE_TYPE_FILE; -#if 0 em->func(em->data, em, em->type, ECORE_FILE_EVENT_EXISTS, em->path); -#endif if (em->type == ECORE_FILE_TYPE_DIRECTORY) { /* Check for subdirs */ @@ -139,17 +138,11 @@ ecore_file_monitor_add(const char *path, } evas_list_free(files); } -#if 0 - else - em->func(em->data, em, em->type, ECORE_FILE_EVENT_EXISTS, em->path); -#endif } else { em->type = ECORE_FILE_TYPE_NONE; -#if 0 em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path); -#endif } _monitors = evas_list_append(_monitors, em); @@ -259,9 +252,7 @@ _ecore_file_monitor_check(Ecore_File_Monitor *em) free(f); } emf->files = evas_list_free(emf->files); -#if 0 em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path); -#endif em->type = ECORE_FILE_TYPE_NONE; } else @@ -297,9 +288,6 @@ _ecore_file_monitor_check(Ecore_File_Monitor *em) Evas_List *files; /* Files have been added or removed */ -#if 0 - em->func(em->data, em, em->type, ECORE_FILE_EVENT_CHANGED, em->path); -#endif files = ecore_file_ls(em->path); for (l = files; l; l = l->next) { @@ -330,6 +318,7 @@ _ecore_file_monitor_check(Ecore_File_Monitor *em) em->func(em->data, em, f->type, ECORE_FILE_EVENT_CREATED, buf); emf->files = evas_list_append(emf->files, f); } + em->func(em->data, em, em->type, ECORE_FILE_EVENT_CHANGED, em->path); } } break;