SVN revision: 52920
This commit is contained in:
Vincent Torri 2010-09-30 07:25:06 +00:00
parent 586334710d
commit 519007d376
7 changed files with 563 additions and 563 deletions

View File

@ -223,8 +223,8 @@ ecore_file_mksubdirs(const char *base, const char **subdirs)
if (buf[baselen - 1] != '/')
{
buf[baselen] = '/';
baselen++;
buf[baselen] = '/';
baselen++;
}
#else
dir = opendir(base);
@ -236,36 +236,36 @@ ecore_file_mksubdirs(const char *base, const char **subdirs)
i = 0;
for (; *subdirs; subdirs++)
{
struct stat st;
struct stat st;
#ifndef HAVE_ATFILE_SOURCE
eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen);
if (stat(buf, &st) == 0)
eina_strlcpy(buf + baselen, *subdirs, sizeof(buf) - baselen);
if (stat(buf, &st) == 0)
#else
if (fstatat(fd, *subdirs, &st, 0) == 0)
if (fstatat(fd, *subdirs, &st, 0) == 0)
#endif
{
if (S_ISDIR(st.st_mode))
{
i++;
continue;
}
}
else
{
if (errno == ENOENT)
{
{
if (S_ISDIR(st.st_mode))
{
i++;
continue;
}
}
else
{
if (errno == ENOENT)
{
#ifndef HAVE_ATFILE_SOURCE
if (mkdir(buf, default_mode) == 0)
if (mkdir(buf, default_mode) == 0)
#else
if (mkdirat(fd, *subdirs, default_mode) == 0)
if (mkdirat(fd, *subdirs, default_mode) == 0)
#endif
{
i++;
continue;
}
}
}
{
i++;
continue;
}
}
}
}
#ifdef HAVE_ATFILE_SOURCE
@ -333,23 +333,23 @@ ecore_file_recursive_rm(const char *dir)
ret = stat(dir, &st);
if ((ret == 0) && (S_ISDIR(st.st_mode)))
{
ret = 1;
if (stat(dir, &st) == -1) return EINA_FALSE;
dirp = opendir(dir);
if (dirp)
{
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
if (!ecore_file_recursive_rm(path))
ret = 0;
}
}
closedir(dirp);
}
if (!ecore_file_rmdir(dir)) ret = 0;
ret = 1;
if (stat(dir, &st) == -1) return EINA_FALSE;
dirp = opendir(dir);
if (dirp)
{
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
snprintf(path, PATH_MAX, "%s/%s", dir, dp->d_name);
if (!ecore_file_recursive_rm(path))
ret = 0;
}
}
closedir(dirp);
}
if (!ecore_file_rmdir(dir)) ret = 0;
if (ret)
return EINA_TRUE;
else
@ -357,8 +357,8 @@ ecore_file_recursive_rm(const char *dir)
}
else
{
if (ret == -1) return EINA_FALSE;
return ecore_file_unlink(dir);
if (ret == -1) return EINA_FALSE;
return ecore_file_unlink(dir);
}
}
@ -393,13 +393,13 @@ ecore_file_mkpath(const char *path)
for (i = 0; path[i] != '\0'; ss[i] = path[i], i++)
{
if (i == sizeof(ss) - 1) return EINA_FALSE;
if ((path[i] == '/') && (i > 0))
{
ss[i] = '\0';
if (!_ecore_file_mkpath_if_not_exists(ss))
return EINA_FALSE;
}
if (i == sizeof(ss) - 1) return EINA_FALSE;
if ((path[i] == '/') && (i > 0))
{
ss[i] = '\0';
if (!_ecore_file_mkpath_if_not_exists(ss))
return EINA_FALSE;
}
}
ss[i] = '\0';
return _ecore_file_mkpath_if_not_exists(ss);
@ -449,12 +449,12 @@ ecore_file_cp(const char *src, const char *dst)
f2 = fopen(dst, "wb");
if (!f2)
{
fclose(f1);
return EINA_FALSE;
fclose(f1);
return EINA_FALSE;
}
while ((num = fread(buf, 1, sizeof(buf), f1)) > 0)
{
if (fwrite(buf, 1, num, f2) != num) ret = EINA_FALSE;
if (fwrite(buf, 1, num, f2) != num) ret = EINA_FALSE;
}
fclose(f1);
fclose(f2);
@ -477,55 +477,55 @@ ecore_file_mv(const char *src, const char *dst)
{
// File cannot be moved directly because
// it resides on a different mount point.
if (errno == EXDEV)
{
struct stat st;
if (errno == EXDEV)
{
struct stat st;
// Make sure this is a regular file before
// we do anything fancy.
stat(src, &st);
if (S_ISREG(st.st_mode))
{
char *dir;
stat(src, &st);
if (S_ISREG(st.st_mode))
{
char *dir;
dir = ecore_file_dir_get(dst);
// Since we can't directly rename, try to
// copy to temp file in the dst directory
// and then rename.
snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX",
dir, ecore_file_file_get(dst));
free(dir);
fd = mkstemp(buf);
if (fd < 0)
{
perror("mkstemp");
goto FAIL;
}
close(fd);
dir = ecore_file_dir_get(dst);
// Since we can't directly rename, try to
// copy to temp file in the dst directory
// and then rename.
snprintf(buf, sizeof(buf), "%s/.%s.tmp.XXXXXX",
dir, ecore_file_file_get(dst));
free(dir);
fd = mkstemp(buf);
if (fd < 0)
{
perror("mkstemp");
goto FAIL;
}
close(fd);
// Copy to temp file
if (!ecore_file_cp(src, buf))
goto FAIL;
// Copy to temp file
if (!ecore_file_cp(src, buf))
goto FAIL;
// Set file permissions of temp file to match src
chmod(buf, st.st_mode);
// Set file permissions of temp file to match src
chmod(buf, st.st_mode);
// Try to atomically move temp file to dst
if (rename(buf, dst))
{
// If we still cannot atomically move
// do a normal copy and hope for the best.
if (!ecore_file_cp(buf, dst))
goto FAIL;
}
// Try to atomically move temp file to dst
if (rename(buf, dst))
{
// If we still cannot atomically move
// do a normal copy and hope for the best.
if (!ecore_file_cp(buf, dst))
goto FAIL;
}
// Delete temporary file and src
ecore_file_unlink(buf);
ecore_file_unlink(src);
goto PASS;
}
}
goto FAIL;
// Delete temporary file and src
ecore_file_unlink(buf);
ecore_file_unlink(src);
goto PASS;
}
}
goto FAIL;
}
PASS:
@ -682,11 +682,11 @@ ecore_file_ls(const char *dir)
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
f = strdup(dp->d_name);
list = eina_list_append(list, f);
}
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
f = strdup(dp->d_name);
list = eina_list_append(list, f);
}
}
closedir(dirp);
@ -713,61 +713,61 @@ restart:
exe1 = p;
while (*p)
{
if (in_quot_sing)
{
if (*p == '\'')
in_quot_sing = 0;
}
else if (in_quot_dbl)
{
if (*p == '\"')
in_quot_dbl = 0;
}
else
{
if (*p == '\'')
in_quot_sing = 1;
else if (*p == '\"')
in_quot_dbl = 1;
if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\'))))
break;
}
p++;
if (in_quot_sing)
{
if (*p == '\'')
in_quot_sing = 0;
}
else if (in_quot_dbl)
{
if (*p == '\"')
in_quot_dbl = 0;
}
else
{
if (*p == '\'')
in_quot_sing = 1;
else if (*p == '\"')
in_quot_dbl = 1;
if ((isspace(*p)) && (!((p > app) && (p[-1] != '\\'))))
break;
}
p++;
}
exe2 = p;
if (exe2 == exe1) return NULL;
if (*exe1 == '~')
{
char *homedir;
int len;
char *homedir;
int len;
/* Skip ~ */
exe1++;
/* Skip ~ */
exe1++;
homedir = getenv("HOME");
if (!homedir) return NULL;
len = strlen(homedir);
if (exe) free(exe);
exe = malloc(len + exe2 - exe1 + 2);
if (!exe) return NULL;
pp = exe;
if (len)
{
strcpy(exe, homedir);
pp += len;
if (*(pp - 1) != '/')
{
*pp = '/';
pp++;
}
}
homedir = getenv("HOME");
if (!homedir) return NULL;
len = strlen(homedir);
if (exe) free(exe);
exe = malloc(len + exe2 - exe1 + 2);
if (!exe) return NULL;
pp = exe;
if (len)
{
strcpy(exe, homedir);
pp += len;
if (*(pp - 1) != '/')
{
*pp = '/';
pp++;
}
}
}
else
{
if (exe) free(exe);
exe = malloc(exe2 - exe1 + 1);
if (!exe) return NULL;
pp = exe;
if (exe) free(exe);
exe = malloc(exe2 - exe1 + 1);
if (!exe) return NULL;
pp = exe;
}
p = exe1;
restart = 0;
@ -775,69 +775,69 @@ restart:
in_quot_sing = 0;
while (*p)
{
if (in_quot_sing)
{
if (*p == '\'')
in_quot_sing = 0;
else
{
*pp = *p;
pp++;
}
}
else if (in_quot_dbl)
{
if (*p == '\"')
in_quot_dbl = 0;
else
{
/* techcincally this is wrong. double quotes also accept
* special chars:
*
* $, `, \
*/
*pp = *p;
pp++;
}
}
else
{
/* technically we should handle special chars:
*
* $, `, \, etc.
*/
if ((p > exe1) && (p[-1] == '\\'))
{
if (*p != '\n')
{
*pp = *p;
pp++;
}
}
else if ((p > exe1) && (*p == '='))
{
restart = 1;
*pp = *p;
pp++;
}
else if (*p == '\'')
in_quot_sing = 1;
else if (*p == '\"')
in_quot_dbl = 1;
else if (isspace(*p))
{
if (restart)
goto restart;
else
break;
}
else
{
*pp = *p;
pp++;
}
}
p++;
if (in_quot_sing)
{
if (*p == '\'')
in_quot_sing = 0;
else
{
*pp = *p;
pp++;
}
}
else if (in_quot_dbl)
{
if (*p == '\"')
in_quot_dbl = 0;
else
{
/* techcincally this is wrong. double quotes also accept
* special chars:
*
* $, `, \
*/
*pp = *p;
pp++;
}
}
else
{
/* technically we should handle special chars:
*
* $, `, \, etc.
*/
if ((p > exe1) && (p[-1] == '\\'))
{
if (*p != '\n')
{
*pp = *p;
pp++;
}
}
else if ((p > exe1) && (*p == '='))
{
restart = 1;
*pp = *p;
pp++;
}
else if (*p == '\'')
in_quot_sing = 1;
else if (*p == '\"')
in_quot_dbl = 1;
else if (isspace(*p))
{
if (restart)
goto restart;
else
break;
}
else
{
*pp = *p;
pp++;
}
}
p++;
}
*pp = 0;
return exe;
@ -860,24 +860,24 @@ ecore_file_escape_name(const char *filename)
q = buf;
while (*p)
{
if ((q - buf) > (PATH_MAX - 6)) return NULL;
if (
(*p == ' ') || (*p == '\t') || (*p == '\n') ||
(*p == '\\') || (*p == '\'') || (*p == '\"') ||
(*p == ';') || (*p == '!') || (*p == '#') ||
(*p == '$') || (*p == '%') || (*p == '&') ||
(*p == '*') || (*p == '(') || (*p == ')') ||
(*p == '[') || (*p == ']') || (*p == '{') ||
(*p == '}') || (*p == '|') || (*p == '<') ||
(*p == '>') || (*p == '?')
)
{
*q = '\\';
q++;
}
*q = *p;
q++;
p++;
if ((q - buf) > (PATH_MAX - 6)) return NULL;
if (
(*p == ' ') || (*p == '\t') || (*p == '\n') ||
(*p == '\\') || (*p == '\'') || (*p == '\"') ||
(*p == ';') || (*p == '!') || (*p == '#') ||
(*p == '$') || (*p == '%') || (*p == '&') ||
(*p == '*') || (*p == '(') || (*p == ')') ||
(*p == '[') || (*p == ']') || (*p == '{') ||
(*p == '}') || (*p == '|') || (*p == '<') ||
(*p == '>') || (*p == '?')
)
{
*q = '\\';
q++;
}
*q = *p;
q++;
p++;
}
*q = 0;
return strdup(buf);
@ -898,12 +898,12 @@ ecore_file_strip_ext(const char *path)
file = strdup(path);
else if (p != path)
{
file = malloc(((p - path) + 1) * sizeof(char));
if (file)
{
memcpy(file, path, (p - path));
file[p - path] = 0;
}
file = malloc(((p - path) + 1) * sizeof(char));
if (file)
{
memcpy(file, path, (p - path));
file[p - path] = 0;
}
}
return file;
@ -925,11 +925,11 @@ ecore_file_dir_is_empty(const char *dir)
while ((dp = readdir(dirp)))
{
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
closedir(dirp);
return 0;
}
if ((strcmp(dp->d_name, ".")) && (strcmp(dp->d_name, "..")))
{
closedir(dirp);
return 0;
}
}
closedir(dirp);

