Docs

FileSystem

This API class can be used for File I/O and create File objects that can be used to access files.

Special Locations

In order to access files, you will need to use the constants of the FileSystem object in order to go to special locations.

Location Description
AudioFiles The audio file folder. In HISE it will be the repo folder, but in the compiled project it will be a sub folder in the appdata folder.
Samples The sample folder as specified in the settings (or the subfolder of the HISE project during development).
AppData The app data directory. This is the main directory for your project which will house the configuration files and user presets.
UserHome The user home folder. Documents The user's Document folder.
Desktop The user's desktop folder.
Downloads The user's download folder.

Please be aware that using any of the user's folder without a good reason is bad taste and should be avoided if possible.

Class methods

browse

Opens a file browser to choose a file.

FileSystem.browse(var startFolder, bool forSaving, String wildcard, var callback)


This will create a file browser from the OS that let's the user choose a file for loading or saving (in case of saving it will confirm a overwrite).

If you call this function it will return immediately and open the file browser asynchronously (otherwise the script execution would time out during the selection).
Therefore you will need to pass in a function that will be executed as soon as the user has selected a file. It expects a function with a single parameter that will hold a File object with the selected file:

FileSystem.browse(undefined, false, "*.txt", function(result)
{
    // the parameter is a File object, so we just show it
    // in the OS' file browser.
    result.show();
});


browseForDirectory

Opens a file browser to choose a directory.

FileSystem.browseForDirectory(var startFolder, var callback)



findFiles

Returns a list of all child files of a directory that match the wildcard.

FileSystem.findFiles(var directory, String wildcard, bool recursive)


This will search a given directory and return an Array that contains one File object per child file.
You can use it to build up a file browser.

fromAbsolutePath

Returns a file object from an absolute path (eg. C:/Windows/MyProgram.exe).

FileSystem.fromAbsolutePath(String path)



getFolder

Returns the current sample folder as File object.

FileSystem.getFolder(var locationType)


You can use this method to access files from one of the given locations (take a look at the Special Locations above for a list of available folders).

You can navigate from that folder to the file you want with the File.getChildFile() method.

getSystemId

Returns a unique machine ID that can be used to identify the computer.

FileSystem.getSystemId()