HISE Docs

FileSystem

The FileSystem API class can be used for File I/O and to 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 in the repo folder, but in the compiled project it will be a sub folder in the appdata folder.
Expansions The expansion folder file folder. In HISE it will be in 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. Edit on GitHub

FileSystem.browseForDirectory(var startFolder, var callback)



decryptWithRSA

Decrypts the given string using a RSA public key. Edit on GitHub

FileSystem.decryptWithRSA( String dataToDecrypt,  String publicKey)



descriptionOfSizeInBytes

Convert a file size in bytes to a neat string description. Edit on GitHub

FileSystem.descriptionOfSizeInBytes(int64 bytes)



encryptWithRSA

Encrypts the given string using a RSA private key. Edit on GitHub

FileSystem.encryptWithRSA( String dataToEncrypt,  String privateKey)



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.

findFileSystemRoots

Returns a list of all root drives of the current computer. Edit on GitHub

FileSystem.findFileSystemRoots()



fromAbsolutePath

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

FileSystem.fromAbsolutePath(String path)



fromReferenceString

Returns a file object for the given location type and the reference string which can either contain a wildcard like {PROJECT_FOLDER} or a full file path. Edit on GitHub

FileSystem.fromReferenceString(String referenceStringOrFullPath, var locationType)



getBytesFreeOnVolume

Returns the number of free bytes on the volume of a given folder. Edit on GitHub

FileSystem.getBytesFreeOnVolume(var folder)



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. Edit on GitHub

FileSystem.getSystemId()



loadExampleAssets

Loads a bunch of dummy assets (audio files, MIDI files, filmstrips) for use in snippets & examples. Edit on GitHub

FileSystem.loadExampleAssets()