vfsOpen

function

Library: File system utilities (OMVFS legacy)
Include: omvfs.xin

Returns: a vfsFile object for the opened file


Declaration
define external vfsFile function vfsOpen 
       value  stream   file-path
  for  value  integer  access-type  optional

or

define external vfsFile function vfsOpen 
       value  stream   absolute-URL
  for  value  integer  access-type  optional

or

define external vfsFile function vfsOpen 
       value  stream   relative-URL
   on  value  vfsDir   dir
  for  value  integer  access-type  optional

Argument definitions

file-path
is the file to be opened expressed in local file system format.
absolute-URL
is the file to be opened expressed as an absolute URL.
relative-URL
is the file to be opened expressed as a relative URL using the specified vfsDir object as its base.
dir
is a vfsDir object created by connecting to a network resource using either vfsConnect or vfsConnectDir.
access-type
is the desired mode of access. The default value is VFS-READ.


Purpose

Use vfsOpen to open a file. A vfsFile OMX component is returned.

Requirements

You must include the following line at the beginning of your OmniMark program:

  include "omvfs.xin"

file-path must be expressed in local file system format, either as an absolute path, or relative to the current working directory.

absolute-URL must be expressed as an absolute URL.

relative-URL must be expressed as a relative URL based on the current working directory for the vfsDir object dir (else external exception VFS105).

The vfsDir object dir must:

access-type is an optional parameter which defaults to VFS-READ. If it is supplied, it must have one of the following values:

Specifying any other value for access-type will cause an exception to be thrown (external exception VFS201).

If the access-type is VFS-READ, the file must exist (else external exception VFS306).

Usage Notes

If an existing file is opened with an access-type of VFS-WRITE, then its contents are deleted.

External exception VFS300 is thrown for any general OS operation failure. The text accompanying the exception will contain details on the reason for the failure.

External exception VFS111 is thrown if an URL supplied as a parameter to this function contains invalid encoding.

External exception VFS004 is thrown if the URL exceeds system length limits.

For complete details on absolute URLs and valid encoding, see Internet Standards RFC 1738: Uniform Resource Locators.

For complete details on relative URLs, see Internet Standards RFC 1808: Relative Uniform Resource Locators.

Example

Opening a file in a subdirectory of the current directory with read-only access.

  include "omvfs.xin"
  
  process
    local vfsFile myFile
    	. . .
    set myFile to vfsOpen "programs/myscript.xom" 
    	for VFS-READ