View File

@ -13,37 +13,37 @@
#ifdef BUILD_ECORE_CON
#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8
#define ECORE_MAGIC_FILE_DOWNLOAD_JOB 0xf7427cb8
struct _Ecore_File_Download_Job
{
ECORE_MAGIC;
Ecore_Con_Url *url_con;
FILE *file;
Ecore_Con_Url *url_con;
FILE *file;
char *dst;
char *dst;
void (*completion_cb)(void *data, const char *file, int status);
void (*completion_cb)(void *data, const char *file, int status);
int (*progress_cb) (void *data, const char *file,
long int dltotal, long int dlnow,
long int ultotal, long int ulnow);
int (*progress_cb) (void *data, const char *file,
long int dltotal, long int dlnow,
long int ultotal, long int ulnow);
};
#ifdef HAVE_CURL
Ecore_File_Download_Job *_ecore_file_download_curl(const char *url, const char *dst,
void (*completion_cb)(void *data, const char *file, int status),
int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow),
void *data);
void (*completion_cb)(void *data, const char *file, int status),
int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow),
void *data);
static Eina_Bool _ecore_file_download_url_complete_cb(void *data, int type, void *event);
static Eina_Bool _ecore_file_download_url_progress_cb(void *data, int type, void *event);
#endif
static Ecore_Event_Handler *_url_complete_handler = NULL;
static Ecore_Event_Handler *_url_progress_download = NULL;
static Eina_List *_job_list;
static Ecore_Event_Handler *_url_complete_handler = NULL;
static Ecore_Event_Handler *_url_progress_download = NULL;
static Eina_List *_job_list;
#endif /* BUILD_ECORE_CON */
@ -87,7 +87,7 @@ ecore_file_download_abort_all(void)
Ecore_File_Download_Job *job;
EINA_LIST_FREE(_job_list, job)
ecore_file_download_abort(job);
ecore_file_download_abort(job);
#endif /* BUILD_ECORE_CON */
}
@ -111,17 +111,17 @@ ecore_file_download_abort_all(void)
*/
EAPI Eina_Bool
ecore_file_download(const char *url, const char *dst,
void (*completion_cb)(void *data, const char *file, int status),
int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow),
void *data, Ecore_File_Download_Job **job_ret)
void (*completion_cb)(void *data, const char *file, int status),
int (*progress_cb)(void *data, const char *file, long int dltotal, long int dlnow, long int ultotal, long int ulnow),
void *data, Ecore_File_Download_Job **job_ret)
{
#ifdef BUILD_ECORE_CON
char *dir = ecore_file_dir_get(dst);
if (!ecore_file_is_dir(dir))
{
free(dir);
return EINA_FALSE;
free(dir);
return EINA_FALSE;
}
free(dir);
if (ecore_file_exists(dst)) return EINA_FALSE;
@ -129,30 +129,30 @@ ecore_file_download(const char *url, const char *dst,
/* FIXME: Add handlers for http and ftp! */
if (!strncmp(url, "file://", 7))
{
/* FIXME: Maybe fork? Might take a while to copy.
* Check filesize? */
/* Just copy it */
/* FIXME: Maybe fork? Might take a while to copy.
* Check filesize? */
/* Just copy it */
url += 7;
/* skip hostname */
url = strchr(url, '/');
return ecore_file_cp(url, dst);
url += 7;
/* skip hostname */
url = strchr(url, '/');
return ecore_file_cp(url, dst);
}
# ifdef HAVE_CURL
else if ((!strncmp(url, "http://", 7)) ||
(!strncmp(url, "ftp://", 6)))
(!strncmp(url, "ftp://", 6)))
{
/* download */
Ecore_File_Download_Job *job;
/* download */
Ecore_File_Download_Job *job;
job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data);
if(job_ret) *job_ret = job;
return job ? EINA_TRUE : EINA_FALSE;
job = _ecore_file_download_curl(url, dst, completion_cb, progress_cb, data);
if(job_ret) *job_ret = job;
return job ? EINA_TRUE : EINA_FALSE;
}
# endif
else
{
return EINA_FALSE;
return EINA_FALSE;
}
#else
completion_cb = NULL;
@ -190,8 +190,8 @@ ecore_file_download_protocol_available(const char *protocol)
static int
_ecore_file_download_url_compare_job(const void *data1, const void *data2)
{
const Ecore_File_Download_Job *job = data1;
const Ecore_Con_Url *url = data2;
const Ecore_File_Download_Job *job = data1;
const Ecore_Con_Url *url = data2;
if (job->url_con == url) return 0;
return -1;
@ -200,8 +200,8 @@ _ecore_file_download_url_compare_job(const void *data1, const void *data2)
static Eina_Bool
_ecore_file_download_url_complete_cb(void *data __UNUSED__, int type __UNUSED__, void *event)
{
Ecore_Con_Event_Url_Complete *ev = event;
Ecore_File_Download_Job *job;
Ecore_Con_Event_Url_Complete *ev = event;
Ecore_File_Download_Job *job;
job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con);
if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON;
@ -222,23 +222,23 @@ _ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__,
{
/* this reports the downloads progress. if we return 0, then download
* continues, if we return anything else, then the download stops */
Ecore_Con_Event_Url_Progress *ev = event;
Ecore_File_Download_Job *job;
Ecore_Con_Event_Url_Progress *ev = event;
Ecore_File_Download_Job *job;
job = eina_list_search_unsorted(_job_list, _ecore_file_download_url_compare_job, ev->url_con);
if (!ECORE_MAGIC_CHECK(job, ECORE_MAGIC_FILE_DOWNLOAD_JOB)) return ECORE_CALLBACK_PASS_ON;
if (job->progress_cb)
if (job->progress_cb(ecore_con_url_data_get(job->url_con), job->dst,
(long int) ev->down.total, (long int) ev->down.now,
(long int) ev->up.total, (long int) ev->up.now) != 0)
(long int) ev->down.total, (long int) ev->down.now,
(long int) ev->up.total, (long int) ev->up.now) != 0)
{
_job_list = eina_list_remove(_job_list, job);
fclose(job->file);
free(job->dst);
free(job);
_job_list = eina_list_remove(_job_list, job);
fclose(job->file);
free(job->dst);
free(job);
return ECORE_CALLBACK_PASS_ON;
return ECORE_CALLBACK_PASS_ON;
}
return ECORE_CALLBACK_DONE;
@ -246,12 +246,12 @@ _ecore_file_download_url_progress_cb(void *data __UNUSED__, int type __UNUSED__,
Ecore_File_Download_Job *
_ecore_file_download_curl(const char *url, const char *dst,
void (*completion_cb)(void *data, const char *file,
int status),
int (*progress_cb)(void *data, const char *file,
long int dltotal, long int dlnow,
long int ultotal, long int ulnow),
void *data)
void (*completion_cb)(void *data, const char *file,
int status),
int (*progress_cb)(void *data, const char *file,
long int dltotal, long int dlnow,
long int ultotal, long int ulnow),
void *data)
{
Ecore_File_Download_Job *job;
@ -263,15 +263,15 @@ _ecore_file_download_curl(const char *url, const char *dst,
job->file = fopen(dst, "wb");
if (!job->file)
{
free(job);
return NULL;
free(job);
return NULL;
}
job->url_con = ecore_con_url_new(url);
if (!job->url_con)
{
fclose(job->file);
free(job);
return NULL;
fclose(job->file);
free(job);
return NULL;
}
ecore_con_url_fd_set(job->url_con, fileno(job->file));

View File

@ -47,21 +47,21 @@ ecore_file_monitor_shutdown(void)
switch (monitor_type)
{
case ECORE_FILE_MONITOR_TYPE_NONE:
break;
break;
#ifdef HAVE_INOTIFY
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
ecore_file_monitor_inotify_shutdown();
break;
ecore_file_monitor_inotify_shutdown();
break;
#endif
#ifdef HAVE_NOTIFY_WIN32
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
ecore_file_monitor_win32_shutdown();
break;
ecore_file_monitor_win32_shutdown();
break;
#endif
#ifdef HAVE_POLL
case ECORE_FILE_MONITOR_TYPE_POLL:
ecore_file_monitor_poll_shutdown();
break;
ecore_file_monitor_poll_shutdown();
break;
#endif
}
}
@ -84,18 +84,18 @@ ecore_file_monitor_add(const char *path,
switch (monitor_type)
{
case ECORE_FILE_MONITOR_TYPE_NONE:
return NULL;
return NULL;
#ifdef HAVE_INOTIFY
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
return ecore_file_monitor_inotify_add(path, func, data);
return ecore_file_monitor_inotify_add(path, func, data);
#endif
#ifdef HAVE_NOTIFY_WIN32
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
return ecore_file_monitor_win32_add(path, func, data);
return ecore_file_monitor_win32_add(path, func, data);
#endif
#ifdef HAVE_POLL
case ECORE_FILE_MONITOR_TYPE_POLL:
return ecore_file_monitor_poll_add(path, func, data);
return ecore_file_monitor_poll_add(path, func, data);
#endif
}
return NULL;
@ -111,21 +111,21 @@ ecore_file_monitor_del(Ecore_File_Monitor *em)
switch (monitor_type)
{
case ECORE_FILE_MONITOR_TYPE_NONE:
break;
break;
#ifdef HAVE_INOTIFY
case ECORE_FILE_MONITOR_TYPE_INOTIFY:
ecore_file_monitor_inotify_del(em);
break;
ecore_file_monitor_inotify_del(em);
break;
#endif
#ifdef HAVE_NOTIFY_WIN32
case ECORE_FILE_MONITOR_TYPE_NOTIFY_WIN32:
ecore_file_monitor_win32_del(em);
break;
ecore_file_monitor_win32_del(em);
break;
#endif
#ifdef HAVE_POLL
case ECORE_FILE_MONITOR_TYPE_POLL:
ecore_file_monitor_poll_del(em);
break;
ecore_file_monitor_poll_del(em);
break;
#endif
}
}

View File

@ -65,11 +65,11 @@ ecore_file_monitor_inotify_init(void)
return 0;
_fdh = ecore_main_fd_handler_add(fd, ECORE_FD_READ, _ecore_file_monitor_inotify_handler,
NULL, NULL, NULL);
NULL, NULL, NULL);
if (!_fdh)
{
close(fd);
return 0;
close(fd);
return 0;
}
return 1;
@ -81,23 +81,23 @@ ecore_file_monitor_inotify_shutdown(void)
int fd;
while(_monitors)
ecore_file_monitor_inotify_del(_monitors);
ecore_file_monitor_inotify_del(_monitors);
if (_fdh)
{
fd = ecore_main_fd_handler_fd_get(_fdh);
ecore_main_fd_handler_del(_fdh);
close(fd);
fd = ecore_main_fd_handler_fd_get(_fdh);
ecore_main_fd_handler_del(_fdh);
close(fd);
}
return 1;
}
Ecore_File_Monitor *
ecore_file_monitor_inotify_add(const char *path,
void (*func) (void *data, Ecore_File_Monitor *em,
Ecore_File_Event event,
const char *path),
void *data)
void (*func) (void *data, Ecore_File_Monitor *em,
Ecore_File_Event event,
const char *path),
void *data)
{
Ecore_File_Monitor *em;
int len;
@ -117,13 +117,13 @@ ecore_file_monitor_inotify_add(const char *path,
if (ecore_file_exists(em->path))
{
if (!_ecore_file_monitor_inotify_monitor(em, em->path))
return NULL;
if (!_ecore_file_monitor_inotify_monitor(em, em->path))
return NULL;
}
else
{
ecore_file_monitor_inotify_del(em);
return NULL;
ecore_file_monitor_inotify_del(em);
return NULL;
}
return em;
@ -156,14 +156,14 @@ _ecore_file_monitor_inotify_handler(void *data __UNUSED__, Ecore_Fd_Handler *fdh
size = read(ecore_main_fd_handler_fd_get(fdh), buffer, sizeof(buffer));
while (i < size)
{
event = (struct inotify_event *)&buffer[i];
event_size = sizeof(struct inotify_event) + event->len;
i += event_size;
event = (struct inotify_event *)&buffer[i];
event_size = sizeof(struct inotify_event) + event->len;
i += event_size;
em = _ecore_file_monitor_inotify_monitor_find(event->wd);
if (!em) continue;
em = _ecore_file_monitor_inotify_monitor_find(event->wd);
if (!em) continue;
_ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask);
_ecore_file_monitor_inotify_events(em, (event->len ? event->name : NULL), event->mask);
}
return ECORE_CALLBACK_RENEW;
@ -176,8 +176,8 @@ _ecore_file_monitor_inotify_monitor_find(int wd)
EINA_INLIST_FOREACH(_monitors, l)
{
if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd)
return l;
if (ECORE_FILE_MONITOR_INOTIFY(l)->wd == wd)
return l;
}
return NULL;
}
@ -200,62 +200,62 @@ _ecore_file_monitor_inotify_events(Ecore_File_Monitor *em, char *file, int mask)
if (mask & IN_MODIFY)
{
if (!isdir)
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
if (!isdir)
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
}
if (mask & IN_MOVED_FROM)
{
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
}
if (mask & IN_MOVED_TO)
{
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
}
if (mask & IN_DELETE)
{
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_FILE, buf);
}
if (mask & IN_CREATE)
{
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
if (isdir)
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_DIRECTORY, buf);
else
em->func(em->data, em, ECORE_FILE_EVENT_CREATED_FILE, buf);
}
if (mask & IN_DELETE_SELF)
{
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
if (mask & IN_MOVE_SELF)
{
/* We just call delete. The dir is gone... */
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
/* We just call delete. The dir is gone... */
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
if (mask & IN_UNMOUNT)
{
/* We just call delete. The dir is gone... */
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
/* We just call delete. The dir is gone... */
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
if (mask & IN_IGNORED)
{
/* The watch is removed. If the file name still exists monitor the new one,
* else delete it */
if (ecore_file_exists(em->path))
{
if (!_ecore_file_monitor_inotify_monitor(em, em->path))
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
/* The watch is removed. If the file name still exists monitor the new one,
* else delete it */
if (ecore_file_exists(em->path))
{
if (!_ecore_file_monitor_inotify_monitor(em, em->path))
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
else
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
}
}
@ -264,17 +264,17 @@ _ecore_file_monitor_inotify_monitor(Ecore_File_Monitor *em, const char *path)
{
int mask;
mask = IN_MODIFY|
IN_MOVED_FROM|IN_MOVED_TO|
IN_DELETE|IN_CREATE|
IN_DELETE_SELF|IN_MOVE_SELF|
IN_UNMOUNT;
IN_MOVED_FROM|IN_MOVED_TO|
IN_DELETE|IN_CREATE|
IN_DELETE_SELF|IN_MOVE_SELF|
IN_UNMOUNT;
ECORE_FILE_MONITOR_INOTIFY(em)->wd = inotify_add_watch(ecore_main_fd_handler_fd_get(_fdh),
path, mask);
path, mask);
if (ECORE_FILE_MONITOR_INOTIFY(em)->wd < 0)
{
ERR("inotify_add_watch error");
ecore_file_monitor_inotify_del(em);
return 0;
ERR("inotify_add_watch error");
ecore_file_monitor_inotify_del(em);
return 0;
}
return 1;
}
@ -312,35 +312,35 @@ _ecore_file_monitor_inotify_print(char *file, int mask)
if (mask & IN_MODIFY)
{
WRN("Inotify modified %s: %s", type, file);
WRN("Inotify modified %s: %s", type, file);
}
if (mask & IN_MOVED_FROM)
{
WRN("Inotify moved from %s: %s", type, file);
WRN("Inotify moved from %s: %s", type, file);
}
if (mask & IN_MOVED_TO)
{
WRN("Inotify moved to %s: %s", type, file);
WRN("Inotify moved to %s: %s", type, file);
}
if (mask & IN_DELETE)
{
WRN("Inotify delete %s: %s", type, file);
WRN("Inotify delete %s: %s", type, file);
}
if (mask & IN_CREATE)
{
WRN("Inotify create %s: %s", type, file);
WRN("Inotify create %s: %s", type, file);
}
if (mask & IN_DELETE_SELF)
{
WRN("Inotify delete self %s: %s", type, file);
WRN("Inotify delete self %s: %s", type, file);
}
if (mask & IN_MOVE_SELF)
{
WRN("Inotify move self %s: %s", type, file);
WRN("Inotify move self %s: %s", type, file);
}
if (mask & IN_UNMOUNT)
{
WRN("Inotify unmount %s: %s", type, file);
WRN("Inotify unmount %s: %s", type, file);
}
}
#endif

View File

@ -51,22 +51,22 @@ int
ecore_file_monitor_poll_shutdown(void)
{
while(_monitors)
ecore_file_monitor_poll_del(_monitors);
ecore_file_monitor_poll_del(_monitors);
if (_timer)
{
ecore_timer_del(_timer);
_timer = NULL;
ecore_timer_del(_timer);
_timer = NULL;
}
return 1;
}
Ecore_File_Monitor *
ecore_file_monitor_poll_add(const char *path,
void (*func) (void *data, Ecore_File_Monitor *em,
Ecore_File_Event event,
const char *path),
void *data)
void (*func) (void *data, Ecore_File_Monitor *em,
Ecore_File_Event event,
const char *path),
void *data)
{
Ecore_File_Monitor *em;
size_t len;
@ -95,37 +95,37 @@ ecore_file_monitor_poll_add(const char *path,
if (ecore_file_exists(em->path))
{
if (ecore_file_is_dir(em->path))
{
/* Check for subdirs */
Eina_List *files;
char *file;
if (ecore_file_is_dir(em->path))
{
/* Check for subdirs */
Eina_List *files;
char *file;
files = ecore_file_ls(em->path);
EINA_LIST_FREE(files, file)
{
Ecore_File *f;
char buf[PATH_MAX];
files = ecore_file_ls(em->path);
EINA_LIST_FREE(files, file)
{
Ecore_File *f;
char buf[PATH_MAX];
f = calloc(1, sizeof(Ecore_File));
if (!f)
{
free(file);
continue;
}
f = calloc(1, sizeof(Ecore_File));
if (!f)
{
free(file);
continue;
}
snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
f->name = file;
f->mtime = ecore_file_mod_time(buf);
f->is_dir = ecore_file_is_dir(buf);
em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
}
}
snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
f->name = file;
f->mtime = ecore_file_mod_time(buf);
f->is_dir = ecore_file_is_dir(buf);
em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
}
}
}
else
{
ecore_file_monitor_poll_del(em);
return NULL;
ecore_file_monitor_poll_del(em);
return NULL;
}
return em;
@ -138,22 +138,22 @@ ecore_file_monitor_poll_del(Ecore_File_Monitor *em)
if (_lock)
{
ECORE_FILE_MONITOR_POLL(em)->deleted = 1;
return;
ECORE_FILE_MONITOR_POLL(em)->deleted = 1;
return;
}
/* Remove files */
/*It's possible there weren't any files to monitor, so check if the list is init*/
if (em->files)
{
for (l = em->files; l;)
{
Ecore_File *file = l;
for (l = em->files; l;)
{
Ecore_File *file = l;
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
free(file->name);
free(file);
}
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
free(file->name);
free(file);
}
}
if (_monitors)
@ -164,13 +164,13 @@ ecore_file_monitor_poll_del(Ecore_File_Monitor *em)
if (_timer)
{
if (!_monitors)
{
ecore_timer_del(_timer);
_timer = NULL;
}
else
ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
if (!_monitors)
{
ecore_timer_del(_timer);
_timer = NULL;
}
else
ecore_timer_interval_set(_timer, ECORE_FILE_INTERVAL_MIN);
}
}
@ -183,7 +183,7 @@ _ecore_file_monitor_poll_handler(void *data __UNUSED__)
_lock = 1;
EINA_INLIST_FOREACH(_monitors, l)
_ecore_file_monitor_poll_check(l);
_ecore_file_monitor_poll_check(l);
_lock = 0;
if (_interval > ECORE_FILE_INTERVAL_MAX)
@ -192,11 +192,11 @@ _ecore_file_monitor_poll_handler(void *data __UNUSED__)
for (l = _monitors; l;)
{
Ecore_File_Monitor *em = l;
Ecore_File_Monitor *em = l;
l = ECORE_FILE_MONITOR(EINA_INLIST_GET(l)->next);
if (ECORE_FILE_MONITOR_POLL(em)->deleted)
ecore_file_monitor_del(em);
l = ECORE_FILE_MONITOR(EINA_INLIST_GET(l)->next);
if (ECORE_FILE_MONITOR_POLL(em)->deleted)
ecore_file_monitor_del(em);
}
return ECORE_CALLBACK_RENEW;
}
@ -209,117 +209,117 @@ _ecore_file_monitor_poll_check(Ecore_File_Monitor *em)
mtime = ecore_file_mod_time(em->path);
if (mtime < ECORE_FILE_MONITOR_POLL(em)->mtime)
{
Ecore_File *l;
Ecore_File_Event event;
Ecore_File *l;
Ecore_File_Event event;
/* Notify all files deleted */
for (l = em->files; l;)
{
Ecore_File *f = l;
char buf[PATH_MAX];
/* Notify all files deleted */
for (l = em->files; l;)
{
Ecore_File *f = l;
char buf[PATH_MAX];
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
if (f->is_dir)
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
else
event = ECORE_FILE_EVENT_DELETED_FILE;
em->func(em->data, em, event, buf);
free(f->name);
free(f);
}
em->files = NULL;
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
_interval = ECORE_FILE_INTERVAL_MIN;
snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
if (f->is_dir)
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
else
event = ECORE_FILE_EVENT_DELETED_FILE;
em->func(em->data, em, event, buf);
free(f->name);
free(f);
}
em->files = NULL;
em->func(em->data, em, ECORE_FILE_EVENT_DELETED_SELF, em->path);
_interval = ECORE_FILE_INTERVAL_MIN;
}
else
{
Ecore_File *l;
Ecore_File *l;
/* Check for changed files */
for (l = em->files; l;)
{
Ecore_File *f = l;
char buf[PATH_MAX];
int mtime;
Ecore_File_Event event;
/* Check for changed files */
for (l = em->files; l;)
{
Ecore_File *f = l;
char buf[PATH_MAX];
int mtime;
Ecore_File_Event event;
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
l = (Ecore_File *) EINA_INLIST_GET(l)->next;
snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
mtime = ecore_file_mod_time(buf);
if (mtime < f->mtime)
{
if (f->is_dir)
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
else
event = ECORE_FILE_EVENT_DELETED_FILE;
snprintf(buf, sizeof(buf), "%s/%s", em->path, f->name);
mtime = ecore_file_mod_time(buf);
if (mtime < f->mtime)
{
if (f->is_dir)
event = ECORE_FILE_EVENT_DELETED_DIRECTORY;
else
event = ECORE_FILE_EVENT_DELETED_FILE;
em->func(em->data, em, event, buf);
em->files = (Ecore_File *) eina_inlist_remove(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
free(f->name);
free(f);
_interval = ECORE_FILE_INTERVAL_MIN;
}
else if ((mtime > f->mtime) && !(f->is_dir))
{
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
_interval = ECORE_FILE_INTERVAL_MIN;
f->mtime = mtime;
}
else
f->mtime = mtime;
}
em->func(em->data, em, event, buf);
em->files = (Ecore_File *) eina_inlist_remove(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
free(f->name);
free(f);
_interval = ECORE_FILE_INTERVAL_MIN;
}
else if ((mtime > f->mtime) && !(f->is_dir))
{
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, buf);
_interval = ECORE_FILE_INTERVAL_MIN;
f->mtime = mtime;
}
else
f->mtime = mtime;
}
/* Check for new files */
if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime)
{
Eina_List *files;
Eina_List *l;
char *file;
/* Check for new files */
if (ECORE_FILE_MONITOR_POLL(em)->mtime < mtime)
{
Eina_List *files;
Eina_List *l;
char *file;
/* Files have been added or removed */
files = ecore_file_ls(em->path);
if (files)
{
/* Are we a directory? We should check first, rather than rely on null here*/
EINA_LIST_FOREACH(files, l, file)
{
Ecore_File *f;
char buf[PATH_MAX];
Ecore_File_Event event;
/* Files have been added or removed */
files = ecore_file_ls(em->path);
if (files)
{
/* Are we a directory? We should check first, rather than rely on null here*/
EINA_LIST_FOREACH(files, l, file)
{
Ecore_File *f;
char buf[PATH_MAX];
Ecore_File_Event event;
if (_ecore_file_monitor_poll_checking(em, file))
continue;
if (_ecore_file_monitor_poll_checking(em, file))
continue;
snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
f = calloc(1, sizeof(Ecore_File));
if (!f)
continue;
snprintf(buf, sizeof(buf), "%s/%s", em->path, file);
f = calloc(1, sizeof(Ecore_File));
if (!f)
continue;
f->name = strdup(file);
f->mtime = ecore_file_mod_time(buf);
f->is_dir = ecore_file_mod_time(buf);
if (f->is_dir)
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
else
event = ECORE_FILE_EVENT_CREATED_FILE;
em->func(em->data, em, event, buf);
em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
}
while (files)
{
file = eina_list_data_get(files);
free(file);
files = eina_list_remove_list(files, files);
}
}
f->name = strdup(file);
f->mtime = ecore_file_mod_time(buf);
f->is_dir = ecore_file_mod_time(buf);
if (f->is_dir)
event = ECORE_FILE_EVENT_CREATED_DIRECTORY;
else
event = ECORE_FILE_EVENT_CREATED_FILE;
em->func(em->data, em, event, buf);
em->files = (Ecore_File *) eina_inlist_append(EINA_INLIST_GET(em->files), EINA_INLIST_GET(f));
}
while (files)
{
file = eina_list_data_get(files);
free(file);
files = eina_list_remove_list(files, files);
}
}
if (!ecore_file_is_dir(em->path))
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path);
_interval = ECORE_FILE_INTERVAL_MIN;
}
if (!ecore_file_is_dir(em->path))
em->func(em->data, em, ECORE_FILE_EVENT_MODIFIED, em->path);
_interval = ECORE_FILE_INTERVAL_MIN;
}
}
ECORE_FILE_MONITOR_POLL(em)->mtime = mtime;
}
@ -331,8 +331,8 @@ _ecore_file_monitor_poll_checking(Ecore_File_Monitor *em, char *name)
EINA_INLIST_FOREACH(em->files, l)
{
if (!strcmp(l->name, name))
return 1;
if (!strcmp(l->name, name))
return 1;
}
return 0;
}

