Skip to content

Commit 6fb0cf8

Browse files
jeffhostetlerdscho
authored andcommitted
compat/fsmonitor/fsm-*-win32: support long paths
Update wchar_t buffers to use MAX_LONG_PATH instead of MAX_PATH and call xutftowcs_long_path() in the Win32 backend source files. Signed-off-by: Jeff Hostetler <[email protected]>
1 parent 17bef7f commit 6fb0cf8

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

compat/fsmonitor/fsm-health-win32.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct fsm_health_data
3232

3333
struct wt_moved
3434
{
35-
wchar_t wpath[MAX_PATH + 1];
35+
wchar_t wpath[MAX_LONG_PATH + 1];
3636
BY_HANDLE_FILE_INFORMATION bhfi;
3737
} wt_moved;
3838
};
@@ -141,8 +141,8 @@ static int has_worktree_moved(struct fsmonitor_daemon_state *state,
141141
return 0;
142142

143143
case CTX_INIT:
144-
if (xutftowcs_path(data->wt_moved.wpath,
145-
state->path_worktree_watch.buf) < 0) {
144+
if (xutftowcs_long_path(data->wt_moved.wpath,
145+
state->path_worktree_watch.buf) < 0) {
146146
error(_("could not convert to wide characters: '%s'"),
147147
state->path_worktree_watch.buf);
148148
return -1;

compat/fsmonitor/fsm-listen-win32.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct one_watch
2525
DWORD count;
2626

2727
struct strbuf path;
28-
wchar_t wpath_longname[MAX_PATH + 1];
28+
wchar_t wpath_longname[MAX_LONG_PATH + 1];
2929
DWORD wpath_longname_len;
3030

3131
HANDLE hDir;
@@ -128,8 +128,8 @@ static int normalize_path_in_utf8(wchar_t *wpath, DWORD wpath_len,
128128
*/
129129
static void check_for_shortnames(struct one_watch *watch)
130130
{
131-
wchar_t buf_in[MAX_PATH + 1];
132-
wchar_t buf_out[MAX_PATH + 1];
131+
wchar_t buf_in[MAX_LONG_PATH + 1];
132+
wchar_t buf_out[MAX_LONG_PATH + 1];
133133
wchar_t *last;
134134
wchar_t *p;
135135

@@ -194,8 +194,8 @@ static enum get_relative_result get_relative_longname(
194194
const wchar_t *wpath, DWORD wpath_len,
195195
wchar_t *wpath_longname, size_t bufsize_wpath_longname)
196196
{
197-
wchar_t buf_in[2 * MAX_PATH + 1];
198-
wchar_t buf_out[MAX_PATH + 1];
197+
wchar_t buf_in[2 * MAX_LONG_PATH + 1];
198+
wchar_t buf_out[MAX_LONG_PATH + 1];
199199
DWORD root_len;
200200
DWORD out_len;
201201

@@ -296,10 +296,10 @@ static struct one_watch *create_watch(struct fsmonitor_daemon_state *state,
296296
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
297297
HANDLE hDir;
298298
DWORD len_longname;
299-
wchar_t wpath[MAX_PATH + 1];
300-
wchar_t wpath_longname[MAX_PATH + 1];
299+
wchar_t wpath[MAX_LONG_PATH + 1];
300+
wchar_t wpath_longname[MAX_LONG_PATH + 1];
301301

302-
if (xutftowcs_path(wpath, path) < 0) {
302+
if (xutftowcs_long_path(wpath, path) < 0) {
303303
error(_("could not convert to wide characters: '%s'"), path);
304304
return NULL;
305305
}
@@ -544,7 +544,7 @@ static int process_worktree_events(struct fsmonitor_daemon_state *state)
544544
struct string_list cookie_list = STRING_LIST_INIT_DUP;
545545
struct fsmonitor_batch *batch = NULL;
546546
const char *p = watch->buffer;
547-
wchar_t wpath_longname[MAX_PATH + 1];
547+
wchar_t wpath_longname[MAX_LONG_PATH + 1];
548548

549549
/*
550550
* If the kernel gets more events than will fit in the kernel

compat/fsmonitor/fsm-path-utils-win32.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,16 @@ static int check_remote_protocol(wchar_t *wpath)
6767
*/
6868
int fsmonitor__get_fs_info(const char *path, struct fs_info *fs_info)
6969
{
70-
wchar_t wpath[MAX_PATH];
71-
wchar_t wfullpath[MAX_PATH];
70+
wchar_t wpath[MAX_LONG_PATH];
71+
wchar_t wfullpath[MAX_LONG_PATH];
7272
size_t wlen;
7373
UINT driveType;
7474

7575
/*
7676
* Do everything in wide chars because the drive letter might be
7777
* a multi-byte sequence. See win32_has_dos_drive_prefix().
7878
*/
79-
if (xutftowcs_path(wpath, path) < 0) {
79+
if (xutftowcs_long_path(wpath, path) < 0) {
8080
return -1;
8181
}
8282

@@ -95,7 +95,7 @@ int fsmonitor__get_fs_info(const char *path, struct fs_info *fs_info)
9595
* slashes to backslashes. This is essential to get GetDriveTypeW()
9696
* correctly handle some UNC "\\server\share\..." paths.
9797
*/
98-
if (!GetFullPathNameW(wpath, MAX_PATH, wfullpath, NULL)) {
98+
if (!GetFullPathNameW(wpath, MAX_LONG_PATH, wfullpath, NULL)) {
9999
return -1;
100100
}
101101

0 commit comments

Comments
 (0)