mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-11-22 18:29:03 +01:00
Issue #3819: G_FILE_MONITOR_WATCH_HARD_LINK does not monitor files on Windows.
Current code was clearly considering the case of having only a filename as a directory monitoring, instead of a hard-link monitoring. As I assume that hard links don't exist on Windows, this case should simply revert back to the basic file monitoring code path.
This commit is contained in:
@@ -245,9 +245,9 @@ g_win32_fs_monitor_init (GWin32FSMonitorPrivate *monitor,
|
|||||||
const gchar *filename,
|
const gchar *filename,
|
||||||
gboolean isfile)
|
gboolean isfile)
|
||||||
{
|
{
|
||||||
wchar_t *wdirname_with_long_prefix = NULL;
|
gchar *dirname_with_long_prefix;
|
||||||
|
wchar_t *wdirname_with_long_prefix;
|
||||||
const gchar LONGPFX[] = "\\\\?\\";
|
const gchar LONGPFX[] = "\\\\?\\";
|
||||||
gchar *fullpath_with_long_prefix, *dirname_with_long_prefix;
|
|
||||||
DWORD notify_filter = isfile ?
|
DWORD notify_filter = isfile ?
|
||||||
(FILE_NOTIFY_CHANGE_FILE_NAME |
|
(FILE_NOTIFY_CHANGE_FILE_NAME |
|
||||||
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
FILE_NOTIFY_CHANGE_ATTRIBUTES |
|
||||||
@@ -260,20 +260,33 @@ g_win32_fs_monitor_init (GWin32FSMonitorPrivate *monitor,
|
|||||||
gboolean success_attribs;
|
gboolean success_attribs;
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attrib_data = {0, };
|
WIN32_FILE_ATTRIBUTE_DATA attrib_data = {0, };
|
||||||
|
|
||||||
|
g_return_if_fail ((filename && isfile) || (dirname && ! isfile));
|
||||||
|
|
||||||
if (dirname != NULL)
|
if (dirname != NULL)
|
||||||
{
|
{
|
||||||
dirname_with_long_prefix = g_strconcat (LONGPFX, dirname, NULL);
|
dirname_with_long_prefix = g_strconcat (LONGPFX, dirname, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gchar *tmp_dirname = g_path_get_dirname (filename);
|
||||||
|
dirname_with_long_prefix = g_strconcat (LONGPFX, tmp_dirname, NULL);
|
||||||
|
g_free (tmp_dirname);
|
||||||
|
}
|
||||||
wdirname_with_long_prefix = g_utf8_to_utf16 (dirname_with_long_prefix, -1, NULL, NULL, NULL);
|
wdirname_with_long_prefix = g_utf8_to_utf16 (dirname_with_long_prefix, -1, NULL, NULL, NULL);
|
||||||
|
|
||||||
if (isfile)
|
if (isfile)
|
||||||
{
|
{
|
||||||
gchar *fullpath;
|
gchar *fullpath;
|
||||||
|
gchar *fullpath_with_long_prefix;
|
||||||
wchar_t wlongname[MAX_PATH_LONG];
|
wchar_t wlongname[MAX_PATH_LONG];
|
||||||
wchar_t wshortname[MAX_PATH_LONG];
|
wchar_t wshortname[MAX_PATH_LONG];
|
||||||
wchar_t *wfullpath, *wbasename_long, *wbasename_short;
|
wchar_t *wfullpath, *wbasename_long, *wbasename_short;
|
||||||
|
|
||||||
|
if (dirname)
|
||||||
fullpath = g_build_filename (dirname, filename, NULL);
|
fullpath = g_build_filename (dirname, filename, NULL);
|
||||||
|
else
|
||||||
|
fullpath = g_strdup (filename);
|
||||||
|
|
||||||
fullpath_with_long_prefix = g_strconcat (LONGPFX, fullpath, NULL);
|
fullpath_with_long_prefix = g_strconcat (LONGPFX, fullpath, NULL);
|
||||||
|
|
||||||
wfullpath = g_utf8_to_utf16 (fullpath, -1, NULL, NULL, NULL);
|
wfullpath = g_utf8_to_utf16 (fullpath, -1, NULL, NULL, NULL);
|
||||||
@@ -318,6 +331,7 @@ g_win32_fs_monitor_init (GWin32FSMonitorPrivate *monitor,
|
|||||||
|
|
||||||
g_free (wfullpath);
|
g_free (wfullpath);
|
||||||
g_free (fullpath);
|
g_free (fullpath);
|
||||||
|
g_free (fullpath_with_long_prefix);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -327,15 +341,6 @@ g_win32_fs_monitor_init (GWin32FSMonitorPrivate *monitor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
monitor->isfile = isfile;
|
monitor->isfile = isfile;
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dirname_with_long_prefix = g_strconcat (LONGPFX, filename, NULL);
|
|
||||||
monitor->wfullpath_with_long_prefix = g_utf8_to_utf16 (dirname_with_long_prefix, -1, NULL, NULL, NULL);
|
|
||||||
monitor->wfilename_long = NULL;
|
|
||||||
monitor->wfilename_short = NULL;
|
|
||||||
monitor->isfile = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
success_attribs = GetFileAttributesExW (monitor->wfullpath_with_long_prefix,
|
success_attribs = GetFileAttributesExW (monitor->wfullpath_with_long_prefix,
|
||||||
GetFileExInfoStandard,
|
GetFileExInfoStandard,
|
||||||
@@ -345,7 +350,7 @@ g_win32_fs_monitor_init (GWin32FSMonitorPrivate *monitor,
|
|||||||
else
|
else
|
||||||
monitor->file_attribs = INVALID_FILE_ATTRIBUTES;
|
monitor->file_attribs = INVALID_FILE_ATTRIBUTES;
|
||||||
monitor->pfni_prev = NULL;
|
monitor->pfni_prev = NULL;
|
||||||
monitor->hDirectory = CreateFileW (wdirname_with_long_prefix != NULL ? wdirname_with_long_prefix : monitor->wfullpath_with_long_prefix,
|
monitor->hDirectory = CreateFileW (wdirname_with_long_prefix,
|
||||||
FILE_LIST_DIRECTORY,
|
FILE_LIST_DIRECTORY,
|
||||||
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
NULL,
|
NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user