Powershell中有没有办法在其他文件系统中提供虚拟文件系统?

发布于 2024-07-27 12:03:01 字数 514 浏览 4 评论 0原文

我知道您可以为自定义 PSDrive 编写支持。 但它们始终是文件系统的根。 如果有一种方法允许 VFS 在文件系统的任意节点启动,例如使用 Set-Location 来输入存档文件并像文件夹一样使用它们,那就太好了。 (有点像 Far 这样做)。

有什么办法可以实现这一点吗? 我知道,要使其正确并发挥作用需要做一些工作,但目前我更感兴趣的是这是否可能。

预计到达时间: 我不知道我不想要为我输入的每个存档创建一个新的 PSDrive,因此以下内容实际上并不是我想要的:

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

而是

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

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> _

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不爱素颜 2024-08-03 12:03:01

您所描述的是一个文件系统提供程序,它也将档案视为容器对象。 由于 FileSystemProvider 是密封,我认为您必须编写自己的 NavigationCmdletProvider 发挥你的魔力。

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.

巡山小妖精 2024-08-03 12:03:01

您需要编写一个 provider这里是 SourceSafe 提供程序的示例(旧但仍然相关)

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

治碍 2024-08-03 12:03:01

当然。 事实上,您已经可以在某种程度上做到这一点,而无需编写任何管理单元代码。 例如:

New-PsDrive -Scope Global -Name MyMod -PSProvider FileSystem -Root (split-path $profile | join-path -child Modules)
dir MyMod:\

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:\
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文