Bundle - develephant/luvit-docs GitHub Wiki

Load the Bundle library:

local bundle = require('luvi').bundle

Note the .bundle on the end of the require.

.stat(path)

Load metadata about a file in the bundle.

local status = bundle.stat(path)
if status then
  if status.type == 'file' then
    p( 'The file is ' .. status.size .. ' bytes.' )
  end
end

The status table will include the following keys:

Key Description
type 'file' or 'tree'
mtime file age in ms
size file size in bytes

.readdir(path)

Read a directory. Returns a list of filenames in the directory.

local file_arr = bundle.readdir(path)
for f=1, #file_arr do
  p( 'file: ' .. file_arr[f] )
end

.readfile(path)

Read the contents of a file.

local file_contents = bundle.readfile(path)
p( file_contents )

.paths()

Returns a table of sources to the bundle.

local paths_tbl = bundle.paths()
p( paths_tbl )

.mainPath

Returns the path to the main file. Property.

local path = bundle.mainPath
p( path )