FileEntry

From SDK
Revision as of 08:22, 4 August 2021 by WikiSysop (talk | contribs) (→‎References)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Back.jpg

This object is returned from the:GetFileAtIndex() method of DirectoryReader and holds information about a file found while building the list of files and directories.


Properties

.Name

Interaction: Read Only

Returns: (string) Name of the file (this is the full pathname to the file)



.FileName

Interaction: Read Only

Returns: (string) Name of the file



.FileNameNoExt

Interaction: Read Only

Returns: (string) Name of the file without the extension



.Size

Interaction: Read Only

Returns: (integer) Size of the file in bytes


Example Code:

   From DXF_Batch_Processor.Lua
     -- [[ ----------- DirectoryProcessor --------------- 
    |
    | Given a root directory and file filter, call the passed function with
    | every file which matches the filter
    |
    | The do_sub_dirs flag indicates if sub directories should be processed as
    | well as the root directory
    |
    ]]
    function DirectoryProcessor(job, dir_name, filter, do_sub_dirs, function_ptr)
    local num_files_processed = 0
    local directory_reader = DirectoryReader()
    local cur_dir_reader = DirectoryReader()
    directory_reader:BuildDirectoryList(dir_name, do_sub_dirs)
    directory_reader:SortDirs()
    local number_of_directories = directory_reader:NumberOfDirs()
    for i = 1, number_of_directories do
    local cur_directory = directory_reader:DirAtIndex(i)
     -- get contents of current directory
     -- dont include sub dirs, use passed filter
    cur_dir_reader:BuildDirectoryList(cur_directory.Name, false)
    cur_dir_reader:GetFiles(filter, true, false)
     -- call passed method for each file:
    local num_files_in_dir = cur_dir_reader:NumberOfFiles()
    for j=1, num_files_in_dir  do
    local file_info = cur_dir_reader:FileAtIndex(j)
    if not function_ptr(job, file_info.Name) then
    return negitve 1
    end
    num_files_processed = num_files_processed + 1
    end
     -- empty out our directory object ready for next go
    cur_dir_reader:ClearDirs()
    cur_dir_reader:ClearFiles()
    end
    return num_files_processed
    end 



Back.jpg

References

Please Note: The base material for the contents found in this WiKi was sourced from Vectric Lua Interface for Gadgets, version 10.0, published August 21, 2019. by Vectric Ltd. Most current document from Vertric can be downloaded at Vertric Developer Information