UXP Toolkit
    Preparing search index...

    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.

    // 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

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    isEntry: boolean

    Indicates that this instance is an Entry. Useful for type-checking.

    if (something.isEntry) {
    return something.getMetadata();
    }
    isFile: boolean

    Indicates that this instance is not a File. Useful for type-checking.

    if (!anEntry.isFile) {
    return "This entry is not a file.";
    }
    isFolder: true

    Indicates that this instance is a folder. Useful for type checking.

    name: string

    The name of this entry. Read-only.

    console.log(anEntry.name);
    
    nativePath: string

    The platform native file-system path of this entry. Read-only

    console.log(anEntry.nativePath);
    

    The associated provider that services this entry. Read-only.

    if (entryOne.provider !== entryTwo.provider) {
    throw new Error("Providers are not the same");
    }
    url: string

    The url of this entry. You can use this url as input to other entities of the extension system like for eg: set as src attribute of a Image widget in UI. Read-only.

    console.log(anEntry.url);
    

    Methods

    • Copies this entry to the specified folder.

      Parameters

      • folder: Folder

        The folder to which to copy this entry.

      • Optionaloptions: { allowFolderCopy?: boolean; overwrite?: boolean }

        Options for the copy operation (all properties are optional)

        • OptionalallowFolderCopy?: boolean

          If true, allows copying the folder.

        • Optionaloverwrite?: boolean

          If true, allows overwriting existing entries.

      Returns Promise<Folder | File>

      EntryExists If the attempt would overwrite an entry and overwrite is false.

      PermissionDenied If the underlying file system rejects the attempt.

      OutOfSpace If the file system is out of storage space.

      await someFile.copyTo(someFolder);
      
      await someFile.copyTo(someFolder, {overwrite: true});
      
      await someFolder.copyTo(anotherFolder, {overwrite: true, allowFolderCopy: true});
      
    • Creates an entry within this folder and returns the appropriate instance.

      Parameters

      • name: string

        The name of the entry to create.

      • Optionaloptions: { overwrite?: boolean; type?: TypeSymbol }

        Options for the create operation (all properties are optional)

        • Optionaloverwrite?: boolean

          If true, the create attempt can overwrite an existing file.

        • Optionaltype?: TypeSymbol

          Indicates which kind of entry to create. Pass folder 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.

      Returns Promise<Folder | File>

      The created entry.

      const myNovel = await aFolder.createEntry("mynovel.txt");
      
      const catImageCollection = await aFolder.createEntry("cats", {type: types.folder});
      
    • 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.

      Parameters

      • name: string

        The name of the file to create.

      • Optionaloptions: { overwrite?: boolean }

        Options for the create operation (all properties are optional)

        • Optionaloverwrite?: boolean

          If true, the create attempt can overwrite an existing file.

      Returns Promise<File>

      The created file entry.

    • Moves this entry to the target folder, optionally specifying a new name.

      Parameters

      • folder: Folder

        The folder to which to move this entry.

      • Optionaloptions: { newName?: string; overwrite?: boolean }

        Options for the move operation (all properties are optional)

        • OptionalnewName?: string

          If specified, the entry is renamed to this name.

        • Optionaloverwrite?: boolean

          If true allows the move to overwrite existing files.

      Returns Promise<void>

      await someFile.moveTo(someFolder);
      
      await someFile.moveTo(someFolder, {overwrite: true});
      
      await someFolder.moveTo(anotherFolder, {overwrite: true});
      
      await someFile.moveTo(someFolder, {newName: 'masterpiece.txt'})
      
      await someFile.moveTo(someFolder, {newName: 'novel.txt', {overwrite: true})
      
    • Returns the details of the given entry like name, type and native path in a readable string format.

      Returns string