2

I know you can write support for custom PSDrives. But those are always a root of a file system. What would be nice if there was a way to allow for VFS start at arbitrary nodes of the file system, such as using Set-Location to enter archive file maybe and use them as if they were folders. (Kinda like Far does this).

Is there any way to achieve this? I know, it would be some work to get it right and working, but at the moment I am more interested whether it would be possible at all.

ETA: What I don't want is a new PSDrive for every archive I enter, so the following isn't actually what I'm after:

PS C:\Path> Invoke-Magic stuff.zip
PS C:\Path> Set-Location MyNewDrive:
PS MyNewDrive:> _

but rather

PS C:\Path> Set-Location stuff.zip
PS C:\Path\stuff.zip> _
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
Joey
  • 344,408
  • 85
  • 689
  • 683

3 Answers3

3

What you're describing is a FileSystem provider that also considers archives to be container objects. As FileSystemProvider is sealed, I think you would have to write your own NavigationCmdletProvider that does your magic.

dahlbyk
  • 75,175
  • 8
  • 100
  • 122
1

You need to write a provider, here is an example for a provider for SourceSafe (old but still relevant)

Shay Erlichmen
  • 31,691
  • 7
  • 68
  • 87
  • The second link is dead, not archived in the Wayback-Machine, and searching for "MSHVSSProvider" doesn't yield any results that it could have been moved to. – leumasme Apr 13 '23 at 17:29
0

Sure. In fact, you can already do this to some degree without writing any snap-in code. For example:

New-PsDrive -Scope Global -Name MyMod -PSProvider FileSystem -Root (split-path $profile | join-path -child Modules)
dir MyMod:\
Richard Berg
  • 20,629
  • 2
  • 66
  • 86