guides:programming:programmers_reference_manual:rti_os_directory

RTI_OS_Directory function

This function provides methods for manipulating operating system directories. NOTE: This function should not be used in OpenInsight 10.x and above; instead, please use the replacement RTI_OS_DIR function.

retVal = RTI_OS_Directory( method, directory, <param1>, <param2>, <param3> )

The function has the following parameters:

ParameterDescription
methodA command to be executed against a directory.

Method - Description
Create - Creates a new directory.
Delete - Deletes a directory and all the directory's content, including all subdirectories.
Rename - Renames a directory.
Exists - Determines if a directory exists.
Choose - Displays the choose directory dialog and returns the selected result.
GetSubDirectories - Returns a list of all the subdirectories within a directory.
GetLogicalDrives -Retrieves a list of the logical drives attached to the current machine.
GetWindowsDirectory - Returns the path to where Windows is installed.
GetMyDocuments - Returns the path to the "My Documents" directory.
GetDesktopDirectory - Returns the path to the Windows Desktop.
GetWindowsTempPath - Returns the path to the Windows temp directory.
GetOIDirectory - Returns the path to where OpenInsight is installed.
GetFiles - Retrieves file names from a specified directory.
GetAttributes - Returns the requested attributes of a file.
directoryThe directory to be acted upon. The path may be a mapped drive or a UNC path.
param1<Optional>Method dependent parameter.
param2<Optional>Method dependent parameter.
param3<Optional>Method dependent parameter.

Method dependent return value. All boolean return values are TRUE if successful and FALSE is unsuccessful.

When returning directories, the program does NOT append a trailing backslash (\).

Create Method

Description

Creates a new directory.

Syntax

successful = RTI_OS_Directory( "CREATE", directory <, createPath> )

Parameters

directory: The directory path to be created.

createPath: <Optional> A boolean value. If set to TRUE a multiple levels may be created.

Returns

A boolean value.

Examples
***************************************

declare function RTI_OS_Directory

 

// Create a new directory called mydir in c:\revsoft.

directory = "c:\revsoft\mydir"

result = RTI_OS_Directory( "CREATE", directory)

Example 2

***************************************

declare function RTI_OS_Directory

$Insert Logical 

// create the full directory structure c:\revsoft\newdir\mydir

declare function rti_os_directory

directory = "c:\revsoft\newdir\mydir"

createPath = TRUE$

result = RTI_OS_Directory( "CREATE", directory, createPath)

Delete Method

Description

Deletes a directory if it is empty, and/or all the files in the directory.

Syntax

success = RTI_OS_Directory( "DELETE", directory <, files> <, deleteDir> )

Parameters

directory: The directory path to be deleted.

files: <Optional> The file(s) to be deleted.

If null and the directory is empty then the directory itself will be deleted.

Multiple filenames should be @fm-delimited, @vm-delimited or comma-delimited. This method does support the question mark (?) and asterisk (*) wildcards.

To delete all .doc files in a directory pass *.doc

deleteDir <Optional> If TRUE, will delete the directory after all the files are deleted.

The default value is FALSE.

Returns

A boolean value.

Remarks

A directory will only be deleted if it is empty.

Examples

Example 1

declare function RTI_OS_Directory

// delete a directory called mydir in c:\revsoft.

directory = "c:\revsoft\mydir"

success = RTI_OS_Directory( "DELETE", directory)

Example 2

declare function RTI_OS_Directory

// delete all files in the directory c:\revsoft\mydir, but do not delete the directory

directory = "c:\revsoft\mydir"

files = "*.*"

success = RTI_OS_Directory( "DELETE", directory, files )

Example 3

declare function RTI_OS_Directory

$Insert Logical

// delete all files in the directory c:\revsoft\mydir and delete the directory

directory = "c:\revsoft\mydir"

files = "*.*"

success = RTI_OS_Directory( "DELETE", directory, files, TRUE$)

Rename Method

Description

Renames a directory.

Syntax

successful = RTI_OS_Directory( "RENAME", directory, newPath )

Parameters

directory: The full path to the directory to rename.

