FileOps.$filelist()

Function group Execute on client Platform(s)
FileOps NO All

Syntax

FileOps.$filelist(iInclude,cPath[,iInformation,cFilter,&cErrorText])

Description

Returns a list of files, directories, and volumes at the location specified in cPath. Errors are reported to cErrorText. Pathnames can be over 255 characters, which was the limit in Studio 8.0.1 or earlier.

The parameter iInclude specifies what to include in the list using a combination of the constants kFileOpsIncludeFiles, kFileOpsIncludeDirectories, and kFileOpsIncludeVolumes. Use + to combine the constants.

If you use kFileOpsIncludeVolumes, then the function adds a line for each volume to the start of the list. The remaining lines in the list, or all lines if you do not use kFileOpsIncludeVolumes, comprise a line for each file or directory in the directory cPath. You can restrict the files returned in the list using the optional filter cFilter. Note that cFilter does not apply to volume or directory names. The filter is a semicolon separated list of file-matching specifications. On all platforms, a file-matching specification can have the form *.<ext>, to match all files with the extension <ext>, or *.* to match all files. On macOS, a file-matching specification can also have the form 'TYPE' , 'TYPE,CREATOR', or ',CREATOR', where TYPE and CREATOR are the 4 character, case-sensitive Mac file type and creator. Note that in this case, the single quotes are part of the file-matching specification. Example file-matching specifications:

*.txt Matches files with .txt as their extension

*.txt;*.lbs Matches files with .txt or .lbs as their extension

"TEXT";",OO$$";*.txt Matches files of type TEXT, or created by Omnis Studio, or with .txt as their extension.

"OO$A,OO$$" Matches Omnis libraries used under macOS.

You specify the information to be returned by passing information as a combination of the kFileOpsInfo... constants listed in the following table. If you omit iInformation, only the name is returned. The returned list contains a column for each kFileOpsInfo... constant you specify. The columns you specify occur in the same order as the table.

Col name information constant description
name kFileOpsInfoName name of the file
name83 kFileOpsInfoName83 DOS 8.3 name of the file
fullname kFileOpsInfoFullName full pathname of the file
readonly kFileOpsInfoReadOnly file's read-only status
hidden kFileOpsInfoHidden file's hidden status
size kFileOpsInfoSize logical size of file
actualsize kFileOpsInfoActualSize physical size of file on disk; same as logical size under Windows
created kFileOpsInfoCreated date and time the file was created
modified kFileOpsInfoModified date and time the file was modified
creator kFileOpsInfoCreatorCode the file's creator under macOS, blank under Windows
type kFileOpsInfoTypeCode the file's type under macOS, the file extension under Windows

The function returns an empty list if an error occurs. The FileOps object supports 64-bit integers for file sizes and for offsets, etc in files.

Example

Do FileOps.$filelist(kFileOpsIncludeFiles+kFileOpsIncludeDirectories,sys(115)) Returns lFileList
; returns a list of files and directories in the main Omnis folder

Do FileOps.$filelist(
kFileOpsIncludeFiles,con(sys(115),'external'),kFileOpsInfoName+kFileOpsInfoCreated+kFileOpsInfoSize,'*.dll') Returns lFileList
; returns a list of DLLs in the Omnis\External folder including the name, size, creation date and time of each file

Do FileOps.$filelist(
kFileOpsIncludeFiles,'c:\windows',kFileOpsInfoSize+kFileOpsInfoFullName+kFileOpsInfoReadOnly+kFileOpsInfoCreated) Returns lFileList
; returns a list of files in the c:\windows folder including the fullname, read-only, size, creation date and time of each file