Copyright (c) Hyperion Entertainment and contributors.
Difference between revisions of "Notification"
Steven Solie (talk | contribs) |
Steven Solie (talk | contribs) |
||
Line 12: | Line 12: | ||
Starting with version 53.x of the DOS Library (dos.library), the notification feature is handled entirely by AmigaDOS. DOS notification is independent of the file system and is always available. Prior to this version, file system notification was available only if each individual file system implemented the feature. If a file system does not support notification the notification functions described below will always fail. |
Starting with version 53.x of the DOS Library (dos.library), the notification feature is handled entirely by AmigaDOS. DOS notification is independent of the file system and is always available. Prior to this version, file system notification was available only if each individual file system implemented the feature. If a file system does not support notification the notification functions described below will always fail. |
||
+ | |||
+ | = Using Notification = |
||
+ | |||
+ | Setting up file notification on a file is easy. The StartNotify() function from dos.library starts notification on a file or directory: |
||
+ | |||
+ | <syntaxhighlight> |
||
+ | BOOL StartNotify( struct NotifyRequest *notify ); |
||
+ | </syntaxhighlight> |
||
+ | |||
+ | StartNotify() returns DOSTRUE if the call is successful, or it returns DOSFALSE (for example, when the file's file system does not support notification). This function takes a pointer to an initialized NotifyRequest structure as its only argument (as defined in |
||
+ | <dos/notify.h>): |
||
+ | |||
+ | <syntaxhighlight> |
||
+ | </syntaxhighlight> |
Revision as of 20:56, 19 March 2013
Introduction
File Notification is a form of interprocess communication. An application can ask either a file system (like the RAM disk handler RAM:, df0:, df1:...) or DOS to inform it whenever changes are made to a specific file or directory, making it easy for the application to react to such changes.
The preferences control program, IPrefs, sets up notification on most of the preferences files in ENV:Sys. If the user alters any of these files (which he/she normally does with a preferences editor), the system will notify IPrefs about the change. IPrefs will react to this notification by attempting to alter the user's environment to reflect the preference change. For example, if the user opens the ScreenMode preferences editor and alters the Workbench environment so that the Workbench screen should be a Hires NTSC screen, ScreenMode writes a file called Screenmode.prefs to the ENV:Sys directory which happens to be in RAM:. Because IPrefs has set up notification on this file, the RAM disk file system or DOS will notify IPrefs of the change, IPrefs will read in the Screenmode.prefs file and will try to reset the Workbench screen so it is in Hires NTSC mode.
Notification allows very different applications to share common data files without knowing anything about each other. This has many possible uses in the Amiga's single user, multitasking environment. One possible use for notification is in a desktop publishing (DTP) package. The user can open the DTP package to layout a group of ILBMs, some structured drawings, and word processed text. When the user loads each of these, the DTP package sets up notification on each of their corresponding files. If the user loads an appropriate editor and changes any of the files on which the DTP package has set up notification, the DTP package will receive notification of these changes and can automatically re-import these files into the current DTP document without the user having to intervene. Another possible use for notification might be in a make utility. A make program for a compiler could set up notification on a set of source code and object files. If any of those files change, the make program will recompile and link the program, without the programmer having to intervene.
File System or DOS?
Starting with version 53.x of the DOS Library (dos.library), the notification feature is handled entirely by AmigaDOS. DOS notification is independent of the file system and is always available. Prior to this version, file system notification was available only if each individual file system implemented the feature. If a file system does not support notification the notification functions described below will always fail.
Using Notification
Setting up file notification on a file is easy. The StartNotify() function from dos.library starts notification on a file or directory:
BOOL StartNotify( struct NotifyRequest *notify );
StartNotify() returns DOSTRUE if the call is successful, or it returns DOSFALSE (for example, when the file's file system does not support notification). This function takes a pointer to an initialized NotifyRequest structure as its only argument (as defined in <dos/notify.h>):