newPath: The full path to the new name of the directory.

Returns

A boolean value. If FALSE, the use of Get_Status() will return an error code and description.

Remarks

This method will only act upon on the lowest level directory.

Examples

Example 1

declare function RTI_OS_Directory

// Rename a directory called c:\revsoft\mydir to c:\revsoft\newdir

directory = "c:\revsoft\mydir"

newname = "c:\revsoft\newdir"

successful = RTI_OS_directory( "RENAME", directory, newname )

if not(successful) then

   error = Get_Status(errCodes)

   if error then

      call FsMsg()

   end

end

Exists Method

Description

Determines whether a directory exists.

Syntax

exists = RTI_OS_Directory( "EXISTS", directory )

Parameters

directory: The full path to the directory to be verified.

Returns

-1: The path does not exist. 0: The path is valid however it is not a directory. 1: The path exists.

Examples

Example 1

declare function RTI_OS_Directory

// checks to see if the directory c:\revsoft\mydir exists

directory = "c:\revsoft\mydir"

exists = RTI_OS_Directory( "EXISTS", directory )

Choose Method

Description

Calls the Common Windows File dialog window, modifying the dialog to display and return only directory information.

Syntax

directory = RTI_OS_Directory( "CHOOSE" <, directory> <, title> )

Parameters

directory: <Optional> The initial directory to be displayed.

title: <Optional> The title to display in the dialog window.

Returns

The full path to the directory chosen.

Examples

Example 1

declare function RTI_OS_Directory

// displays the choose directory dialog window with the initial directory set to c:\revsoft
// and with the text "Choose a directory" displayed in the dialog window

directory = "c:\revsoft"

title = "Choose a directory"

result = RTI_OS_Directory( "CHOOSE", directory, title)

GetLogicalDrives Method

Description

Retrieves a list of the logical drives attached to the current machine.

Syntax

results = RTI_OS_Directory( "GetLogicalDrives" )

Parameters

<empty>: This method does not accept parameters.

Returns

An @fm-delimited list of logical drive letters.

Examples

Example 1

declare function RTI_OS_Directory

// returns a list of logical drives for the current machine

result = RTI_OS_Directory( "GETLOGICALDRIVES" )

GetSubDirectories Method

Description

Retrieves the subdirectories within a directory.

Syntax

results = RTI_OS_Directory( "GETSUBDIRECTORIES" <, levels> )

Parameters

directory: The directory from which subdirectories should be returned.

levels: <Optional> The number of subdirectory levels to navigate. Defaults to 1, which will only return the sub directories of the passed directory.

Returns

Returns an @fm delimited list of subdirectories in the given directory, in the order in which they were encountered.

Examples

Example 1

declare function RTI_OS_Directory

// returns an @fm delimited list of subdirectories in the c:\revsoft

// directory
 

directory = "c:\revsoft"

levels = 1

result = RTI_OS_Directory( "GETSUBDIRECTORIES", directory, levels )

GetFiles Method

Description

Retrieves file names from a specified directory.

Syntax

fileList = RTI_OS_Directory( "GetFiles", directory <,file_filter> <, attrib_filter> )

Parameters

directory: The directory from which to retrieve the file list.

name_filter: <Optional> Filename filter. Supports the the use of wild cards ? and *.

attrib_filter: <Optional> File attributes filter. Refer to SetInitDirOptions subroutine for more information.

Returns

An @fm-delimited list of file names (not including the directory).

Examples

Example 1

declare function RTI_OS_Directory

// returns an @fm delimited list of files in the specified directory

directory = "c:\revsoft"

files = RTI_OS_Directory( "GETFILES", directory)

Example 2

declare function RTI_OS_Directory

// returns an @fm delimited list of files in the specified directory matching the filename

// filter.

// In this example files matching the file extension .pdf will be returned.

directory = "c:\revsoft\oinsight"

filter = "*.pdf"

result = RTI_OS_Directory( "GETFILES", directory, filter )

Example 3

declare function RTI_OS_Directory

// returns an @fm delimited list of files in the specified directory matching the filename

