![]() |
|
||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() |
|||||
vfs.file
|
||
The VFS file OMX component represents an individual file.
The OmniMark Virtual File System dynamic link library file ("omvfs.dll") creates the VFS file OMX component. The related module file ("omvfs.xmd") defines the interface to that component. To use VFS file OMX components in your program, you must import it into your program using a statement like this:
import "omvfs.xmd" prefixed by vfs.
(Please see the import topic
for more on importing.)
Please refer to OMX Components for a general description of OMX components and how they are used.
The functions
are used to open and close files. VFS file objects are used by the following OMVFS library functions:vfs.cursor-position - get the current position of the cursor in a VFS file object.
vfs.describe-file - return a set of attributes describing a file.
vfs.file-directory - get the directory location of the file.
vfs.file-name - get the file name of a VFS file object.
vfs.lock - lock an entire VFS file object or a specific area of it.
vfs.move-cursor - change the cursor position from the current location in a file's contents to the position you specify.
vfs.reader - read the contents of a VFS file and return them in an OmniMark source.
vfs.truncate - truncate a file at a specified byte.
vfs.unlock - unlock a single locked section or an entire file.
vfs.writer - obtain an output object (write) to an open file.
import "omvfs.xmd" prefixed by vfs.
process
local vfs.file myFile
local vfs.directory myDir
local stream attributes-shelf variable
set myDir to vfs.connect "file:///omprogs/"
set myFile to vfs.open "jean-sibelius.txt" on myDir for vfs.read-mode
vfs.describe-file myFile into attributes-shelf
output " Name: " || attributes-shelf{"name"} || "%n"
output " Size: " || attributes-shelf{"size"} || " bytes%n"
do when attributes-shelf{"isdir"} = 0
output " Type: file" || "%n"
else
output " Type: directory" || "%n"
done
output "Contents: " || vfs.reader on myFile || "%n"
This program produces the following output:
Name: file:///omprogs/jean-sibelius.txt
Size: 115 bytes
Type: file
Contents: "Pay no attention to what the critics say; no statue has ever been erected to a critic."
-- Jean Sibelius