sublime_lib icon indicating copy to clipboard operation
sublime_lib copied to clipboard

Expose resource roots

Open Thom1729 opened this issue 6 years ago • 1 comments

In order to implement ResourcePath.from_file_path() and Resource_path.file_path(), we internally keep a list of ResourceRoot objects. Exposing these roots could allow users to answer various tricky questions about resources:

  • Is a given resource from a zipped or unzipped package?
  • Does a given resource have overrides?
  • When was a given resource last modified?

This functionality could be useful for packages like OverrideAudit. In addition, it could be used to implement resource caching (#24): a resource must be reloaded if either the modification time or the resource root has changed.

As a first thought, a resource root could support the following operations:

  • resource_to_file_path(path) -> Path (already implemented)
  • file_to_resource_path(path) -> ResourcePath (already implemented)
  • resource_exists(path) → boolean
  • resource_modified(path) → timestamp
  • load_resource(path) → string
  • load_binary_resource(path) → bytes

The following operation would be provided at the ResourcePath level (or perhaps in a new class?):

  • roots_providing_resource(path) → List[ResourceRoot]

Thom1729 avatar Jun 05 '19 15:06 Thom1729

Good idea, imo.

FichteFoll avatar Jun 05 '19 15:06 FichteFoll