diff --git a/twander.py b/twander.py index e6cdcea..461cec0 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 2.83 2003/01/29 01:13:30 tundra Exp $" +RCSID = "$Id: twander.py,v 2.84 2003/01/29 17:45:38 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -340,11 +340,8 @@ (win32con.DRIVE_REMOVABLE, 'Removable')) # Size of each of the drive detail fields, including room for trailing space. - # Since the LABEL, FREE, and TOTAL fields can be filled with the UNAVAILABLE - # string, they must be at least that long (+1 for trailing space) - SZ_DRIVE_NAME = 4 - SZ_DRIVE_LABEL = 12 + SZ_DRIVE_LABEL = 14 # Must be wide enough to hold NODRIVE + 1 SZ_DRIVE_FREE = 13 # In this case there is no trailing space but a trailing '/' SZ_DRIVE_TTL = 13 # so we can have a 'free/total' presentation SZ_DRIVE_TYPE = 20 @@ -389,6 +386,7 @@ FILEGROUP = "group" FILEOWNER = "owner" +NODRIVE = "" SYMPTR = " -> " UNAVAILABLE = "Unavailable" WIN32GROUP = "win32" + FILEGROUP @@ -1623,9 +1621,9 @@ def KeyToggleWin32All(event): global WIN32ALLON - if USEWIN32ALL: + if USEWIN32ALL and (UI.CurrentDir != SHOWDRIVES): WIN32ALLON = not WIN32ALLON - RefreshDirList(event) + RefreshDirList(event) # End of 'KeyToggleWin32All()' @@ -2320,7 +2318,7 @@ # If details are off, just return the list of drives if not UI.DetailsOn: - UI.NameFirst = 0 + UI.NameFirst = 0 # Note where name actually begins return drivelist # We're returning detailed information about each drive @@ -2346,7 +2344,7 @@ entry = '\\\\' # Machine Hosting The Drive - if typestring == win32con.DRIVE_REMOTE: + if drivetype == win32con.DRIVE_REMOTE: name = WNetGetUniversalName(drive, 1).split('\\')[2].capitalize() else: name = WIN32HOST.capitalize() @@ -2357,7 +2355,7 @@ try: label = GetVolumeInformation(drive)[0] except: - label = UNAVAILABLE + label = NODRIVE entry += label + " " * ((SZ_DRIVE_HOST + SZ_DRIVE_LABEL) - len(entry + label)) @@ -2385,7 +2383,7 @@ # Save final result in detailed list details.append(entry) - UI.NameFirst = SZ_DRIVE_TOTAL + UI.NameFirst = SZ_DRIVE_TOTAL # Note where entry name actually begins return details # Get details on directory contents @@ -2520,17 +2518,31 @@ if WIN32ALL and USEWIN32ALL and WIN32ALLON: try: + # Get the internal Win32 security information for this file. ho = GetFileSecurity(fn, OWNER_SECURITY_INFORMATION) hg = GetFileSecurity(fn, GROUP_SECURITY_INFORMATION) sido = ho.GetSecurityDescriptorOwner() sidg = hg.GetSecurityDescriptorGroup() - owner = LookupAccountSid(WIN32HOST, sido)[0] - group = LookupAccountSid(WIN32HOST, sidg)[0] + + # We have to know who is hosting the filesytem for this file + + drive = fn[0:3] + if GetDriveType(drive) == win32con.DRIVE_REMOTE: + fnhost = WNetGetUniversalName(drive, 1).split('\\')[2] + else: + fnhost = WIN32HOST + + # Now we can translate the sids into names + + owner = LookupAccountSid(fnhost, sido)[0] + group = LookupAccountSid(fnhost, sidg)[0] + + # We assume the values are unavailable on any error except: owner = UNAVAILABLE group = UNAVAILABLE - # Default names for all other OSs + # Default names for all other OSs else: owner = OSNAME + FILEOWNER group = OSNAME + FILEGROUP @@ -2582,10 +2594,10 @@ detlist[index] += SYMPTR + f if UI.DetailsOn: - UI.NameFirst = ST_SZTOTAL + UI.NameFirst = ST_SZTOTAL # Note where name actually begins return detlist else: - UI.NameFirst = 0 + UI.NameFirst = 0 # Note where name actually begins return dList + fList # End of 'BuildDirList()'