DIR-VIEW

Creates a special Reality file that provides access to a host directory. The files in the directory appear as items in the Reality file and, unless defined as a binary view, each new line of text in a text file appears as an attribute (line) within the associated item (on read, newline characters are converted to attribute marks and on write, attribute marks are converted to newline characters).

Syntax

DIR-VIEW file-name directory {(options}

Syntax elements

file-name The name of the directory view file. The format of a valid file name is described in Rules for File and Data Section Names.

directory The absolute path of the host directory to be associated with the Reality file.

Notes:

  • You can also use a relative path, but this is not recommended because the directory location will depend on the way in which you have logged onto the database.
  • If the host file system is case-sensitive, this parameter must be specified in the correct case.
  • If the TCLDELIMITER environment option is set, you cannot use backslashes in DIR-VIEW directory paths entered at the TCL command prompt; either enclose the path in quotes or use forward slashes (/) instead.

Options

B Binary view. All files within the host directory are written to and read as binary items - no NEWLINE/Attribute Mark translations are performed.

E On Windows systems, generate UNIX-style line endings (single LF).

F Binary view on read. All files within the host directory are read as binary items - no NEWLINE/Attribute Mark translations are performed. However, items are written as ASCII (with Attribute marks converted to newline characters) or binary depending on whether the data in memory is considered by Reality to be binary data.

O Overwrite any existing DIR-VIEW file.

R Read only. The host directory cannot be modified from Reality.

U Creates a file with case-sensitive item-ids.

W Creates a file with case-insensitive item-ids. Only valid if the database is enabled for item-id case-insensitivity.

Restrictions

You can only use the DIR-VIEW command if Directory View is enabled in your security profile.

Access to a directory view file is also subject to the access permissions of the referenced host directory and files. Attempting to access the directory view of a directory to which you do not have access permissions will display an error message. If you do not have read access to particular files in the host directory, those files will not be visible in the directory view.

Note

When using DIR-VIEW on Windows, you must ensure that the Reality Users group has permission to access the directory concerned and all directories in the path of this directory. For example, if you are setting up a directory view of the directory C:\user1\accounts, the Reality Users group must have access to drive C: and to the directories C:\user1 and C:\user1\accounts.

Because the maximum size of a Reality item is 2 Gb, host files larger than this will be visible but will not be readable. DataBasic's OPENSEQ statement can be used to process large files by opening them directly.

Special files such as sub-directories, pipes and devices are not visible in the Reality file.

Directory view should be used with care when accessing binary data (such as graphics). Unless the directory view file is defined as binary, data read from a binary file may be corrupted.

Directory view files do not take part in transactions or Transaction Logging.

The names of items you create in a directory view file must be valid file names on the host operating system.

Comments

The directory view file is virtually indistinguishable from an ordinary Reality database file, enabling the referenced host directory to be accessed and manipulated by a database user using standard TCL commands and other processors, such as English, DataBasic and Proc.

More than one directory view file can be created for the same host directory. Any operation in one (such as deleting an item) will affect all directory view files associated with that host directory.

A directory view file can be used to transfer data between the host and Reality environments.

DIR-VIEW will create a directory view file even if the specified directory does not exist in the host file system. However, any attempt to view such a directory will return the error message:

'directory' IS NOT A FILE NAME

Case sensitivity

The U and W options can be used to override the default item-id case setting (set with the INSENS.CREATE.FILE environment option). See Case Sensitivity for more details.

If both U and W are specified an error message is displayed and the directory view is not created.

The operation of a case-insensitive directory view depends on whether the host file system is case-sensitive or insensitive:

Case-sensitive host (for example, UNIX).
All item-ids are converted to lower case. Only host files with lower case names are accessible.

Case-insensitive host (for example, Windows).
All items are accessible, regardless of case.

Example

On a UNIX system, create the directory /user1/accounts, or on a Windows system, create the directory C:\user1\accounts. Next, create two sub-directories vat and log, and three files invoice109, invoice110 and invoice111.

Now, at TCL enter:

DIR-VIEW ACCOUNTS /user1/accounts (on UNIX)

or

DIR-VIEW ACCOUNTS C:\user1\accounts (on Windows)

as appropriate.

The following message is returned:

[417] FILE 'ACCOUNTS' CREATED.
D/CODE =DY, DIRECTORY = /user1/accounts

This creates the directory view file ACCOUNTS for the host directory /user/accounts or C:\user1\accounts, as appropriate.

Now use the LIST command to list items in the directory view file ACCOUNTS. Enter:

LIST ACCOUNTS

The following list is displayed:

ACCOUNTS...
invoice109
invoice110
invoice111

Note that the directory view file contains an item for each of the three invoice text files in the accounts directory, but not for the sub-directories log and vat.

Now enter:

CT ACCOUNTS invoice109

This displays the contents of the host file invoice109 in Reality item format.

You can transfer data between the host environment and a Reality database using the COPY TCL command; for example:

COPY BP DBPROG
TO: (ACCOUNTS

exports the DataBasic program DBPROG into a file in /user1/accounts.

Conversely,

COPY ACCOUNTS invoice109
TO: (INVOICES

imports the file invoice109 into database as an item in the file INVOICES.