Skip to content
English

Files Server Side Only

Open

Open a file from a given file path

ParameterDescription
resourcenamethe string name of your resource
filepaththe path to the file you with to open or create

FeatherCore.Files:Open(resourcename, filepath))

Example Usage:

lua
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
end)
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
end)

Read

Read the file that you have openned.

ParameterDescription
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

file:Read(mode)

Example Usage:

lua
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    local filedata = file:Read()
end)
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    local filedata = file:Read()
end)

Save

Save data to the file that you have opened.

ParameterDescription
contentThe data you with to save to the file
modeif nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly

file:Save(content, mode)

Example Usage:

lua
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    local filedata = file:Read()

    local data = "Some Awesome stuff!"

    file:Save(data)
end)
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    local filedata = file:Read()

    local data = "Some Awesome stuff!"

    file:Save(data)
end)

Update

Instead of needing to open and save a file, you can update data directly to the file.

ParameterDescription
contentThe data you with to save to the file
modeif nothing, it will default to standard save, modes are 'standard' or 'table'. Table will store a table to the file properly

file:Update(content, mode)

Example Usage:

lua
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    file:Update("Some Awesome stuff!")
end)
CreateThread(function()
    local file = FeatherCore.Files:Open(GetCurrentResourceName(), 'data.txt')
    file:Update("Some Awesome stuff!")
end)

Lazy Functions

There is a way to use these functions without needing to call the Open() function, this can be used for quick usage or prototyping, but is non-optimal and slower than the above.

Load File

Read the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

FeatherCore.Files:Load(resourcename, filepath, mode)

Example Usage:

lua
-- Lazy functions, not as optimized
CreateThread(function()
    local file = FeatherCore.Files:Load(GetCurrentResourceName(), 'data.txt')
end)
-- Lazy functions, not as optimized
CreateThread(function()
    local file = FeatherCore.Files:Load(GetCurrentResourceName(), 'data.txt')
end)

Save File

Save the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
contentdata to save to the file
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

FeatherCore.Files:Load(resourcename, filepath, mode)

Example Usage:

lua
-- Lazy functions, not as optimized
CreateThread(function()
    FeatherCore.Files:Save(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)
-- Lazy functions, not as optimized
CreateThread(function()
    FeatherCore.Files:Save(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)

Update File

Update the file that you have openned.

ParameterDescription
resourcenameName of the resource
filepathpath to the file you with to load
contentdata to update to the file
modeif nothing, it will default to standard read, mode are 'standard' or 'table'. Table will store a table to the file properly

FeatherCore.Files:Update(resourcename, filepath, content, mode)

Example Usage:

lua
-- Lazy functions, not as optimized
CreateThread(function()
    FeatherCore.Files:Update(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)
-- Lazy functions, not as optimized
CreateThread(function()
    FeatherCore.Files:Update(GetCurrentResourceName(), 'data.txt', "Some cool stuff!")
end)