Update when func is called.

SVN revision: 13453
This commit is contained in:
sebastid 2005-02-21 16:03:08 +00:00 committed by sebastid
parent e450a16122
commit 98fe13e6aa
3 changed files with 32 additions and 43 deletions

View File

@ -29,21 +29,21 @@
#include <Evas.h>
#include <time.h>
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 {

View File

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

View File

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