Skip to content

Commit a3b9c79

Browse files
committed
fsmonitor/windows: Simplify code
Stripping the prefix of \\?\-prefixed long name paths is currently not fully correct. This appears to not be a problem because the path is never compared up to the prefix anyway. Thus this prefix-stripping is not needed at all. Plus some minor simplifications.
1 parent 6e7f42d commit a3b9c79

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/fsmonitor/windows/watcher.ml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ let get_win_path root dir ((ev_path, act) as ev) =
8888
let p = if event_kind ev = `DEL then None else
8989
follow_win_path dir (Lwt_win.longpathname root ev_path) 0 in
9090
match p with
91-
| Some _ as pathnm -> (pathnm, ev)
91+
| Some _ -> (p, ev)
9292
| None ->
9393
(* If path is not found or event is a deletion then look up the
9494
parent directory and report a modification on it. It is not
@@ -110,21 +110,11 @@ let flags =
110110
let watch_root_directory path dir =
111111
let h = Lwt_win.open_directory path in
112112
let path = Lwt_win.longpathname "" path in
113-
let path =
114-
if String.sub path 0 4 = "\\\\?\\" then begin
115-
let n = String.sub path 4 (String.length path - 4) in
116-
if String.sub n 0 3 = "UNC" then
117-
"\\" ^ String.sub n 3 (String.length n - 3)
118-
else
119-
n
120-
end else
121-
path
122-
in
123113
let rec loop () =
124114
Lwt_win.readdirectorychanges h true flags >>= fun l ->
125115
let time = Unix.gettimeofday () in
126116
List.iter
127-
(fun ((ev_path, _) as ev) ->
117+
(fun ev ->
128118
if !previous_event <> Some ev then begin
129119
previous_event := Some ev;
130120
if !Watchercommon.debug then print_event ev;

0 commit comments

Comments
 (0)