Home modules.gotpike.org
Username: Password: [Create Account]
[Forgot Password?]

Modules

ADT
Database
GTK2
GUI
IP
PiJAX
Public
Sql
Stdio
Subversion
System
Tools
Xosd
lua
v4l2
wx

Recent Changes

Public.Parser.XML2 1.50
Public.ZeroMQ 1.1
Public.Template.Mustache 1.0
Public.Protocols.XMPP 1.4
Sql.Provider.jdbc 1.0

Popular Downloads

Public.Parser.JSON2 1.0
Public.Parser.JSON 0.2
GTK2 2.23
Public.Web.FCGI 1.8
Public.Parser.XML2 1.48


Pike Module Reference:

module version 0.1, prepared

  MODULE Public
Modules
System

  MODULE Public.System
Modules
Inotify

  MODULE Public.System.Inotify
Classes
Instance
_Instance

Methods
parse_event()

Constants

constant Public.System.Inotify.IN_ACCESS
constant Public.System.Inotify.IN_ATTRIB
constant Public.System.Inotify.IN_CLOSE_WRITE
constant Public.System.Inotify.IN_CLOSE_NOWRITE
constant Public.System.Inotify.IN_CREATE
constant Public.System.Inotify.IN_DELETE
constant Public.System.Inotify.IN_DELETE_SELF
constant Public.System.Inotify.IN_MODIFY
constant Public.System.Inotify.IN_MOVE_SELF
constant Public.System.Inotify.IN_MOVED_FROM
constant Public.System.Inotify.IN_MODED_TO
constant Public.System.Inotify.IN_OPEN
constant Public.System.Inotify.IN_MOVE
constant Public.System.Inotify.IN_CLOSE
constant Public.System.Inotify.IN_DONT_FOLLOW
constant Public.System.Inotify.IN_MASK_ADD
constant Public.System.Inotify.IN_ONESHOT
constant Public.System.Inotify.IN_ONLYDIR
constant Public.System.Inotify.IN_IGNORED
constant Public.System.Inotify.IN_ISDIR
constant Public.System.Inotify.IN_Q_OVERFLOW
constant Public.System.Inotify.IN_UNMOUNT

Description

Please have a look at the inotify(7) manpage for information about these constants.

Note

Some constants may not be available when the module has been compiled on a machine with an old kernel (before 2.6.15). See the manpage for more details.


Method parse_event

array Public.System.Inotify.parse_event(string data)

Description

Parses one inotify_event struct from data.

Returns

Returns an array consisting of

The watch descriptor returned by add_watch() when the watch for this file was added.

An integer that describes the event that occured. See the inotify manpage for a list of possible events and their numerical identifiers.

An integer cookie that can be used to group together different events that were triggered by moving a file from one location to another.

The name of the file. This will only be present if the event happened to a file in a directory that was watched, e.g. with Public.System.Inotify.IN_CREATE. Otherwise this will be 0.

The length of the data that has been parsed. In case a string contains more than one inotify events, this parse function has to be called again with the rest as an argument.

  CLASS Public.System.Inotify.Instance
Methods
add_watch()
rm_watch()
Description

More convenient interface to inotify(7). Automatically reads events from the inotify file descriptor and parses them.


Method add_watch

int Public.System.Inotify.Instance()->add_watch(string filename, int mask, function callback, mixed ... extra)

Description

Add a watch for a certain file and a set of events specified by mask. The function callback will be called when such an event occurs. The arguments to the callback will be the events mask, the cookie, the filename and extra.

Returns

Returns a watch descriptor which can be used to remove the watch.

Note

When adding a second watch for the same file the old one will be removed unless Public.System.Inotify.IN_MASK_ADD is contained in mask.

Note

The mask of an event may be a subset of the mask given when adding the watch.

Note

In case the watch is added for a regular file, the filename will be passed to the callback. In case the watch is added for a directory, the name of the file to which the event happened inside the directory will be concatenated.


Method rm_watch

void Public.System.Inotify.Instance()->rm_watch(int wd)

Description

Remove the watch associated with the watch descriptor wd.

  CLASS Public.System.Inotify._Instance
Methods
add_watch()
get_fd()
rm_watch()
Description

Simple wrapper class that gives direct access to the inotify(7) interface. On create an inotify instance is initiated by calling inotify_init(2). Every object of this class has its own inotify file descriptor. Use this class only if you want direct access to the file descriptor to read from it manually. For a more user-friendly inferface use Public.System.Inotify.Instance.


Method add_watch

int Public.System.Inotify._Instance()->add_watch(string file, int mask)

Description

Add a watch for a certain file/dir and certain events. Adding more than one watch for a file will overwrite the previous watch unless Public.System.Inotify.IN_MASK_ADD is ORed to the mask.

Parameter file

Name of the file that should be watched. Can be either a directory or a file.

Parameter mask

Integer mask specifying the event. This can be a combination of different event types combined using bitwise OR. See the inotify manpage for possible values and their description. The values defined by the inotify header file are exported by Public.System.Inotify as constants using the same names (e.g. Public.System.Inotify.IN_CREATE).

Note

Subdirectories are not watched. If you want to watch subdirectories aswell, its necessary to add watches for them individually.


Method get_fd

int Public.System.Inotify._Instance()->get_fd()

Returns

Returns the file descriptor that is associated to the inotify instance.


Method rm_watch

int Public.System.Inotify._Instance()->rm_watch(int wd)

Description

Remove a watch.

Parameter wd

The watch descriptor that was returned by add_watch().

gotpike.org | Copyright © 2004 - 2019 | Pike is a trademark of Department of Computer and Information Science, Linköping University