[python-win32] detect mapped network path

Paul Moore p.f.moore at gmail.com
Fri Jul 1 17:28:28 CEST 2005


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

works, in that case...?

Paul.


More information about the Python-win32 mailing list