remove deprecated inotify-event struct

db4
Doug Coleman 2009-09-08 14:15:25 -05:00
parent 942fb7b048
commit eb558fcc9c
2 changed files with 18 additions and 19 deletions

View File

@ -5,7 +5,7 @@ io.files io.pathnames io.buffers io.ports io.timeouts
io.backend.unix io.encodings.utf8 unix.linux.inotify assocs
namespaces make threads continuations init math math.bitwise
sets alien alien.strings alien.c-types vocabs.loader accessors
system hashtables destructors unix ;
system hashtables destructors unix classes.struct ;
IN: io.monitors.linux
SYMBOL: watches
@ -82,30 +82,30 @@ M: linux-monitor dispose* ( monitor -- )
] { } make prune ;
: parse-event-name ( event -- name )
dup inotify-event-len zero?
[ drop "" ] [ inotify-event-name utf8 alien>string ] if ;
dup len>> zero?
[ drop "" ] [ name>> utf8 alien>string ] if ;
: parse-file-notify ( buffer -- path changed )
dup inotify-event-mask ignore-flags? [
dup mask>> ignore-flags? [
drop f f
] [
[ parse-event-name ] [ inotify-event-mask parse-action ] bi
[ parse-event-name ] [ mask>> parse-action ] bi
] if ;
: events-exhausted? ( i buffer -- ? )
fill>> >= ;
: inotify-event@ ( i buffer -- alien )
ptr>> <displaced-alien> ;
: inotify-event@ ( i buffer -- inotify-event )
ptr>> <displaced-alien> inotify-event memory>struct ;
: next-event ( i buffer -- i buffer )
2dup inotify-event@
inotify-event-len "inotify-event" heap-size +
len>> inotify-event heap-size +
swap [ + ] dip ;
: parse-file-notifications ( i buffer -- )
2dup events-exhausted? [ 2drop ] [
2dup inotify-event@ dup inotify-event-wd wd>monitor
2dup inotify-event@ dup wd>> wd>monitor
[ parse-file-notify ] dip queue-change
next-event parse-file-notifications
] if ;

View File

@ -1,15 +1,14 @@
! Copyright (C) 2008 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: alien.syntax math math.bitwise ;
USING: alien.syntax math math.bitwise classes.struct ;
IN: unix.linux.inotify
C-STRUCT: inotify-event
{ "int" "wd" } ! watch descriptor
{ "uint" "mask" } ! watch mask
{ "uint" "cookie" } ! cookie to synchronize two events
{ "uint" "len" } ! length (including nulls) of name
{ "char[0]" "name" } ! stub for possible name
;
STRUCT: inotify-event
{ wd int }
{ mask uint }
{ cookie uint }
{ len uint }
{ name char[0] } ;
CONSTANT: IN_ACCESS HEX: 1 ! File was accessed
CONSTANT: IN_MODIFY HEX: 2 ! File was modified
@ -28,8 +27,8 @@ CONSTANT: IN_UNMOUNT HEX: 2000 ! Backing fs was unmounted
CONSTANT: IN_Q_OVERFLOW HEX: 4000 ! Event queued overflowed
CONSTANT: IN_IGNORED HEX: 8000 ! File was ignored
: IN_CLOSE ( -- n ) IN_CLOSE_WRITE IN_CLOSE_NOWRITE bitor ; inline ! close
: IN_MOVE ( -- n ) IN_MOVED_FROM IN_MOVED_TO bitor ; inline ! moves
: IN_CLOSE ( -- n ) { IN_CLOSE_WRITE IN_CLOSE_NOWRITE } flags ; foldable ! close
: IN_MOVE ( -- n ) { IN_MOVED_FROM IN_MOVED_TO } flags ; foldable ! moves
CONSTANT: IN_ONLYDIR HEX: 1000000 ! only watch the path if it is a directory
CONSTANT: IN_DONT_FOLLOW HEX: 2000000 ! don't follow a sym link