require('uxp').storage.Entry
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.
Entry(name, provider, id)
Creates an instance of Entry.
| Param | Type |
|---|---|
name | * |
provider | * |
id | * |
isEntry : boolean
Indicates that this instance is an Entry. Useful for type-checking.
Example
Copied to your clipboardif (something.isEntry) {return something.getMetadata();}
isFile : boolean
Read only
Indicates that this instance is not a File. Useful for type-
checking.
Example
Copied to your clipboardif (!anEntry.isFile) {return "This entry is not a file.";}
isFolder : boolean
Read only Indicates that this instance is not a folder. Useful for type- checking.
Example
Copied to your clipboardif (!anEntry.isFolder) {return "This entry is not a folder.";}
name : string
Read only The name of this entry. Read-only.
Example
Copied to your clipboardconsole.log(anEntry.name);
provider : FileSystemProvider
Read only The associated provider that services this entry. Read-only.
Example
Copied to your clipboardif (entryOne.provider !== entryTwo.provider) {throw new Error("Providers are not the same");}
url : string
Read only 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.
Example
Copied to your clipboardconsole.log(anEntry.url);
nativePath : string
Read only The platform native file-system path of this entry. Read-only
Example
Copied to your clipboardconsole.log(anEntry.nativePath);
toString()
Returns the details of the given entry like name, type and native path in a readable string format.
Returns: string
copyTo(folder, options)
Copies this entry to the specified folder.
Returns: Promise<File|Folder>
Throws:
EntryExistsif the attempt would overwrite an entry andoverwriteisfalsePermissionDeniedif the underlying file system rejects the attemptOutOfSpaceif the file system is out of storage space
| Param | Type | Default | Description |
|---|---|---|---|
folder | Folder | the folder to which to copy this entry | |
options | * | ||
[options.overwrite] | boolean | false | if true, allows overwriting existing entries |
[options.allowFolderCopy] | boolean | false | if true, allows copying the folder |
Example
Copied to your clipboardawait someFile.copyTo(someFolder);
Example
Copied to your clipboardawait someFile.copyTo(someFolder, {overwrite: true});
Example
Copied to your clipboardawait someFolder.copyTo(anotherFolder, {overwrite: true, allowFolderCopy: true});
moveTo(folder, options)
Moves this entry to the target folder, optionally specifying a new name.
| Param | Type | Default | Description |
|---|---|---|---|
folder | Folder | the folder to which to move this entry | |
options | * | ||
[options.overwrite] | boolean | false | If true allows the move to overwrite existing files |
[options.newName] | string | If specified, the entry is renamed to this name |
Returns: Promise<void>
Example
Copied to your clipboardawait someFile.moveTo(someFolder);
Example
Copied to your clipboardawait someFile.moveTo(someFolder, {overwrite: true});
Example
Copied to your clipboardawait someFolder.moveTo(anotherFolder, {overwrite: true});
Example
Copied to your clipboardawait someFile.moveTo(someFolder, {newName: 'masterpiece.txt'})
Example
Copied to your clipboardawait someFile.moveTo(someFolder, {newName: 'novel.txt', {overwrite: true})
delete()
Removes this entry from the file system. If the entry is a folder, all the contents will also be removed.
Returns: Promise<number> - the number is 0 if succeeded, otherwise throws an Error
Example
Copied to your clipboardawait aFile.delete();
getMetadata()
Returns this entry's metadata.
Returns: Promise<EntryMetadata>
Example
Copied to your clipboardconst metadata = aFile.getMetadata();

