View Full Version : UNC Path conversion
Rob H
January 30th, 2005, 10:48 AM
Is there any way in LUA to take a file path e.g. "E:\Video\Movies\Ripped\Gangs of New York.ISO" and turn it into a valid UNC path e.g. "\\BUFFY\Movies\Ripped\Gangs of New York.ISO"? (E:\Video\Movies is shared as \\BUFFY\Movies)
Promixis
January 30th, 2005, 11:54 AM
hm... will the filesystemobject do this?
Rob H
January 30th, 2005, 12:34 PM
Not as far as I can see, no :(
There is a function to do this - WNetGetUniversalName but I don't know of a plugin that exposes it.
Promixis
January 30th, 2005, 12:52 PM
uggh, that function is a bear to implement...
Rob H
January 30th, 2005, 12:55 PM
Why's that?
Promixis
January 31st, 2005, 11:25 AM
i gave it a quick try and the function was returning error messages. look on the net and you will see lots of people having problems with it.
Northernmost
January 31st, 2005, 01:22 PM
Is there any way in LUA to take a file path e.g. "E:\Video\Movies\Ripped\Gangs of New York.ISO" and turn it into a valid UNC path e.g. "\\BUFFY\Movies\Ripped\Gangs of New York.ISO"? (E:\Video\Movies is shared as \\BUFFY\Movies)
If the file path is "E:\Video\Movies\Ripped\Gangs of New York.ISO" could that not just be translated in to "\\ComputerName\e$\Video\Movies\Ripped\Gangs of New York.ISO"?
I've seen a GetComputerName() function somewhere (WinLUAEx perhaps) so it should be relatively easy to replace the drive with the UNC equivalent i.e. changing "E:" to "\\ComputerName\E$". This is assuming your Girder is on the same machine as the file of course. Hmmm... I also think [read: don't know] but the PC or PPC your trying to access the file from would need to have access to the admin shares on the machine hosting the file.
My 2p
Rob H
January 31st, 2005, 03:12 PM
That's a possibility, it would be easy enough to transform the e: to \\computername\e$ - although I'm not keen on exposing the whole disk like that.
Another possibility would be to have a configuration parameter to indicate prefixes and transforms. Even better would be to be able to list all the shares and what they map to so the transforms could be built automatically.
It's possible that WMI could provide this list, but I'm damned if I can work out how!
Northernmost
January 31st, 2005, 03:36 PM
That's a possibility, it would be easy enough to transform the e: to \\computername\e$ - although I'm not keen on exposing the whole disk like that.
All disks have the admin share enabled by default I think, and, if memory serves, XP chucks a wobbler if you try and disable it. I've just tryed to disable an admn share and XP is telling me that it will be automatically re-shared the next time the computer reboots
:P :evil:
It's possible that WMI could provide this list, but I'm damned if I can work out how!
I'm with you there! I've briefly played with WMI before... and it was no fun at all.
I've not even looked at the code but there's a C# demo at CodeProject (http://www.thecodeproject.com/csharp/networkshares.asp):
Two common requirements seem to have been missed from the .NET framework: enumerating network shares, and converting a local path to a UNC path. The shares could potentially be retrieved via WMI, but you can't guarantee that NT4 and 98 will have it installed. These classes provide a simple wrapper around the API calls necessary to retrieve this information.
So the above could be compiled with COM support and used from luacom... perhaps. Like I said - I haven't even looked at the code :wink:
Rob H
January 31st, 2005, 03:47 PM
I tried accessing a file via the admin share but I don't have the relevant privileges.
Thanks for the link - I'll take a closer look tomorrow.
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.