-
-
Notifications
You must be signed in to change notification settings - Fork 2
Library: File System
ov - Anisa edited this page Jun 14, 2025
·
7 revisions
The File module provides a comprehensive file system management solution, designed to simulate file system operations similar to those found in other programming languages like JavaScript. This module was developed to address specific use cases and overcome limitations in MTA's file path handling.
Add the below code globally once in either of the shared .lua
script of the resource you want to use within:
loadstring(exports.assetify_library:import("filesystem"))()
-
✨ Verifies whether the specified file exists.
local bool: result = assetify.file:exists( string: path )
-
✨ Deletes the specified file.
local bool: result = assetify.file:delete( string: path )
-
✨ Retrieves specified path's buffer data.
local string: result = assetify.file:read( string: path )
-
✨ Writes buffer data to a specified path.
local bool: result = assetify.file:write( string: path, string: data )
-
✨ Deletes specified directory.
local bool: result = assetify.file:deleteDir( string: path )
-
✨ Parses url & returns all possible known datas.
local table: result = assetify.file:parseURL( string: path ) result: { pointer = string: pointer, --rootDir (~/url) / localDir (@/url) / false url = string: url extension = string: extension, --Extension of file (If any) file = string: file --Name of file (If any) directory = string: directory --Directory list the file is located within (If any) }
-
✨ Resolves & returns resolved url.
local string: result = assetify.file:resolveURL( string: path, --This can be relative path such as "@/dirA/dirB/dirC/.../.../dirD/file.json", "~/dirA/dirB/dirC/.../.../dirD/file.json", "dirB/dirC/.../.../dirD/file.json" etc string: chroot --Optional: If specified resolver will be limited within specified chroot's scope )