// filter and the special attributes filter.

// In this example a list of files with a .pdf extension which have the archive attribute will

// be returned.

directory = "c:\revsoft"

filter = "*.pdf"

attributes = "A"

result = RTI_OS_Directory( "GETFILES", directory, filter, attributes )

GetAttributes Method

Description

Returns the requested attributes of a file. Attributes include size, create date, create time and extended attributes like image details and mp3 encoding details.

Syntax

attribs = RTI_OS_Directory( "GetAttributes", directory, filename <, attributes> )

Parameters

directory: The directory path containing the file whose attributes are to be returned.

filename: The name of the file whose attributes are to be returned.

attributes: <Optional> An @fm or @vm-delimited list of attributes to be returned. If null, then the function will return all attributes.

Returns

An @fm-delimited list of attribute values based on the order passed in the <attributes> parameter.

Examples

Example 1

declare function RTI_OS_Directory

// returns an @fm delimited list of all the extended attributes for a file

directory = "c:\revsoft\oinsight"

filename = "readme.pdf"

result = rti_os_directory( "GetAttributes", directory, filename)

Example 2

declare function RTI_OS_Directory


// returns the size of the file requested

directory = "c:\revsoft\oinsight"

filename = "readme.pdf"

attributes = "size"

result = RTI_OS_Directory( "GetAttributes", directory, filename, attributes )

Example 3

declare function RTI_OS_Directory

// returns an @fm delimited list of attributes in the order in which they are requested

directory = "c:\revsoft\oinsight"

filename = "readme.pdf"

attributes = "size,kind,title"

result = RTI_OS_Directory( "GetAttributes", directory, filter, attributes)

GetWindowsDirectory Method

Description

Returns the path to where Windows is installed.

Syntax

results = RTI_OS_Directory( "GetWindowsDirectory" )

Parameters

<empty>: This method does not accept parameters.

Returns

The full path to the directory where Windows is installed.

Examples

Example 1

declare function RTI_OS_Directory

// returns the path to the directory where windows is installed

result = RTI_OS_Directory( "GetWindowsDirectory")

GetOIDirectory Method

Description

Returns the path to where OpenInsight is installed.

Syntax

result = RTI_OS_Directory( "GetOIDirectory" )

Parameters

<empty>: This method does not accept parameters.

Returns

The full path to the directory where OpenInsight is installed.

Example 1

declare function RTI_OS_Directory

$Insert Logical

// returns the path to the directory where OpenInsight is installed

result = RTI_OS_Directory( "GetOIDirectory" )

GetMyDocuments Method

Description

Returns the path to the "My Documents" directory.

Syntax

result = RTI_OS_Directory( "GetMyDocuments" )

Parameters

<empty>

Returns

Returns the path to the "My Documents" directory.

Examples

Example 1

declare function RTI_OS_Directory

$Insert Logical

// returns the path to the the "My Documents" directory

result = RTI_OS_Directory( "GetMyDocuments" )

GetDesktopDirectory Method

Description

Returns the path to the Windows Desktop.

Syntax

tempPath = RTI_OS_Directory( "GetDesktopDirectory" )

Parameters

<empty>: This method does not accept parameters.

Returns

The full path to the directory where the Desktop is located.

Examples

Example 1

declare function RTI_OS_Directory

$Insert Logical

// returns the path to the directory where the Windows Temp folder is located

result = RTI_OS_Directory( "GetDesktopDirectory" )

GetWindowsTempPath Method

Description

Returns the path to the Windows temp directory.

Syntax

tempPath = RTI_OS_Directory( "GetWindowsTempPath" )

Parameters

<empty>: This method does not accept parameters.

Returns

The full path to the directory where the Windows TEMP folder is located.

Examples

Example 1

declare function RTI_OS_Directory

$Insert Logical

// returns the path to the directory where the Windows Temp folder is located

result = RTI_OS_Directory( "GetWindowsTempPath" )
  • guides/programming/programmers_reference_manual/rti_os_directory.txt
  • Last modified: 2024/10/25 12:49
  • by bshumsky