From d645b2e17ccc63d5b2a80c945f726c68e9364ecb Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 1 Nov 2015 19:58:05 -0800 Subject: [PATCH] io.monitors.windows: Strip the :Zone.Identifier from pathnames reported by the file change api. --- basis/io/monitors/windows/windows.factor | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/basis/io/monitors/windows/windows.factor b/basis/io/monitors/windows/windows.factor index b4292b99d8..9419570902 100644 --- a/basis/io/monitors/windows/windows.factor +++ b/basis/io/monitors/windows/windows.factor @@ -54,9 +54,15 @@ TUPLE: win32-monitor < monitor port ; : memory>u16-string ( alien len -- string ) memory>byte-array utf16n decode ; +! Files on an NTFS downloaded from the internet may contain an +! ADS (alternate data stream) such as foo.txt:Zone.Identifier +! which the win32 API reports as the filename. We wish to strip this off +! and instead work on the actual file contents instead of ADS data. : parse-notify-record ( buffer -- path changed ) - [ [ FileName>> ] [ FileNameLength>> ] bi memory>u16-string ] - [ Action>> parse-action ] bi ; + [ + [ FileName>> ] [ FileNameLength>> ] bi + memory>u16-string ":Zone.Identifier" ?tail drop + ] [ Action>> parse-action ] bi ; : (file-notify-records) ( buffer -- buffer ) FILE_NOTIFY_INFORMATION memory>struct