private async lookupBlobContainer()

in src/AzureStorageFS.ts [397:438]


    private async lookupBlobContainer(uri: vscode.Uri, context: IActionContext, resourceId: string, filePath: string, endSearchEarly?: boolean): Promise<AzureStorageBlobTreeItem> {
        let treeItem: AzureStorageBlobTreeItem = <BlobContainerTreeItem>await this.lookupRoot(uri, context, resourceId);
        if (filePath === '') {
            return treeItem;
        }

        const pathToLook = filePath.split('/');
        let childCount: number = 0;
        for (const childName of pathToLook) {
            // Only allow blobs to be found on the last iteration of the loop.
            // Otherwise a blob with the same name as a directory will be found first leading to a file system error.
            childCount += 1;
            const allowBlobTreeItem: boolean = childCount === pathToLook.length;

            if (treeItem instanceof BlobTreeItem) {
                if (endSearchEarly) {
                    return treeItem;
                }
                throw getFileSystemError(uri, context, vscode.FileSystemError.FileNotFound);
            }

            const children: AzExtTreeItem[] = await treeItem.getCachedChildren(context);
            const child = children.find((element) => {
                if (element instanceof BlobTreeItem && allowBlobTreeItem) {
                    return element.blobName === childName;
                } else if (element instanceof BlobDirectoryTreeItem) {
                    return element.dirName === childName;
                }
                return false;
            });
            if (!child) {
                if (endSearchEarly) {
                    return treeItem;
                }
                throw getFileSystemError(uri, context, vscode.FileSystemError.FileNotFound);
            }

            treeItem = <BlobTreeItem | BlobDirectoryTreeItem>child;
        }

        return treeItem;
    }