2011-04-25 10:04:46 -07:00
|
|
|
/* EIO - EFL data type library
|
|
|
|
* Copyright (C) 2011 Enlightenment Developers:
|
|
|
|
* Cedric Bail <cedric.bail@free.fr>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library;
|
|
|
|
* if not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-05-20 06:10:00 -07:00
|
|
|
#include <evil_private.h> /* evil_wchar_to_char evil_last_error_get */
|
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
#include "eio_private.h"
|
|
|
|
#include "Eio.h"
|
|
|
|
|
2012-03-31 00:01:24 -07:00
|
|
|
/*============================================================================*
|
|
|
|
* Local *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2012-04-02 09:46:16 -07:00
|
|
|
typedef struct _Eio_Monitor_Win32_Watcher Eio_Monitor_Win32_Watcher;
|
|
|
|
|
|
|
|
/* 4096 = 256 * sizeof(FILE_NOTIFY_INFORMATION) */
|
|
|
|
# define EIO_MONITOR_WIN32_BUFFER_SIZE 4096
|
|
|
|
|
|
|
|
struct _Eio_Monitor_Win32_Watcher
|
|
|
|
{
|
|
|
|
char buffer[EIO_MONITOR_WIN32_BUFFER_SIZE];
|
|
|
|
OVERLAPPED overlapped;
|
|
|
|
HANDLE handle;
|
|
|
|
HANDLE event;
|
|
|
|
Eio_Monitor *monitor;
|
|
|
|
Ecore_Win32_Handler *h;
|
2014-05-20 02:00:14 -07:00
|
|
|
Eina_Stringshare *current;
|
|
|
|
Eina_Stringshare *file;
|
2012-04-02 09:46:16 -07:00
|
|
|
DWORD buf_length;
|
2012-09-05 23:30:29 -07:00
|
|
|
Eina_Bool monitor_file : 1;
|
|
|
|
Eina_Bool monitor_parent : 1;
|
2012-04-02 09:46:16 -07:00
|
|
|
};
|
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
struct _Eio_Monitor_Backend
|
|
|
|
{
|
2012-04-02 09:46:16 -07:00
|
|
|
Eio_Monitor *parent;
|
2012-09-05 23:30:29 -07:00
|
|
|
Eio_Monitor_Win32_Watcher *watcher_file;
|
|
|
|
Eio_Monitor_Win32_Watcher *watcher_dir;
|
|
|
|
Eio_Monitor_Win32_Watcher *watcher_parent;
|
2011-04-25 10:04:46 -07:00
|
|
|
};
|
|
|
|
|
2012-04-02 09:46:16 -07:00
|
|
|
static Eina_Bool
|
2012-12-04 09:40:58 -08:00
|
|
|
_eio_monitor_win32_cb(void *data, Ecore_Win32_Handler *wh EINA_UNUSED)
|
2012-04-02 09:46:16 -07:00
|
|
|
{
|
|
|
|
PFILE_NOTIFY_INFORMATION fni;
|
|
|
|
Eio_Monitor_Win32_Watcher *w;
|
|
|
|
wchar_t *wname;
|
|
|
|
char *name;
|
|
|
|
DWORD filter;
|
|
|
|
DWORD offset;
|
|
|
|
DWORD buf_length;
|
2012-09-05 23:30:29 -07:00
|
|
|
int event;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
w = (Eio_Monitor_Win32_Watcher *)data;
|
|
|
|
|
2015-01-30 01:49:49 -08:00
|
|
|
if (!GetOverlappedResult(w->handle, &w->overlapped, &buf_length, FALSE))
|
2012-04-02 09:46:16 -07:00
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
|
|
|
|
fni = (PFILE_NOTIFY_INFORMATION)w->buffer;
|
|
|
|
do {
|
|
|
|
if (!fni)
|
|
|
|
break;
|
|
|
|
offset = fni->NextEntryOffset;
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
wname = (wchar_t *)malloc(fni->FileNameLength + sizeof(wchar_t));
|
2012-04-02 09:46:16 -07:00
|
|
|
if (!wname)
|
|
|
|
return 0;
|
|
|
|
|
2015-02-03 04:25:58 -08:00
|
|
|
if (fni->FileName[0] == 0)
|
2015-10-08 03:17:29 -07:00
|
|
|
{
|
|
|
|
free(wname);
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
2015-02-03 04:25:58 -08:00
|
|
|
|
2012-04-02 09:46:16 -07:00
|
|
|
memcpy(wname, fni->FileName, fni->FileNameLength);
|
2012-09-05 23:30:29 -07:00
|
|
|
wname[fni->FileNameLength / sizeof(wchar_t)] = 0;
|
2012-04-02 09:46:16 -07:00
|
|
|
name = evil_wchar_to_char(wname);
|
|
|
|
free(wname);
|
|
|
|
if (!name)
|
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
event = -1;
|
2012-04-02 09:46:16 -07:00
|
|
|
switch (fni->Action)
|
|
|
|
{
|
|
|
|
case FILE_ACTION_ADDED:
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!w->monitor_parent)
|
|
|
|
{
|
|
|
|
if (w->monitor_file)
|
|
|
|
event = EIO_MONITOR_FILE_CREATED;
|
|
|
|
else
|
|
|
|
event = EIO_MONITOR_DIRECTORY_CREATED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
break;
|
|
|
|
case FILE_ACTION_REMOVED:
|
2012-09-05 23:30:29 -07:00
|
|
|
if (w->monitor_parent)
|
|
|
|
{
|
|
|
|
char path[MAX_PATH];
|
|
|
|
char *res;
|
|
|
|
|
|
|
|
res = _fullpath(path, name, MAX_PATH);
|
|
|
|
if (res && (strcmp(res, w->current) == 0))
|
|
|
|
event = EIO_MONITOR_SELF_DELETED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
else
|
2012-09-05 23:30:29 -07:00
|
|
|
{
|
|
|
|
if (w->monitor_file)
|
|
|
|
event = EIO_MONITOR_FILE_DELETED;
|
|
|
|
else
|
|
|
|
event = EIO_MONITOR_DIRECTORY_DELETED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
break;
|
|
|
|
case FILE_ACTION_MODIFIED:
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!w->monitor_parent)
|
|
|
|
{
|
|
|
|
if (w->monitor_file)
|
|
|
|
event = EIO_MONITOR_FILE_MODIFIED;
|
|
|
|
else
|
|
|
|
event = EIO_MONITOR_DIRECTORY_MODIFIED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
break;
|
|
|
|
case FILE_ACTION_RENAMED_OLD_NAME:
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!w->monitor_parent)
|
|
|
|
{
|
|
|
|
if (w->monitor_file)
|
|
|
|
event = EIO_MONITOR_FILE_DELETED;
|
|
|
|
else
|
|
|
|
event = EIO_MONITOR_DIRECTORY_DELETED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
break;
|
|
|
|
case FILE_ACTION_RENAMED_NEW_NAME:
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!w->monitor_parent)
|
|
|
|
{
|
|
|
|
if (w->monitor_file)
|
|
|
|
event = EIO_MONITOR_FILE_CREATED;
|
|
|
|
else
|
|
|
|
event = EIO_MONITOR_DIRECTORY_CREATED;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
break;
|
|
|
|
default:
|
2012-09-05 23:30:29 -07:00
|
|
|
ERR("unknown event");
|
2012-04-02 09:46:16 -07:00
|
|
|
event = EIO_MONITOR_ERROR;
|
|
|
|
break;
|
|
|
|
}
|
2012-09-05 23:30:29 -07:00
|
|
|
|
2015-02-27 06:18:47 -08:00
|
|
|
if (w->monitor)
|
|
|
|
{
|
|
|
|
if ((event >= 0) && (event != EIO_MONITOR_ERROR))
|
|
|
|
_eio_monitor_send(w->monitor, name, event);
|
|
|
|
}
|
2012-09-05 23:30:29 -07:00
|
|
|
|
|
|
|
free(name);
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
fni = (PFILE_NOTIFY_INFORMATION)((LPBYTE)fni + offset);
|
|
|
|
} while (offset);
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
filter =
|
2012-04-02 09:46:16 -07:00
|
|
|
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
|
|
|
FILE_NOTIFY_CHANGE_SIZE |
|
|
|
|
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
|
|
|
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
|
|
|
FILE_NOTIFY_CHANGE_CREATION |
|
|
|
|
FILE_NOTIFY_CHANGE_SECURITY;
|
2012-09-05 23:30:29 -07:00
|
|
|
if (w->monitor_file)
|
|
|
|
filter |= FILE_NOTIFY_CHANGE_FILE_NAME;
|
|
|
|
else
|
|
|
|
filter |= FILE_NOTIFY_CHANGE_DIR_NAME;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
2015-02-27 06:18:47 -08:00
|
|
|
if (!ReadDirectoryChangesW(w->handle,
|
|
|
|
(LPVOID)w->buffer,
|
|
|
|
EIO_MONITOR_WIN32_BUFFER_SIZE,
|
|
|
|
FALSE,
|
|
|
|
filter,
|
|
|
|
&w->buf_length,
|
|
|
|
&w->overlapped,
|
|
|
|
NULL))
|
|
|
|
{
|
2017-12-10 22:06:02 -08:00
|
|
|
ERR("%s", evil_last_error_get());
|
2015-02-27 06:18:47 -08:00
|
|
|
return ECORE_CALLBACK_CANCEL;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eio_Monitor_Win32_Watcher *
|
2014-05-20 02:00:14 -07:00
|
|
|
_eio_monitor_win32_watcher_new(Eio_Monitor *monitor,
|
|
|
|
Eina_Stringshare *current,
|
|
|
|
Eina_Stringshare *file,
|
|
|
|
Eina_Bool monitor_file,
|
|
|
|
Eina_Bool monitor_parent)
|
2012-04-02 09:46:16 -07:00
|
|
|
{
|
|
|
|
Eio_Monitor_Win32_Watcher *w;
|
2012-09-05 23:30:29 -07:00
|
|
|
char *monitored;
|
2012-04-02 09:46:16 -07:00
|
|
|
DWORD filter;
|
|
|
|
|
|
|
|
w = (Eio_Monitor_Win32_Watcher *)calloc(1, sizeof(Eio_Monitor_Win32_Watcher));
|
|
|
|
if (!w) return NULL;
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!monitor_parent)
|
2014-05-29 03:54:22 -07:00
|
|
|
monitored = (char *)current;
|
2012-09-05 23:30:29 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
tmp = strrchr(current, '\\');
|
|
|
|
monitored = (char *)alloca((tmp - current) + 1);
|
|
|
|
memcpy(monitored, current, tmp - current);
|
|
|
|
monitored[tmp - current] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
w->handle = CreateFile(monitored,
|
2012-04-02 09:46:16 -07:00
|
|
|
FILE_LIST_DIRECTORY,
|
|
|
|
FILE_SHARE_READ |
|
|
|
|
FILE_SHARE_WRITE,
|
|
|
|
NULL,
|
|
|
|
OPEN_EXISTING,
|
|
|
|
FILE_FLAG_BACKUP_SEMANTICS |
|
|
|
|
FILE_FLAG_OVERLAPPED,
|
|
|
|
NULL);
|
|
|
|
if (w->handle == INVALID_HANDLE_VALUE)
|
|
|
|
goto free_w;
|
|
|
|
|
|
|
|
w->event = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
|
|
if (!w->event)
|
|
|
|
goto close_handle;
|
|
|
|
|
|
|
|
ZeroMemory (&w->overlapped, sizeof(w->overlapped));
|
|
|
|
w->overlapped.hEvent = w->event;
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
filter =
|
2012-04-02 09:46:16 -07:00
|
|
|
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
|
|
|
FILE_NOTIFY_CHANGE_SIZE |
|
|
|
|
FILE_NOTIFY_CHANGE_LAST_WRITE |
|
|
|
|
FILE_NOTIFY_CHANGE_LAST_ACCESS |
|
|
|
|
FILE_NOTIFY_CHANGE_CREATION |
|
|
|
|
FILE_NOTIFY_CHANGE_SECURITY;
|
2012-09-05 23:30:29 -07:00
|
|
|
if (monitor_file)
|
|
|
|
filter |= FILE_NOTIFY_CHANGE_FILE_NAME;
|
|
|
|
else
|
|
|
|
filter |= FILE_NOTIFY_CHANGE_DIR_NAME;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
if (!ReadDirectoryChangesW(w->handle,
|
2012-08-27 22:49:38 -07:00
|
|
|
(LPVOID)w->buffer,
|
2012-04-02 09:46:16 -07:00
|
|
|
EIO_MONITOR_WIN32_BUFFER_SIZE,
|
|
|
|
FALSE,
|
|
|
|
filter,
|
|
|
|
&w->buf_length,
|
|
|
|
&w->overlapped,
|
|
|
|
NULL))
|
2012-08-27 22:49:38 -07:00
|
|
|
{
|
2017-12-10 22:06:02 -08:00
|
|
|
ERR("%s", evil_last_error_get());
|
2012-08-27 23:28:56 -07:00
|
|
|
goto close_event;
|
2012-08-27 22:49:38 -07:00
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
w->h = ecore_main_win32_handler_add(w->event,
|
|
|
|
_eio_monitor_win32_cb,
|
|
|
|
w);
|
|
|
|
if (!w->h)
|
|
|
|
goto close_event;
|
|
|
|
|
|
|
|
w->monitor = monitor;
|
2012-09-05 23:30:29 -07:00
|
|
|
w->monitor_file = monitor_file;
|
|
|
|
w->monitor_parent = monitor_parent;
|
2014-05-20 02:00:14 -07:00
|
|
|
w->file = eina_stringshare_ref(file);
|
|
|
|
w->current = eina_stringshare_ref(current);
|
2012-04-02 09:46:16 -07:00
|
|
|
|
|
|
|
return w;
|
|
|
|
|
|
|
|
close_event:
|
|
|
|
CloseHandle(w->event);
|
|
|
|
close_handle:
|
|
|
|
CloseHandle(w->handle);
|
|
|
|
free_w:
|
|
|
|
free(w);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_eio_monitor_win32_watcher_free(Eio_Monitor_Win32_Watcher *w)
|
|
|
|
{
|
|
|
|
if (!w) return;
|
|
|
|
|
2016-12-27 06:20:58 -08:00
|
|
|
ecore_main_win32_handler_del(w->h);
|
2014-05-20 02:00:14 -07:00
|
|
|
eina_stringshare_del(w->file);
|
|
|
|
eina_stringshare_del(w->current);
|
2012-04-02 09:46:16 -07:00
|
|
|
CloseHandle(w->event);
|
|
|
|
CloseHandle (w->handle);
|
|
|
|
free (w);
|
|
|
|
}
|
|
|
|
|
2012-03-31 00:01:24 -07:00
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* Global *
|
|
|
|
*============================================================================*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @cond LOCAL
|
|
|
|
*/
|
|
|
|
|
2011-04-25 10:04:46 -07:00
|
|
|
void eio_monitor_backend_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void eio_monitor_backend_shutdown(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void eio_monitor_backend_add(Eio_Monitor *monitor)
|
|
|
|
{
|
2012-09-05 23:30:29 -07:00
|
|
|
char path[PATH_MAX];
|
|
|
|
struct _stat s;
|
|
|
|
char *res;
|
2014-05-20 02:00:14 -07:00
|
|
|
Eina_Stringshare *current;
|
|
|
|
Eina_Stringshare *file = NULL;
|
2012-04-02 09:46:16 -07:00
|
|
|
Eio_Monitor_Backend *backend;
|
2012-09-05 23:30:29 -07:00
|
|
|
int ret;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
res = _fullpath(path, monitor->path, MAX_PATH);
|
|
|
|
if (!res)
|
|
|
|
goto fallback;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
ret = _stat(res, &s);
|
|
|
|
if (ret != 0)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
if (_S_IFDIR & s.st_mode)
|
2012-04-02 09:46:16 -07:00
|
|
|
{
|
2014-05-20 02:00:14 -07:00
|
|
|
current = eina_stringshare_add(path);
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!current)
|
|
|
|
goto fallback;
|
2012-04-02 09:46:16 -07:00
|
|
|
}
|
2012-09-05 23:30:29 -07:00
|
|
|
else if (_S_IFREG & s.st_mode)
|
2012-04-02 09:46:16 -07:00
|
|
|
{
|
2012-09-05 23:30:29 -07:00
|
|
|
char *tmp;
|
|
|
|
|
|
|
|
tmp = strrchr(path, '\\');
|
2014-05-20 02:00:14 -07:00
|
|
|
file = eina_stringshare_add(tmp + 1);
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!file)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
*tmp = '\0';
|
2014-05-20 02:00:14 -07:00
|
|
|
current = eina_stringshare_add(path);
|
2012-09-05 23:30:29 -07:00
|
|
|
if (!current)
|
|
|
|
{
|
2014-05-20 02:00:14 -07:00
|
|
|
eina_stringshare_del(file);
|
2012-09-05 23:30:29 -07:00
|
|
|
goto fallback;
|
|
|
|
}
|
2012-04-02 09:46:16 -07:00
|
|
|
}
|
2012-09-05 23:30:29 -07:00
|
|
|
else
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
backend = calloc(1, sizeof (Eio_Monitor_Backend));
|
|
|
|
if (!backend)
|
|
|
|
goto fallback;
|
|
|
|
|
|
|
|
backend->parent = monitor;
|
|
|
|
|
|
|
|
backend->watcher_file = _eio_monitor_win32_watcher_new(monitor, current, file, EINA_TRUE, EINA_FALSE);
|
|
|
|
if (!backend->watcher_file)
|
|
|
|
goto free_backend;
|
|
|
|
|
|
|
|
backend->watcher_dir = _eio_monitor_win32_watcher_new(monitor, current, file, EINA_FALSE, EINA_FALSE);
|
|
|
|
if (!backend->watcher_dir)
|
|
|
|
goto free_backend_file;
|
|
|
|
|
|
|
|
backend->watcher_parent = _eio_monitor_win32_watcher_new(monitor, current, file, EINA_FALSE, EINA_TRUE);
|
|
|
|
if (!backend->watcher_parent)
|
|
|
|
goto free_backend_dir;
|
2012-04-02 09:46:16 -07:00
|
|
|
|
2016-12-27 06:20:58 -08:00
|
|
|
monitor->fallback = EINA_FALSE;
|
2012-04-02 09:46:16 -07:00
|
|
|
monitor->backend = backend;
|
2012-09-05 23:30:29 -07:00
|
|
|
|
2014-05-20 02:00:14 -07:00
|
|
|
eina_stringshare_del(current);
|
|
|
|
eina_stringshare_del(file);
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
free_backend_dir:
|
|
|
|
_eio_monitor_win32_watcher_free(backend->watcher_dir);
|
|
|
|
free_backend_file:
|
|
|
|
_eio_monitor_win32_watcher_free(backend->watcher_file);
|
|
|
|
free_backend:
|
|
|
|
free(backend);
|
|
|
|
fallback:
|
|
|
|
INF("falling back to poll monitoring");
|
|
|
|
eio_monitor_fallback_add(monitor);
|
2011-04-25 10:04:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void eio_monitor_backend_del(Eio_Monitor *monitor)
|
|
|
|
{
|
2016-12-27 06:20:58 -08:00
|
|
|
if (monitor->fallback)
|
2012-04-02 09:46:16 -07:00
|
|
|
{
|
|
|
|
eio_monitor_fallback_del(monitor);
|
2013-06-20 04:28:18 -07:00
|
|
|
return;
|
2012-04-02 09:46:16 -07:00
|
|
|
}
|
|
|
|
|
2012-09-05 23:30:29 -07:00
|
|
|
_eio_monitor_win32_watcher_free(monitor->backend->watcher_parent);
|
|
|
|
_eio_monitor_win32_watcher_free(monitor->backend->watcher_dir);
|
|
|
|
_eio_monitor_win32_watcher_free(monitor->backend->watcher_file);
|
2012-04-02 09:46:16 -07:00
|
|
|
free(monitor->backend);
|
|
|
|
monitor->backend = NULL;
|
2011-04-25 10:04:46 -07:00
|
|
|
}
|
2012-03-31 00:01:24 -07:00
|
|
|
|
efl_io_model: next try to fix this race condition
what is happening is that a file gets announced through eio_model
listing code, at this point of time, the monitor does not yet know about
the file. If the file now gets deleted between the annoncing and the
learning of the file from the monitor, then the file got an ADD event,
but no DEL event. Which is a bug.
With this commit there is a new API which asks the monitor if the file
already has the knowledge about the files existance, or not. A few
monitors like win32 inotify or cocoa do not have context about the file
directly, if the OS is now having the same bug, then we are again in
trouble, however, we canot do anything about that. In the case of kevent
or poll, this asks the context of the monitor if the file is already
there.
Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10006
2019-09-18 02:32:08 -07:00
|
|
|
Eina_Bool eio_monitor_context_check(const Eio_Monitor *monitor, const char *path)
|
|
|
|
{
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-03-31 00:01:24 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @endcond
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/*============================================================================*
|
|
|
|
* API *
|
|
|
|
*============================================================================*/
|