Folder
Represents a folder on a file system. You'll never instantiate this directly, but will get it by calling FileSystemProvider.getTemporaryFolder, FileSystemProvider.getFolder, or via Folder.getEntries.
Example
// Get the Folder instance via localFileSystem
const fs = require('uxp').storage.localFileSystem;
const folder = await fs.getTemporaryFolder(); // Gets the Folder instance
console.log(folder.isFolder); // returns true
isFolder
Indicates that this instance is a folder. Useful for type checking.
getEntries()
Returns an array of entries contained within this folder.
Returns: Promise<Array<Entry>> - The entries within the folder.
Example
const entries = await aFolder.getEntries();
const allFiles = entries.filter(entry => entry.isFile);
createEntry(name, options)
Creates an entry within this folder and returns the appropriate instance.
Returns: Promise<File | Folder> the created entry
stringanySymboltypes.fileFolder to create a new folder. Note that if the type is file then this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object.booleanfalsetrue, the create attempt can overwrite an existing fileExample
const myNovel = await aFolder.createEntry("mynovel.txt");
Example
const catImageCollection = await aFolder.createEntry("cats", {type: types.folder});
createFile(name, options)
Creates a File Entry object within this folder and returns the appropriate instance. Note that this method just create a file entry object and not the actual file on the disk. The file actually gets created when you call for eg: write method on the file entry object.
Returns: Promise<File> - the created file entry
stringanybooleanfalsetrue, the create attempt can overwrite an existing fileExample
const myNovelTxtFile = await aFolder.createFile("mynovel.txt");
createFolder(name)
Creates a Folder within this folder and returns the appropriate instance.
Returns: Promise<Folder> - the created folder entry object
stringExample
const myCollectionsFolder = await aFolder.createFolder("collections");
getEntry(filePath)
Gets an entry from within this folder and returns the appropriate instance.
Returns: Promise<File | Folder> the fetched entry.
stringExample
const myNovel = await aFolder.getEntry("mynovel.txt");
renameEntry(entry, newName, options)
Renames an entry to a new name.
Returns: Promise<void>
Entrystringanybooleanfalsetrue, renaming can overwrite an existing entryExample
await myNovels.rename(myNovel, "myFantasticNovel.txt");
isFolder ⇒ boolean
Checks if an entry is a folder. Safe to use if entry might be null or undefined. Useful for type checking.
Returns: boolean - if true, the entry is a folder
any