Skip to content

File Shared

A module to work with files in both client and server side

JO Functions

jo.file.isExist()

Checks if a file exists

Syntax

lua
jo.file.isExist(...)

Parameters

modname : string

The file location

Return Value

Type : boolean

Returns true if the file exists, false otherwise

Example

lua
local isExist = jo.file.isExist('module.fileName')
print(isExist)
-- OR --
local isExist = jo.file.isExist('@resource.folder.fileName')
print(isExist)

jo.file.load()

Loads and executes a Lua file

Syntax

lua
jo.file.load(modname)

Parameters

modname : string

The file location

Return Value

Type : any

The result of the executed file, or false if there was an error

Example

lua
local file = jo.file.load('module.fileName')
print('File loaded')
-- OR --
local isExist = jo.file.load('@resource.folder.fileName')
print('File loaded')

jo.file.read()

Read a file and return it if it's exist or false. The function accept one or two arguments.
One argument: the filepath
Two argument: the resource AND the filepath

Syntax

lua
jo.file.read(...)

Parameters

... : string

path of the file

Return Value

Type : file|boolean,resource|string,modpath|string

Example

lua
local content,resource,modPath = jo.file.read('module.fileName')
print(content,resource,modPath)
-- OR --
local content,resource,modPath = jo.file.read('@resource.folder.fileName')
print(content,resource,modPath)

Last updated: