All pages
Powered by GitBook
1 of 3

Loading...

Loading...

Loading...

Filesystem

dir(directory)

Return an iterator listing all the files and directories name in a directory

@status current Introduced in 2.5.0

Parameters

  • directory (string) Working directory

Return value

none

Example

    local var y = 40
    for fname in dir("/SCRIPTS") do
        lcd.drawText(5,y, fname, TEXT_COLOR)
        y = y + 20
    end

fstat(path)

Checks the existence of file or directory. If not exist, return nil. If exist, return the object information.

@status current Introduced in 2.5.0

Parameters

  • path (string) path to the object

Return value

  • table object info, table elements:

  • size (number) file size

  • attrib (number) file attribute flags

  • time (table) table with last time modified date and times, table elements:

    • year (number) year

    • mon (number) month

Example

day (number) day of month

  • hour (number) hours

  • hour12 (number) hours in US format

  • min (number) minutes

  • sec (number) seconds

  • suffix (text) am or pm

  •   info = fstat("radio")
      if info ~= nil then
        if (info.attrib == AM_DIR) then
          print("is a directory")
        end
    
        size = info.size
        time = info.time
      end