Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Library: File System

ov - Anisa edited this page Jun 14, 2025 · 7 revisions

» Overview

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.

» Importing

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"))()

» APIs

  • assetify.file:exists() - shared

    Verifies whether the specified file exists.

    local bool: result = assetify.file:exists(
       string: path
    )
  • assetify.file:delete() - shared

    Deletes the specified file.

    local bool: result = assetify.file:delete(
       string: path
    )
  • assetify.file:read() - shared

    Retrieves specified path's buffer data.

    local string: result = assetify.file:read(
       string: path
    )
  • assetify.file:write() - shared

    Writes buffer data to a specified path.

    local bool: result = assetify.file:write(
       string: path,
       string: data
    )
  • assetify.file:deleteDir() - shared

    Deletes specified directory.

    local bool: result = assetify.file:deleteDir(
       string: path
    )
  • assetify.file:parseURL() - shared

    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)
    }
  • assetify.file:resolveURL() - shared

    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
    )
Clone this wiki locally