The directory root for the extended filesystem which has more space (IndexedDB) and uses asynchronous access.
The directory where Inform reads author-provided files (not saves or transcripts).
Save file directory in the extended filesystem.
The directory for temporary files. The temporary directory is emptied after leaving the page.
Transcripts directory in the extended filesystem.
The directory Vorple uses for its own files for communication between the interpreter and the game file.
Copies a file to another location or name in the filesystem.
File to copy
Target directory or the new name
An optional options object.
Returns true on success, false otherwise.
Does a file or directory exist in the virtual filesystem?
File or directory name to check
An optional options object
Returns true if the file/directory exists, false otherwise.
Show a modal asking the user to provide a filename.
The function to call with the filename as the parameter after the user has selected the filename, or null if action was canceled
The root path of the file
Returns the BrowserFS object for direct access to the BrowserFS API.
Returns the FS object or null if the filesystem hasn't been initialized yet.
Check if a file is in a filesystem that requires asynchronous access.
(Asynchronous file access isn't officially supported so this is for internal use only.)
Path to the file. Must be a full path, not relative.
Returns an object with information about a file or directory.
File or directory
An optional options object
Returns the FileInfo information object, or null if the file or directory doesn't exist.
Creates a header for Inform 7 files. If the story is made with Inform 6, this method returns an empty string.
Project's name
Filename, path is automatically removed
If true, the file is marked "ready" for Inform 7
Returns the Inform 7 header or an empty string for Inform 6.
Initialize the filesystem. This gets called automatically when calling vorple.init() but it can be called manually before that to get access to the filesystem earlier.
The method returns a promise that resolves into the BrowserJS filesystem object, but after the promise has resolved all vorple.file.* are also available.
Returns a promise that resolves to the filesystem object.
Check if a file has been marked ready for Inform 7 to read.
If the file doesn't exist, it doesn't have a header, or it can't be read, the method returns false. Error conditions must be checked manually if it's important to make a difference between invalid operation and a file that has been marked not ready.
Path to the file
An optional options object
Returns true if file is ready, false on error or not ready.
This method always returns false on Inform 6.
Marks a file ready to read (or not ready to read) for Inform 7. This is equivalent of the phrases "mark (external file) as ready to read" and "mark (external file) as not ready to read" in Inform 7.
If the file doesn't have an Inform 7 header the method does nothing and returns false.
In Inform 6 this method does nothing and always returns false.
Path to the file
If true, marks the file ready. Otherwise marks the file not ready.
An optional options object
Returns true if operation was successful, false otherwise. Returns true even if no change was made to the file (was already marked ready.) Always returns false on Inform 6.
Create a new directory in the virtual filesystem.
This does not create missing subdirectories, e.g. mkdir( 'foo/bar' )
won't work if directory 'foo' doesn't exist.
The directory to create
An optional options object
Returns true if a directory was created, false otherwise.
Moves a file or directory to another directory. If the target doesn't exist, the file or directory is renamed.
File/directory to move
Target directory or the new name
An optional options object
Returns true on success, false otherwise.
Adds a path to a given filename. See https://nodejs.org/api/path.html#path_path_resolve_paths for rules on how path joining works.
The default root directory is /inform so
vorple.file.path( "foo.txt", "bar" )
will resolve to
/inform/bar/foo.txt
.
Name of the file
Path where the file is appended
Returns the full path.
Read a text file from the virtual filesystem
The file to read
An optional options object
Returns the contents of the file, or null file could not be read.
Reads the contents of a directory.
Name of the directory
An optional options object
Returns the list of files and directories as an array of strings. Returns null if the directory doesn't exist or if trying to read a file.
Get the URL to a resource, which can be a normal URL or a data URL containing the resource itself. This is used to get the resource files from the Borogove editor.
URL to the resource
Returns the URL or a data URL.
Ask the user to choose a save file to restore.
The IFID of the game
The function to call with the filename as the parameter after the user has selected the filename, or null if action was canceled
Remove a directory from the virtual filesystem. Directory must be empty.
An optional options object
Returns true if a directory was removed, false otherwise.
Ask the user to provide a filename for saving the transcript.
The IFID of the game
The function to call with the filename as the parameter after the user has selected the filename, or null if action was canceled
Ask the user to provide a filename for saving the transcript.
The function to call with the filename as the parameter after the user has selected the filename, or null if action was canceled
Unlink (i.e. delete) a file from the virtual filesystem. Use rmdir to remove directories.
File to unlink
An optional options object
Returns true if the file was removed, false otherwise.
Write a file to the virtual filesystem.
Filename/path to write
Contents of what to write to the file, either a string or a byte array
An optional options object
Returns true on success, false otherwise.
Generated using TypeDoc
This module is the access point to the virtual filesystem.
The system uses BrowserFS to handle the virtual filesystem in browser's localstorage. See https://jvilk.com/browserfs/1.4.1/classes/_backend_localstorage_.localstoragefilesystem.html for the full API. The getFS method can be used to retrieve the filesystem object that can be used to access the BrowserFS API directly.
All methods in this module use the synchronous versions of the filesystem methods (readFileSync, writeFileSync etc.)
3.2.0