Skip to content

FileSystemProvider

Trae Yelovich edited this page Mar 21, 2024 · 12 revisions

Table of Contents

In v3 of Zowe Explorer, we have made an architectural shift from using temporary, on-disk files to using the FileSystemProvider interface provided by VS Code. Starting with v3, the three "core" tree views in Zowe Explorer will use implementations of the FileSystemProvider to encapsulate remote operations (reading/writing, renaming, deleting, etc.):

Tree view FileSystemProvider implementation
Data Sets DatasetFSProvider
Jobs JobsFSProvider
Unix System Services (USS) UssFSProvider

We will no longer write files to the temporary, on-disk directory used in previous versions. All data is now managed in memory.

We have also exposed a BaseProvider class in Zowe Explorer API to help extenders create their own FileSystemProvider implementations if needed.
However, the implementations above are not directly accessible through Zowe Explorer API. Extenders should use the vscode.workspace.fs façade to access information instead.

File paths vs. URIs

The FileSystemProvider interface largely operates on the concept of resource URIs. Because our implementations leverage Zowe-specific resource URIs to build a path structure in memory, each segment is important when building a correct URI for a resource.

All core resource URIs for Zowe Explorer use this general structure:

zowe-*:/<Profile Name (LPAR)>/<Resource Path>

zowe-* refers to a scheme with the zowe- prefix. The core schemes are exposed in Zowe Explorer API as the ZoweScheme enum and are defined as the following:

  • Data Sets: zowe-ds
  • Jobs: zowe-jobs
  • USS: zowe-uss
Data Set URIs

For a sequential data set named FRUIT.CHKLIST on the food.zosmf LPAR, the URI would read as follows:

zowe-ds:/food.zosmf/FRUIT.CHKLIST

Partitioned data sets are interpreted as directories in the FileSystemProvider, and members are entries inside the directory.
For example, to represent the member APPLE in PDS FRUIT.BASKET on the food.zosmf LPAR, the URI would be:

zowe-ds:/food.zosmf/FRUIT.BASKET/APPLE
USS URIs

USS URIs use the format zowe-uss:/<Profile Name (LPAR)>/<USS Path> to represent files or folders.
A file at path /u/users/fruit/apple.txt on the food.zosmf LPAR would look like this:

zowe-uss:/food.zosmf/u/users/fruit/apple.txt

Its parent folder /u/users/fruit/ would look like this:

zowe-uss:/food.zosmf/u/users/fruit/
Job URIs

Job URIs use the format zowe-jobs:/<Profile Name (LPAR)>/<Job ID>/. Spool URIs use the format zowe-jobs:/<Profile Name (LPAR)>/<Job ID>/<Unique Spool ID>.

Extenders can leverage the buildUniqueSpoolName function in Zowe Explorer API to help build spool URIs. The Job ID segment matches the jobid parameter on the IJobFile object.

Coupling with tree nodes

When instantiating a VS Code TreeItem, each item can be paired with a resourceUri to establish a relationship between the URI and the tree node. We recommend that extenders pair their URIs alongside their tree nodes to establish a connection between the node and the resource, and to allow URI changes to propagate to the item in the tree view (such as when a URI is deleted from a provider).

With Zowe Explorer core resources, the URIs are generated and added to the FileSystemProvider as the user interacts with the tree view. However, extenders can create empty files and folders in the provider using writeFile and createDirectory as needed.

Operations for Extenders

Please note: These operations assume that the given resource URI exists in the FileSystemProvider. If the resource does not exist, an exception may be thrown - these should be caught and handled by your extension as needed.

Get contents of a USS file, Data Set, or spool file

To read the contents of a spool file, data set, or USS file, use the vscode.workspace.fs.readFile function.

  • Returns a Uint8Array with the contents of the resource

Get entries of a USS folder, PDS, or job

To list the contents of a USS directory, PDS, or job specified by a given URI, use the vscode.workspace.fs.readDirectory function.

  • Returns an array of tuples, where each tuple represents a child entry in the directory
  • For jobs, use this to return a list of spool files under a given job URI
  • For USS files, use this to a list of files and folders at the given path
  • For Data Sets, use this to get the members for a given PDS

Get resource statistics

To retrieve statistics for any resource URI, use the vscode.workspace.fs.stat function.

  • Returns a FileStat object containing metadata about the URI, such as its type, size, and timestamps
  • For USS files and Data Sets, this also contains e-tag and encoding information
  • For jobs, this contains the IJob or IJobFile object depending on the resource (job or spool)
Clone this wiki locally