Skip to content

Commit 6f50cde

Browse files
committed
fixup! fsmonitor-fs-listen-win32: implement FSMonitor backend on Windows
Let's keep avoiding the `*A()` family of Win32 API functions because they are susceptible to incoherent encoding problems. In Git for Windows, we always assume paths to be UTF-8 encoded. Let's use the dedicated helper to convert such a path to the wide character version, and then use the `*W()` function instead. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent f1590a7 commit 6f50cde

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

compat/fsmonitor/fsmonitor-fs-listen-win32.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,14 @@ static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
111111
DWORD share_mode =
112112
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
113113
HANDLE hDir;
114+
wchar_t wpath[MAX_PATH];
114115

115-
hDir = CreateFileA(path,
116+
if (xutftowcs_long_path(wpath, path) < 0) {
117+
error(_("could not convert to wide characters: '%s'"), path);
118+
return NULL;
119+
}
120+
121+
hDir = CreateFileW(wpath,
116122
desired_access, share_mode, NULL, OPEN_EXISTING,
117123
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OVERLAPPED,
118124
NULL);

0 commit comments

Comments
 (0)