forked from enlightenment/efl
parent
e450a16122
commit
98fe13e6aa
|
@ -29,21 +29,21 @@
|
||||||
#include <Evas.h>
|
#include <Evas.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
EAPI int ecore_file_init(void);
|
EAPI int ecore_file_init (void);
|
||||||
EAPI int ecore_file_shutdown(void);
|
EAPI int ecore_file_shutdown (void);
|
||||||
EAPI time_t ecore_file_mod_time(char *file);
|
EAPI time_t ecore_file_mod_time (const char *file);
|
||||||
EAPI int ecore_file_exists(char *file);
|
EAPI int ecore_file_exists (const char *file);
|
||||||
EAPI int ecore_file_is_dir(char *file);
|
EAPI int ecore_file_is_dir (const char *file);
|
||||||
EAPI int ecore_file_mkdir(char *dir);
|
EAPI int ecore_file_mkdir (const char *dir);
|
||||||
EAPI int ecore_file_mkpath(char *path);
|
EAPI int ecore_file_mkpath (const char *path);
|
||||||
EAPI int ecore_file_cp(char *src, char *dst);
|
EAPI int ecore_file_cp (const char *src, const char *dst);
|
||||||
EAPI char *ecore_file_realpath(char *file);
|
EAPI char *ecore_file_realpath (const char *file);
|
||||||
EAPI char *ecore_file_get_file(char *path);
|
EAPI char *ecore_file_get_file (const char *path);
|
||||||
EAPI char *ecore_file_get_dir(char *path);
|
EAPI char *ecore_file_get_dir (const char *path);
|
||||||
|
|
||||||
EAPI int ecore_file_can_exec(char *file);
|
EAPI int ecore_file_can_exec (const char *file);
|
||||||
EAPI char *ecore_file_readlink(char *link);
|
EAPI char *ecore_file_readlink (const char *link);
|
||||||
EAPI Evas_List *ecore_file_ls(char *dir);
|
EAPI Evas_List *ecore_file_ls (const char *dir);
|
||||||
|
|
||||||
typedef struct _Ecore_File_Monitor Ecore_File_Monitor;
|
typedef struct _Ecore_File_Monitor Ecore_File_Monitor;
|
||||||
typedef struct _Ecore_File_Monitor_Event Ecore_File_Monitor_Event;
|
typedef struct _Ecore_File_Monitor_Event Ecore_File_Monitor_Event;
|
||||||
|
@ -56,10 +56,10 @@ typedef enum {
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ECORE_FILE_EVENT_NONE,
|
ECORE_FILE_EVENT_NONE,
|
||||||
|
ECORE_FILE_EVENT_EXISTS,
|
||||||
ECORE_FILE_EVENT_CREATED,
|
ECORE_FILE_EVENT_CREATED,
|
||||||
ECORE_FILE_EVENT_DELETED,
|
ECORE_FILE_EVENT_DELETED,
|
||||||
ECORE_FILE_EVENT_CHANGED,
|
ECORE_FILE_EVENT_CHANGED
|
||||||
ECORE_FILE_EVENT_EXISTS
|
|
||||||
} Ecore_File_Event;
|
} Ecore_File_Event;
|
||||||
|
|
||||||
struct _Ecore_File_Monitor {
|
struct _Ecore_File_Monitor {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
* 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_private.h"
|
||||||
|
#include "Ecore_File.h"
|
||||||
|
|
||||||
/* externally accessible functions */
|
/* externally accessible functions */
|
||||||
int
|
int
|
||||||
|
@ -22,7 +22,7 @@ ecore_file_shutdown()
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
ecore_file_mod_time(char *file)
|
ecore_file_mod_time(const char *file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ ecore_file_mod_time(char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_exists(char *file)
|
ecore_file_exists(const char *file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ ecore_file_exists(char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_is_dir(char *file)
|
ecore_file_is_dir(const char *file)
|
||||||
{
|
{
|
||||||
struct stat st;
|
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;
|
static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_mkdir(char *dir)
|
ecore_file_mkdir(const char *dir)
|
||||||
{
|
{
|
||||||
if (mkdir(dir, default_mode) < 0) return 0;
|
if (mkdir(dir, default_mode) < 0) return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_mkpath(char *path)
|
ecore_file_mkpath(const char *path)
|
||||||
{
|
{
|
||||||
char ss[PATH_MAX];
|
char ss[PATH_MAX];
|
||||||
int i, ii;
|
int i, ii;
|
||||||
|
@ -85,7 +85,7 @@ ecore_file_mkpath(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_cp(char *src, char *dst)
|
ecore_file_cp(const char *src, const char *dst)
|
||||||
{
|
{
|
||||||
FILE *f1, *f2;
|
FILE *f1, *f2;
|
||||||
char buf[16384];
|
char buf[16384];
|
||||||
|
@ -106,7 +106,7 @@ ecore_file_cp(char *src, char *dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ecore_file_realpath(char *file)
|
ecore_file_realpath(const char *file)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
struct stat st;
|
struct stat st;
|
||||||
|
@ -116,7 +116,7 @@ ecore_file_realpath(char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ecore_file_get_file(char *path)
|
ecore_file_get_file(const char *path)
|
||||||
{
|
{
|
||||||
char *result = NULL;
|
char *result = NULL;
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ ecore_file_get_file(char *path)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ecore_file_get_dir(char *file)
|
ecore_file_get_dir(const char *file)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
|
@ -143,7 +143,7 @@ ecore_file_get_dir(char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ecore_file_can_exec(char *file)
|
ecore_file_can_exec(const char *file)
|
||||||
{
|
{
|
||||||
static int have_uid = 0;
|
static int have_uid = 0;
|
||||||
static uid_t uid = -1;
|
static uid_t uid = -1;
|
||||||
|
@ -174,7 +174,7 @@ ecore_file_can_exec(char *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
ecore_file_readlink(char *link)
|
ecore_file_readlink(const char *link)
|
||||||
{
|
{
|
||||||
char buf[PATH_MAX];
|
char buf[PATH_MAX];
|
||||||
int count;
|
int count;
|
||||||
|
@ -185,7 +185,7 @@ ecore_file_readlink(char *link)
|
||||||
}
|
}
|
||||||
|
|
||||||
Evas_List *
|
Evas_List *
|
||||||
ecore_file_ls(char *dir)
|
ecore_file_ls(const char *dir)
|
||||||
{
|
{
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
* - Implement recursive as an option!
|
* - Implement recursive as an option!
|
||||||
* - Keep whole path or just name of file? (Memory or CPU...)
|
* - Keep whole path or just name of file? (Memory or CPU...)
|
||||||
* - Remove requests without files?
|
* - Remove requests without files?
|
||||||
|
* - Change poll time
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _Ecore_File_Monitor_Poll Ecore_File_Monitor_Poll;
|
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);
|
em->path = strdup(path);
|
||||||
len = strlen(em->path);
|
len = strlen(em->path);
|
||||||
if (em->path[len - 1] == '/')
|
if (em->path[len - 1] == '/')
|
||||||
em->path[len - 1] = '\0';
|
em->path[len - 1] = 0;
|
||||||
|
|
||||||
em->func = func;
|
em->func = func;
|
||||||
em->data = data;
|
em->data = data;
|
||||||
|
@ -105,9 +106,7 @@ ecore_file_monitor_add(const char *path,
|
||||||
ECORE_FILE_TYPE_DIRECTORY :
|
ECORE_FILE_TYPE_DIRECTORY :
|
||||||
ECORE_FILE_TYPE_FILE;
|
ECORE_FILE_TYPE_FILE;
|
||||||
|
|
||||||
#if 0
|
|
||||||
em->func(em->data, em, em->type, ECORE_FILE_EVENT_EXISTS, em->path);
|
em->func(em->data, em, em->type, ECORE_FILE_EVENT_EXISTS, em->path);
|
||||||
#endif
|
|
||||||
if (em->type == ECORE_FILE_TYPE_DIRECTORY)
|
if (em->type == ECORE_FILE_TYPE_DIRECTORY)
|
||||||
{
|
{
|
||||||
/* Check for subdirs */
|
/* Check for subdirs */
|
||||||
|
@ -139,17 +138,11 @@ ecore_file_monitor_add(const char *path,
|
||||||
}
|
}
|
||||||
evas_list_free(files);
|
evas_list_free(files);
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else
|
|
||||||
em->func(em->data, em, em->type, ECORE_FILE_EVENT_EXISTS, em->path);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
em->type = ECORE_FILE_TYPE_NONE;
|
em->type = ECORE_FILE_TYPE_NONE;
|
||||||
#if 0
|
|
||||||
em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path);
|
em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_monitors = evas_list_append(_monitors, em);
|
_monitors = evas_list_append(_monitors, em);
|
||||||
|
@ -259,9 +252,7 @@ _ecore_file_monitor_check(Ecore_File_Monitor *em)
|
||||||
free(f);
|
free(f);
|
||||||
}
|
}
|
||||||
emf->files = evas_list_free(emf->files);
|
emf->files = evas_list_free(emf->files);
|
||||||
#if 0
|
|
||||||
em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path);
|
em->func(em->data, em, em->type, ECORE_FILE_EVENT_DELETED, em->path);
|
||||||
#endif
|
|
||||||
em->type = ECORE_FILE_TYPE_NONE;
|
em->type = ECORE_FILE_TYPE_NONE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -297,9 +288,6 @@ _ecore_file_monitor_check(Ecore_File_Monitor *em)
|
||||||
Evas_List *files;
|
Evas_List *files;
|
||||||
|
|
||||||
/* Files have been added or removed */
|
/* 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);
|
files = ecore_file_ls(em->path);
|
||||||
for (l = files; l; l = l->next)
|
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);
|
em->func(em->data, em, f->type, ECORE_FILE_EVENT_CREATED, buf);
|
||||||
emf->files = evas_list_append(emf->files, f);
|
emf->files = evas_list_append(emf->files, f);
|
||||||
}
|
}
|
||||||
|
em->func(em->data, em, em->type, ECORE_FILE_EVENT_CHANGED, em->path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue