The brand new Registry API provides a simple way to create a Key/Value store for your app.
See Libraries and Components → Registry.
{
Registry: {},
Root: {
Pluto: {
panics: { ... },
config: {
"appearanceConfig.json": JSON.stringify({
wallpaper: "./assets/wallpapers/space.png",
useThemeWallpaper: true,
theme: "dark.theme",
sidebarType: "vertical",
}),
"settingsConfig.json": JSON.stringify({
warnSecurityIssues: true,
}),
themes: { ... },
},
apps: {
"README.MD":
"This folder contains all the apps that you have downloaded. If you have any questions about them please contact us.",
},
startup: "",
},
Desktop: {},
Documents: {},
Downloads: {},
Pictures: {},
Videos: {},
Music: {},
},
}Vfs functions are found as below. Some are documented, others are not
async exportFS()async importFS(fsObject = templateFsLayout)async getParentFolder(path)Helper function to get the parent folder of a given pathasync whatIs(path, fsObject = this.fileSystem)function to tell you if stored data is a file or a folderasync readFile(path, fsObject = this.fileSystem, bypass = false)Function to get the contents of a file at a given pathasync writeFile(path, contents, fsObject = this.fileSystem)Function to write to a file at a given pathasync createFolder(path, fsObject = this.fileSystem)Function to create a new folder at a given pathasync delete(path, fsObject = this.fileSystem)Function to delete a file or folder at a given pathasync list(path, fsObject = this.fileSystem)Function to list all files and folders at a given pathasync rename(path, newName, fsObject = this.fileSystem)Function to rename a file newName MUST be the new exact name of the file, NOT absolute.async exists(path, fsObject = this.fileSystem)async merge(fsObject = this.fileSystem)
Using the VFS in your app:
const Vfs = await Root.Lib.loadLibrary("VirtualFS");
await Vfs.importFS();
// You can now use Vfs with any of the functions aboveThe file Root/Pluto/startup allows you to configure startup apps. Use newlines to change which apps are launched at boot.
Example:
Root/Desktop/Settings.shrt
Root/Pluto/Apps/Example.js
launches Settings and Example at startup.
For config files, use the Registry path instead of Root. The files will be hidden from the end-user by default.
Here's an example:
const vfs = await Root.Lib.loadLibrary("VirtualFS");
await vfs.importFS();
// Registry is a hidden folder that can be used for storing app data but keeping it away from the user
vfs.writeFile("Registry/MyConfig.json", JSON.stringify(config));Use the Root/Pluto/cache/lib folder for storing external libraries.