aspen-core
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • IBasicFileSystemHost

Index

Properties

getItems

getItems: function

Just slightly more than unix's ls command

Called when a Directory loads its contents

Do not waste computational time on sorting items just yet, return them as is (Specify host.sortComparator instead)

There is no need to sort raw items. The parent Directory will call your sortComparator function (if specified) once raw items are converted to "real" objects

Array of { name: string, type: FileType, attributes?: {[key: string]: any}}

Type declaration

    • (path: string): IFileEntryItem[] | Promise<IFileEntryItem[]>
    • Parameters

      • path: string

      Returns IFileEntryItem[] | Promise<IFileEntryItem[]>

pathStyle

pathStyle: "win32" | "unix"

Path style aspen should stick to for the duration of its existence

Valid values are win32 or unix. Invalid value will implicitly mean unix.

Once Root is set up, almost all of the common path utils can be accessed through Root#pathfx object. Utils in this object are 100% compliant with specified pathStyle

Notes:

  • win32 paths are separated by backslash (\) as well as forward slash (/), but if aspen needs to merge paths, it'll only use \ for that purpose
  • unix paths are separated ONLY by forward slash (/). Backslashes (\) in unix paths become part of the filename.

Optional sortComparator

sortComparator: function

Sorting comparator Directories should use when:

  • Directory is expanded for first time
  • Root#forceLoadFileEntryAtPath is called and the target exists in a Directory that was not expaned previously (thus triggering a hard reload)
  • On WatchEvent.Moved, WatchEvent.Added and WatchEvent.Changed (but not on WatchEvent.Removed)

REMINDER: Avoid using instanceof when checking if an item is Directory or FileEntry. instanceof is computationally expensive and not required for this purpose. Use item.type === FileType.File to check if item is FileEntry and item.type === FileType.Directory to check for Directory

Type declaration

Optional watch

watch: function

File watching

This method will be called whenever a Directory loads its contents to let the host know that aspen will be expecting notifications if any file(s) get added/removed/moved

Host and UI can stay in a perfect sync if host is good at notifying aspen about any changes.

Hereafter, use Root#inotify to dispatch the events (dispatch a properly formatted IWatcherEvent and Root will take care of the rest)

watch must return a function that aspen can call to terminate a watch session when it's no longer needed. The returned function will be called with the same path which was used to start the watch in first place.

It is recommended that instead of returning a new function reference everytime, all calls to watch should return same function for each watch. That one function can take the path parameter and terminate the associated watcher accordingly.

Type declaration

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc