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
Tools

  MODULE Public.Tools
Modules
FAM

  MODULE Public.Tools.FAM
Modules
Connection
Event
Request

Description

Example:

   object connection = Public.Tools.FAM.Connection();

   object request = connection->monitor_file("/path/to/file");
   object event = connection->next_event();

   switch (event->code()) {
     case Public.Tools.FAM.Event.Changed: 
     case Public.Tools.FAM.Event.Deleted:  
     case Public.Tools.FAM.Event.EndExists:
       update_things();
       break;
    }
 

Monitoring ends when there are no references to the request object, so keep the request object for as long as you want to monitor.

  MODULE Public.Tools.FAM.Event
Methods
code()
filename()
get_connection()
hostname()
reqnum()
Description

From the FAM Manual:

Changes to files and directories are encoded in the FAMEvent structure. The code field of this structure contains one of the following enumeration constants:

Changed Some value which can be obtained with fstat(1) changed for a file or directory being monitored.

Deleted A file or directory being monitored was deleted or its name was changed. This event is also generated when monitoring starts on a nonexistent file or directory.

StartExecuting An executable file or shared library being monitored started executing. If multiple processes execute the same file, this event only occurs when the first process starts.

StopExecuting An executable file being monitored which was running finished. If multiple processes from an executable are running, this event is only generated when the last one finishes.

Created A file was created in a directory being monitored. Note: this event is only generated for files created directly in a directory being monitored; subdirectories are not automatically monitored.

Moved FAMMoved events never occur. The name remains defined so that programs that reference it will still compile.

Acknowledge After a FAMCancelMonitor, fam generates a FAMAcknowledge event. Also, if an invalid pathname is specified, fam generates a FAMAcknowledge event.

Exists When the application requests a file be monitored, fam generates a FAMExists event for that file. When the application requests a directory be monitored, fam generates a FAMExists event for that directory and every file directly contained in that directory.

EndExist When the application requests a file directory be monitored, a series of FAMExists events is generated as described above. After the last FAMExists message, fam generates a FAMEndExist message.

If a FAM event applies to a file or directory being monitored, the FAMEvent's filename field contains the full pathname that was passed to fam. If an event applies to an entry in a monitored directory, the filename field contains the relative path only. For example, if the directory /usr/tmp/xyzzy were monitored, and the file /usr/tmp/xyzzy/plugh were deleted, a FAMDeleted event would be generated containing "plugh" in filename. If the directory itself were deleted, filename would contain "/usr/tmp/xyzzy".


Method reqnum

int Public.Tools.FAM.Event.reqnum()

Returns

Returns a number corresponding to the Request object.


Method get_connection

object(Connection) Public.Tools.FAM.Event.get_connection()

Returns

Returns the corresponding Public.Tools.Fam.Connection


Method code

int Public.Tools.FAM.Event.code()


Method hostname

string Public.Tools.FAM.Event.hostname()

Returns

Returns the corresponding hostname, or 0 if unavailable


Method filename

string Public.Tools.FAM.Event.filename()

Returns

Returns the corresponding filename, or 0 if unavailable

  MODULE Public.Tools.FAM.Request
Methods
()
get_connection()
reqnum()

Method reqnum

int Public.Tools.FAM.Request.reqnum()

Returns

Returns a number corresponding to the Request object.


Method get_connection

object(Connection) Public.Tools.FAM.Request.get_connection()

Returns

Returns the corresponding Public.Tools.Fam.Connection


Methods

void Public.Tools.FAM.Request.suspend()
void Public.Tools.FAM.Request.resume()

Description

From the FAM manual:

FAMSuspendMonitor temporarily suspends monitoring of files or directories. This is useful when an application is not displaying information about files, when it is iconified, for example. FAMResumeMonitor signals fam to start monitoring the file or directory again. Changes which occur while monitoring is suspended are enqueued and delivered when monitoring is resumed.

Because fam runs as an asynchronous process, FAMNextEvent may return a few events regarding a given request after that request has been suspended.

  MODULE Public.Tools.FAM.Connection
Methods
()
next_event()
pending()

Methods

object(Request) Public.Tools.FAM.Connection.monitor_file(string filename)
object(Request) Public.Tools.FAM.Connection.monitor_dir(string filename)

Description

From the FAM manual:

FAMMonitorDirectory and FAMMonitorFile tell FAM to start monitoring a directory or file, respectively. The parameters to this function are a FAMConnection (initialized by FAMOpen), a FAMRequest structure, a filename and a user data pointer. The FAMRequest structure is modified to subsequently identify this request. When the file or directory changes, a FAM event structure will be generated. The application can retrieve this structure by calling FAMNextEvent (see description under FAMNextEvent).

FAMMonitorDirectory monitors changes that happens to the contents of the directory (as well as the directory file itself); FAMMonitorFile monitors only what happens to a particular file. Both routines return 0 if successful and -1 otherwise.

Parameter filename

The filename argument must be a full pathname.

Returns

Returns the corresponding Public.Tools.Fam.Request


Method pending

int(0..1) Public.Tools.FAM.Connection.pending()

Description

From the FAM manual:

FAMPending returns 1 if an event is waiting and 0 if no event is waiting. It also returns 1 if an error has been encountered. This routine returns immediately to the caller.


Method next_event

object(Event) Public.Tools.FAM.Connection.next_event()

Description

FAMNextEvent will get the next FAM event. If there are no FAM events waiting, then the calling application blocks until a FAM event is received. If blocking is not desirable, call FAMPending before FAMNextEvent, and only call FAMNextEvent when FAMPending says an event is available.

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