Skip to main content

FileSystem

fs.file_load_bin

Loads a binary file into memory.

  • Parameters:

    NameTypeDescription
    namestringThe path to the binary file.
  • Return:

    TypeDescription
    userdata|nullA pointer to the binary data if successful, or nil if the file could not be loaded.
  • Methods:

    • fs.file_load_bin(name)

fs.file_load_txt

Loads a text file as a string.

  • Parameters:

    NameTypeDescription
    namestringThe path to the text file.
  • Return:

    TypeDescription
    stringThe content of the file as a string, or an empty string if the file could not be loaded.
  • Methods:

    • fs.file_load_txt(name)

fs.file_free

Frees the memory allocated for a binary or text file.

  • Parameters:

    NameTypeDescription
    datauserdata|stringThe pointer to the binary data that needs to be freed.
  • Return:

    TypeDescription
    booleanTrue if the data was successfully freed, False otherwise.
  • Methods:

    • fs.file_free(data)

fs.file_write

Writes text to a file, overwriting any existing content.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file.
    textstringThe text to write to the file.
  • Return:

    TypeDescription
    booleanTrue if the write operation was successful, False otherwise.
  • Methods:

    • fs.file_write(name, text)

fs.file_append

Appends text to the end of a file.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file.
    textstringThe text to append to the file.
  • Return:

    TypeDescription
    booleanTrue if the append operation was successful, False otherwise.
  • Methods:

    • fs.file_append(name, text)

fs.exists

Checks if a file or directory exists.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file or directory.
  • Return:

    TypeDescription
    booleanTrue if the file or directory exists, False otherwise.
  • Methods:

    • fs.exists(name)

fs.file_exists

Checks specifically if a file exists.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file.
  • Return:

    TypeDescription
    booleanTrue if the file exists, False otherwise.
  • Methods:

    • fs.file_exists(name)

fs.directory_exists

Checks specifically if a directory exists.

  • Parameters:

    NameTypeDescription
    namestringThe path to the directory.
  • Return:

    TypeDescription
    booleanTrue if the directory exists, False otherwise.
  • Methods:

    • fs.directory_exists(name)

fs.create_dir

Creates a directory at the specified path.

  • Parameters:

    NameTypeDescription
    namestringThe path where the directory should be created.
  • Return:

    TypeDescription
    booleanTrue if the directory was successfully created, False otherwise.
  • Methods:

    • fs.create_dir(name)

fs.is_file

Checks if the specified path is a file.

  • Parameters:

    NameTypeDescription
    namestringThe path to check.
  • Return:

    TypeDescription
    booleanTrue if the path is a file, False otherwise.
  • Methods:

    • fs.is_file(name)

fs.is_dir

Checks if the specified path is a directory.

  • Parameters:

    NameTypeDescription
    namestringThe path to check.
  • Return:

    TypeDescription
    booleanTrue if the path is a directory, False otherwise.
  • Methods:

    • fs.is_dir(name)

fs.delete

Deletes a file or directory at the specified path.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file or directory to delete.
  • Return:

    TypeDescription
    booleanTrue if the file or directory was successfully deleted, False otherwise.
  • Methods:

    • fs.delete(name)

fs.get_size

Gets the size of a file or directory.

  • Parameters:

    NameTypeDescription
    namestringThe path to the file or directory.
  • Return:

    TypeDescription
    numberThe size of the file or directory in bytes.
  • Methods:

    • fs.get_size(name)

fs.get_appdata_dir

Returns the directory path for the application data.

  • Return:

    TypeDescription
    stringThe path to the application data directory.
  • Methods:

    • fs.get_appdata_dir()

fs.get_product_dir

Returns the directory path for the product-specific files.

  • Return:

    TypeDescription
    stringThe path to the product directory.
  • Methods:

    • fs.get_product_dir()

fs.get_log_dir

Returns the directory path for product logs.

  • Return:

    TypeDescription
    stringThe path to the product log directory.
  • Methods:

    • fs.get_log_dir()