View File

@ -45,8 +45,8 @@ _ecore_file_path_from_env(const char *env)
if (!*p)
{
if (!ecore_file_path_dir_exists(last))
path = eina_list_append(path, strdup(last));
if (!ecore_file_path_dir_exists(last))
path = eina_list_append(path, strdup(last));
last = p + 1;
}
}
@ -71,8 +71,8 @@ ecore_file_path_dir_exists(const char *in_dir)
if (!__ecore_file_path_bin) return EINA_FALSE;
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
{
if (strcmp(dir, in_dir))
return EINA_TRUE;
if (strcmp(dir, in_dir))
return EINA_TRUE;
}
return EINA_FALSE;
@ -97,9 +97,9 @@ ecore_file_app_installed(const char *exe)
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
{
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
if (ecore_file_can_exec(buf))
return EINA_TRUE;
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
if (ecore_file_can_exec(buf))
return EINA_TRUE;
}
return EINA_FALSE;
@ -119,15 +119,15 @@ ecore_file_app_list(void)
EINA_LIST_FOREACH(__ecore_file_path_bin, l, dir)
{
files = ecore_file_ls(dir);
EINA_LIST_FREE(files, exe)
{
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
if ((ecore_file_can_exec(buf)) &&
(!ecore_file_is_dir(buf)))
list = eina_list_append(list, strdup(buf));
free(exe);
}
files = ecore_file_ls(dir);
EINA_LIST_FREE(files, exe)
{
snprintf(buf, sizeof(buf), "%s/%s", dir, exe);
if ((ecore_file_can_exec(buf)) &&
(!ecore_file_is_dir(buf)))
list = eina_list_append(list, strdup(buf));
free(exe);
}
}
return list;

View File

@ -73,9 +73,9 @@ struct _Ecore_File_Monitor
{
EINA_INLIST;
void (*func) (void *data,
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path);
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path);
char *path;
void *data;
@ -86,11 +86,11 @@ struct _Ecore_File_Monitor
int ecore_file_monitor_inotify_init(void);
int ecore_file_monitor_inotify_shutdown(void);
Ecore_File_Monitor *ecore_file_monitor_inotify_add(const char *path,
void (*func) (void *data,
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path),
void *data);
void (*func) (void *data,
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path),
void *data);
void ecore_file_monitor_inotify_del(Ecore_File_Monitor *ecore_file_monitor);
#endif
@ -110,11 +110,11 @@ void ecore_file_monitor_win32_del(Ecore_File_Monitor *ecore_file_
int ecore_file_monitor_poll_init(void);
int ecore_file_monitor_poll_shutdown(void);
Ecore_File_Monitor *ecore_file_monitor_poll_add(const char *path,
void (*func) (void *data,
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path),
void *data);
void (*func) (void *data,
Ecore_File_Monitor *ecore_file_monitor,
Ecore_File_Event event,
const char *path),
void *data);
void ecore_file_monitor_poll_del(Ecore_File_Monitor *ecore_file_monitor);
#endif