Skip to content

Commit c0d4914

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 eac273d commit c0d4914

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

compat/fsmonitor/fsm-health-win32.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct fsm_health_data
3434

3535
struct wt_moved
3636
{
37-
wchar_t wpath[MAX_PATH + 1];
37+
wchar_t wpath[MAX_LONG_PATH + 1];
3838
BY_HANDLE_FILE_INFORMATION bhfi;
3939
} wt_moved;
4040
};
@@ -143,8 +143,8 @@ static int has_worktree_moved(struct fsmonitor_daemon_state *state,
143143
return 0;
144144

145145
case CTX_INIT:
146-
if (xutftowcs_path(data->wt_moved.wpath,
147-
state->path_worktree_watch.buf) < 0) {
146+
if (xutftowcs_long_path(data->wt_moved.wpath,
147+
state->path_worktree_watch.buf) < 0) {
148148
error(_("could not convert to wide characters: '%s'"),
149149
state->path_worktree_watch.buf);
150150
return -1;

compat/fsmonitor/fsm-listen-win32.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct one_watch
2828
DWORD count;
2929

3030
struct strbuf path;
31-
wchar_t wpath_longname[MAX_PATH + 1];
31+
wchar_t wpath_longname[MAX_LONG_PATH + 1];
3232
DWORD wpath_longname_len;
3333

3434
HANDLE hDir;
@@ -131,8 +131,8 @@ static int normalize_path_in_utf8(wchar_t *wpath, DWORD wpath_len,
131131
*/
132132
static void check_for_shortnames(struct one_watch *watch)
133133
{
134-
wchar_t buf_in[MAX_PATH + 1];
135-
wchar_t buf_out[MAX_PATH + 1];
134+
wchar_t buf_in[MAX_LONG_PATH + 1];
135+
wchar_t buf_out[MAX_LONG_PATH + 1];
136136
wchar_t *last;
137137
wchar_t *p;
138138

@@ -197,8 +197,8 @@ static enum get_relative_result get_relative_longname(
197197
const wchar_t *wpath, DWORD wpath_len,
198198
wchar_t *wpath_longname, size_t bufsize_wpath_longname)
199199
{
200-
wchar_t buf_in[2 * MAX_PATH + 1];
201-
wchar_t buf_out[MAX_PATH + 1];
200+
wchar_t buf_in[2 * MAX_LONG_PATH + 1];
201+
wchar_t buf_out[MAX_LONG_PATH + 1];
202202
DWORD root_len;
203203
DWORD out_len;
204204

@@ -298,10 +298,10 @@ static struct one_watch *create_watch(const char *path)
298298
FILE_SHARE_WRITE | FILE_SHARE_READ | FILE_SHARE_DELETE;
299299
HANDLE hDir;
300300
DWORD len_longname;
301-
wchar_t wpath[MAX_PATH + 1];
302-
wchar_t wpath_longname[MAX_PATH + 1];
301+
wchar_t wpath[MAX_LONG_PATH + 1];
302+
wchar_t wpath_longname[MAX_LONG_PATH + 1];
303303

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

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

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ static int check_remote_protocol(wchar_t *wpath)
6969
*/
7070
int fsmonitor__get_fs_info(const char *path, struct fs_info *fs_info)
7171
{
72-
wchar_t wpath[MAX_PATH];
73-
wchar_t wfullpath[MAX_PATH];
72+
wchar_t wpath[MAX_LONG_PATH];
73+
wchar_t wfullpath[MAX_LONG_PATH];
7474
size_t wlen;
7575
UINT driveType;
7676

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

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

0 commit comments

Comments
 (0)