FileManager

Services.get("FileManager")

Overview:

Functions:

The working directory is automatically the parent folder of the current script!

API Reference

fileExists()

Returns true if the file exists or false if it does not exist or is inaccessible.

fileManager.fileExists("config.json")

Parameters:

  • path (String)

Returns Boolean.


read()

Returns the data of a readable file (in String) if successfully ran.

Parameters:

  • path (String)

Returns String.


write()

Writes the data (in String) on the file, overwriting its previous data.

Parameters:

  • path (String)

  • data (String) ⇒ The content that will be written to the file

Returns:


createFile()

Creates a file (if it does not exist) on the specified path. Use forward slashes "/" to jump to folders.

Parameters:

  • path (String)

Returns: java.io.File


createFolder()

Creates a folder (if it does not exist) on the specified path. Use forward slashes "/" to jump to folders.

Parameters:

  • path (String)

Returns:


listenOnPath()

Allows scripts to listen for file changes on the specified path.

Parameters:

  • path (String)

  • listenerType (String) ⇒ "ENTRY_CREATE" When a file gets added/created "ENTRY_DELETE" When a file gets removed/moved "ENTRY_MODIFY" When a file gets modified/edited

Returns (function handler):

  • Event Type "ENTRY_CREATE" or "ENTRY_DELETE" or "ENTRY_MODIFY"


clearFileListeners()

Removes all of the file listeners created by the current script.


Example:

Last updated

Was this helpful?