ridoslib
This library gives a program three kinds of DOS helpers. File
notification tells the program when a file or directory changes; the
device list names the devices, volumes and assigns the system knows;
GetFileName and GetPathName split a path into its two parts.
File notification and the device list need dos.library version 36 or
later (Kickstart 2.0). The library opens it itself when the program
starts, together with one message port that receives all
notifications; when the program ends, the notifications still active
are ended and the port is deleted. On Kickstart 1.x a program with
the library runs, but these commands do nothing: AddNotify,
NotifyPort, CheckNotify, WaitNotify and GetDeviceList return
0, NextDevice returns "" and DeviceEntryType -1. GetFileName
and GetPathName work on every Kickstart.
A notification is not a Blitz object but a slot of an internal table of
64 entries, numbered 0 to 63, chosen by the program with AddNotify.
When DOS reports a change, CheckNotify or WaitNotify returns the
slot number. Because 0 also means “no message”, slot 0 is best left
unused. A slot used again ends the notification that was in it.
The device list is locked with GetDeviceList; while it is locked, no
other program can change it, so FreeDeviceList should follow as soon
as the names are read:
If GetDeviceList(%1000)
Repeat
a$=NextDevice
If a$<>"" Then NPrint a$
Until a$=""
FreeDeviceList
EndIfThe fixed bugs of the library are listed in Fixes in ridoslib.
Based on the RI DOS Lib guide by Red When Excited.
Library number 33.
Commands
AddNotify
Asks DOS to report changes of a file or directory, in the slot idno (0 to 63). As a function it returns -1 if the notification was started, else 0.
Statement or function, result .l. Help text: idno,filespec$
Arguments: .l, $
The messages arrive at the port of NotifyPort and are read with
CheckNotify or WaitNotify, which return idno.
A slot in use is ended first, as with RemNotify. The result is 0
also when there is not enough memory; a notification that cannot be
started is freed at once. With runtime error checking, a slot outside
0 to 63 is the error “Notify number must be 0 to 63”.
CheckNotify
The slot number of the next notification message, or 0 if no message is waiting. It does not wait.
Function, result .l. No help text.
No arguments.
DeviceEntryType
The kind of the entry NextDevice returned last - 0 device, 1 assign (directory), 2 volume, 3 late assign, 4 non-binding assign; -1 if there is none.
Function, result .l. Help text: -- dev=0,dir=1,vol=2,late=3,nonbind=4
No arguments.
The kind is noted while the list is locked, so it stays the same
after FreeDeviceList.
FreeDeviceList
Unlocks the DOS device list locked with GetDeviceList.
Statement or function, result .l. No help text.
No arguments.
Without a locked list, the command does nothing.
GetDeviceList
Locks the DOS device list for reading with NextDevice. flags chooses the entries - %100 devices, %1000 volumes, %10000 assigns, added together for more than one kind. As a function it returns -1 on success and 0 otherwise.
Statement or function, result .l. Help text: flags
Arguments: .w
The library sets the read bit (bit 0) itself; never set bit 1, which
asks for write access. While the list is locked, no other program can
change it: call FreeDeviceList as soon as possible. A second
GetDeviceList unlocks the list before it locks it again, and the
end of the program unlocks a list that is still locked.
GetFileName
The file part of a path, everything behind the last / or :. GetFileName("Work:Test/test.txt") returns “test.txt”.
Function, result $. Help text: filepath$
Arguments: $
GetPathName
The directory part of a path, up to and including the last / or :; "" if there is none. GetPathName("Work:Test/test.txt") returns “Work:Test/”.
Function, result $. Help text: filepath$
Arguments: $
“/abc” gives “/”, and “:x” gives “:”.
NextDevice
The name of the next entry of the list locked with GetDeviceList, without a colon, or "" after the last entry.
Function, result $. No help text.
No arguments.
Without a list locked with GetDeviceList, it returns “”.
NotifyPort
The address of the message port that receives the notification messages, for example to wait for it together with other ports.
Function, result .l. No help text.
No arguments.
RemNotify
Ends the notification in a slot and frees it. An empty slot is left alone.
Statement. Help text: notify#
Arguments: .l
With runtime error checking, a slot outside 0 to 63 is the error “Notify number must be 0 to 63”.
WaitNotify
Waits for the next notification message and returns its slot number.
Function, result .l. No help text.
No arguments.
Without any active notification it waits for ever.