vfs.file

data type

Library: File system utilities (OMVFS)
Import : omvfs.xmd


Purpose

The vfs.file data type represents an individual file.

Related OMVFS library functions:

The functions

are used to open and close files. vfs.file objects are used by the following OMVFS library functions:

Example

This example shows vfs.file being used to obtain the properties and contents of a file.

  import "omvfs.xmd" prefixed by vfs.
  
  process
    local vfs.directory directory-handle
    local vfs.file      file-handle
    local stream        properties variable
  
    set directory-handle to vfs.connect "file:///omprogs/"
    set file-handle      to vfs.open "jean-sibelius.txt" on directory-handle for vfs.read-mode 
  
    vfs.describe-file file-handle into properties
    output "    Name:   " || properties{"name"} || "%n"
    output "    Size:   " || properties{"size"} || " bytes%n"
    do when properties{"isdir"} = 0
      output "    Type:   file" || "%n"
  
    else
      output "    Type:   directory" || "%n"
    done
  
    output "Contents:  " || vfs.reader of file-handle || "%n"

Depending on the state and contents of the file system, this program might produce output such as:

  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

Usage Notes

To use the vfs.file data type in your program, you must import OMVFS into your program using an import declaration such as:

  import "omvfs.xmd" prefixed by vfs.