File utilities for Base64 conversion and export
[heading: "Description"]FileTools is a static utility class that provides methods for Base64 conversion, file path manipulation, and song data preparation for chart export. It centralises common file-related operations so that parsers, the file system layer, and the export pipeline share a single implementation.
[heading: "Key Features"] [list] * Converts URLs to Base64 data URIs * Strips data URI prefixes to extract raw Base64 strings * Parses song data for chart export * Resolves file paths, names, and extensions [/list] [heading: "Methods"] [table header] [ Method | Parameters | Description ] [ extractBase64 | (dataUrl) | Strips the data URI prefix from a data URI string, returning raw Base64. ] [ getFilename | (url) | Extracts the filename portion from a URL or file path. ] [ getDirectory | (url) | Extracts the directory portion from a URL or file path. ] [ getExtension | (url) | Extracts the file extension from a URL or file path. ] [ loadTextFile | (url) | Fetches a text file from a URL using XMLHttpRequest. ] [ readTextFile | (file) | Reads a File object as text using FileReader. ] [ readBinaryFile | (file) | Reads a File object as a binary string using FileReader. ] [/table] [heading: "Example Usage (Modding)"] [codeblock javascript] // Converting a remote image URL to a Base64 string const base64 = await FileTools.urlToBase64('https://example.com/banner.png'); if (base64) { const img = new Image(); img.src = 'data:image/png;base64,' + base64; } // Extracting a filename from a full path const name = FileTools.getFilename('Songs/MySong/audio.mp3'); console.log(name); // "audio.mp3" [/codeblock] [footer: "© Retora 2026"]