UXP Toolkit
    Preparing search index...

    An Entry is the base class for File and Folder. You'll typically never instantiate an Entry directly, but it provides the common fields and methods that both File and Folder share.

    You can get an instance of Entry via the localFileSystem by fetching an instance of a File or Folder.

    // Since Entry cannot be called directly we can use a File or Folder object to invoke Entry as shown below
    const fs = require('uxp').storage.localFileSystem;
    const folder = await fs.getPluginFolder(); // returns a Folder instance
    const folderEntry = await folder.getEntry("entryName.txt");
    // Now we can use folderEntry to invoke the APIs provided by Entry
    console.log(folderEntry.isEntry); // isEntry is an API of Entry, in this example it will return 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: boolean

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

    if (!anEntry.isFolder) {
    return "This entry is not a folder.";
    }
    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});
      
    • 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