# Class Method: $system::getfiles()

Updated: 1/18/2022, 5:31:44 PM
Created: 1/18/2022, 5:31:44 PM
Last Updated By: dependabot[bot]
Read Time: 1 minute(s)

# Description

The getfiles() method creates a sub-object of all files visible to the JEDIFILEPATH environment variable or defined as Q- or F-pointers in the MD/VOC provided JEDIFILENAME_MD is defined.

Files in the current directory are also included by default.

An optional parameter can filter out a specific file.

The sub-object contains 2 properties:

filepath - an array of the search paths for files

files - an array of sub-objects where each sub-object has the following properties:

fullpath - the full path to the file

directory - the directory containing the file

name - the file name

index - the position the file is found in the filepath property; this is number is zero-based

# Return Value

The total number of files found.

# Examples

Display everything:

equ beautify to 5
my_system = new object("$system")
my_system->getfiles()
crt my_system->$tojson(beautify)
1
2
3
4

Display a single file:

equ beautify to 5
my_system = new object("$system")
my_system->getfiles("JDEMO")
crt my_system->$tojson(beautify)
1
2
3
4

Result:

{
    "filepath":[
        "C:\\jbase\\globals\\MD",
        "C:\\home\\testfiles",
        "."
    ],
    "files":[
        {
            "fullpath":"C:\\home\\testfiles\\JDEMO",
            "directory":"C:\\home\\testfiles",
            "name":"JDEMO",
            "index":1
        }
    ]
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

Back to $system class