[python-win32] detect mapped network path

Simon Dahlbacka simon.dahlbacka at gmail.com
Mon Jul 4 07:49:28 CEST 2005


On 7/1/05, Paul Moore <p.f.moore at gmail.com> wrote:
> On 7/1/05, Simon Dahlbacka <simon.dahlbacka at gmail.com> wrote:
> > On 7/1/05, Mark Hammond <mhammond at skippinet.com.au> wrote:
> > > > ..but how do i find out if let's say X:\foo\bar\blarg.baz is a local
> > > > path or in fact a mapped network path?
> > >
> > > win32api.GetLogicalDriveStrings() may also help.
> >
> > I was going to say that it does not help, but then I found
> > win32file.GetDriveType
> >
> > so for future reference, here is a solution that WorksForMe(tm)
> >
> > >>> def IsMappedDrive(name):
> > ...     allDrives = win32api.GetLogicalDriveStrings().split("\x00")
> > ...     return name.upper() in [drive for drive in allDrives if
> > win32file.GetDriveType(drive) == win32file.DRIVE_REMOTE]
> >
> > >>> IsMappedDrive("z:\\")
> > True
> > >>> IsMappedDrive("c:\\")
> > False
> 
> Um, surely
> 
>     def IsMappedDrive(name):
>         return win32file.GetDriveType(name) == win32file.DRIVE_REMOTE
> 
hmm.. well yes, (apart from the fact that GetDriveType expects just
<letter>:\ )
I guess I should think before posting examples next time ;)

/Simon


More information about the Python-win32 mailing list