On Nov 19, 7:43 am, "Staffan Gustafsson"
<staffan_no_spam_.e.gustafs...@xxxxxx> wrote:
> Hi All,
>
> I'm writing a DeviceFilesystem provider, that is using RAPI to expose a
> device connected via ActiveSync as a Powershell drive.
>
> I'm having trouble figuring out the best way to handle copies from the
> device to the pc and vice versa.
>
> Is there a standard way to do this?
>
> Say for example I'd like to do the following:
>
> Copy a file log.txt from \storagecard\ on the device to a folder c:\logs on
> the PC.
>
> 1. Should I write my provider with some heuristics to find out if the path
> is located on the PC or on the device?
> ie: Copy-Item -path: \StorageCard\log.txt -destination:
> C:\Logs\log.txt
> 2. Should I demand that all PC paths are qualified with the provider
> (Microsoft.PowerShell.Core\FileSystem:
?
> ie: Copy-Item -path:
> DeviceUtil\DeviceFileSystem::StorageCard\log.txt -destination:
> Microsoft.PowerShell.Core\FileSystem::C:\Logs\log.txt
> 3. Is there any way to get the above Copy-Item example to work if my
> current location is not in the DeviceFileSystem provider?
> PS C:\ > Copy-Item -path:
> DeviceUtil\DeviceFileSystem::StorageCard\log.txt -destination:
> Microsoft.PowerShell.Core\FileSystem::C:\Logs\log.txt
>
> Thx,
>
> Staffan Hi Staffan,
Unfortunately cross-provider copying is not possible in PowerShell
v1.0 using the stock *-item cmdlets; nor have I heard any twittering
from the big house regarding its arrival in 2.0 either. It's early
days though. Speaking of, many moons ago during (very) early betas of
Monad/PowerShell I was in your position and had opportunity to ask
someone on the posh team about this and iirc, I was told that many
ideas about how to do it were thrown about internally but nothing
really worked well enough to warrant the time and effort on it, and it
was placed on the "argh!" list.
The only two interfaces that provide data reading and data writing
that are common to providers are IContentReader and IContentWriter,
which are obtained for reading and writing to/from items in a provider
that implements IContentCmdletProvider. While it looks nice in theory,
in practice I've found it to be a pain; I found myself wishing for a
IContentStreamReader / IContentStreamWriter that would let you expose
Streams instead, since often you're manipulating one under the covers
anyway; Streams come with their own baggage too I guess though, in the
sense that you're forced to implement quite a number of members, some
of which may or may not make sense for you (async read/write for
example).
So ultimately, you might think of creating some cross-provider cmdlets
specialising in "connecting" the ContentReader and ContentWriter ends
of two provider paths; I know I did, but some initial tests proved it
to be prohibitively slow. I suspect this is what the Posh team found
too, and decided it would be too damaging to the perception of posh's
speed -- already a thorny point as it is -- and instead choosing to
push it for v2 (we hope).
- Oisin / x0n
p.s. how are you finding that RAPI stuff? painful, isn't it? I have a
very similar project in flux up on codeplex at the moment:
www.codeplex.com/psmobile - perhaps we could join forces?