io.monitors.windows: Strip the :Zone.Identifier from pathnames reported

by the file change api.
db4
Doug Coleman 2015-11-01 19:58:05 -08:00
parent 26e5c1aecf
commit d645b2e17c
1 changed files with 8 additions and 2 deletions

View File

@ -54,9 +54,15 @@ TUPLE: win32-monitor < monitor port ;
: memory>u16-string ( alien len -- string ) : memory>u16-string ( alien len -- string )
memory>byte-array utf16n decode ; 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 ) : 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-records) ( buffer -- buffer )
FILE_NOTIFY_INFORMATION memory>struct FILE_NOTIFY_INFORMATION memory>struct