]> gitweb.factorcode.org Git - factor.git/commitdiff
io.monitors.windows: Strip the :Zone.Identifier from pathnames reported
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 2 Nov 2015 03:58:05 +0000 (19:58 -0800)
committerDoug Coleman <doug.coleman@gmail.com>
Mon, 2 Nov 2015 03:58:05 +0000 (19:58 -0800)
by the file change api.

basis/io/monitors/windows/windows.factor

index b4292b99d8905b768bb10ef169ff5cbb83db351b..9419570902bd709515439619a58001b95cd0e712 100644 (file)
@@ -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