To use this function add it to the class library file named PluginVCDatastoreService.ts
GitHub Repository: https://github.com/SimonSparksUK/Orchestrator
Filename: PluginVCDatastoreService.ts
Description: The following script gets all files in a datastore
Public Function: GetAllVcFileInfo
public GetAllVcFileInfo(objVcDatastore: VcDatastore, arrVcFileQuery: VcFileQuery[], strFilePath: string = "/", strFileName?: string): VcFileInfo[] {
let objVcHostDatastoreBrowserSearchSpec: VcHostDatastoreBrowserSearchSpec = new VcHostDatastoreBrowserSearchSpec();
objVcHostDatastoreBrowserSearchSpec.details = this.VcFileQueryFlagsGet();
objVcHostDatastoreBrowserSearchSpec.query = arrVcFileQuery;
objVcHostDatastoreBrowserSearchSpec.searchCaseInsensitive = true;
objVcHostDatastoreBrowserSearchSpec.sortFoldersFirst = true;
if (strFileName !== "") {
objVcHostDatastoreBrowserSearchSpec.matchPattern = [strFileName];
}
let objVcHostDatastoreBrowser: VcHostDatastoreBrowser = objVcDatastore.browser;
let strDatastorePath: string = `[${objVcDatastore.name}] ${strFilePath}`;
let objVcTask: VcTask = objVcHostDatastoreBrowser.searchDatastoreSubFolders_Task(strDatastorePath, objVcHostDatastoreBrowserSearchSpec);
let arrVcHostDatastoreBrowserSearchResults: VcHostDatastoreBrowserSearchResults[] = this.WaitForVcTaskEnd(objVcTask, 2) as VcHostDatastoreBrowserSearchResults[];
let arrVcFileInfoReturn: VcFileInfo[] = [];
arrVcHostDatastoreBrowserSearchResults.forEach((objVcHostDatastoreBrowserSearchResults: VcHostDatastoreBrowserSearchResults): void => {
let arrVcFileInfo: VcFileInfo[] = objVcHostDatastoreBrowserSearchResults.file;
arrVcFileInfoReturn = arrVcFileInfoReturn.concat(arrVcFileInfo);
});
return arrVcFileInfoReturn;
}Private Function: VcFileQueryFlagsGet
private VcFileQueryFlagsGet(): VcFileQueryFlags {
let objVcFileQueryFlags: VcFileQueryFlags = new VcFileQueryFlags();
objVcFileQueryFlags.fileSize = true;
objVcFileQueryFlags.fileOwner = true;
objVcFileQueryFlags.modification = true;
objVcFileQueryFlags.fileType = true;
return objVcFileQueryFlags;
}TypeScriptDiscover more from Cloud Build Tools
Subscribe to get the latest posts sent to your email.

This was the only practical implementation of the searchDatastoreSubFolders_Task method that I could find. Thank you for this!!