From: daid303 Date: Wed, 3 Apr 2013 09:20:21 +0000 (+0200) Subject: Enhance the SD card list with more info. X-Git-Tag: 13.05~135 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=039c552b3674531a746c14d1c34bd2f13fd078e5;p=cura.git Enhance the SD card list with more info. --- diff --git a/Cura/util/removableStorage.py b/Cura/util/removableStorage.py index e020c7d5..57651450 100644 --- a/Cura/util/removableStorage.py +++ b/Cura/util/removableStorage.py @@ -8,19 +8,27 @@ def getPossibleSDcardDrives(): drives = [] if platform.system() == "Windows": from ctypes import windll + import ctypes bitmask = windll.kernel32.GetLogicalDrives() for letter in string.uppercase: if bitmask & 1 and windll.kernel32.GetDriveTypeA(letter + ':/') == 2: - drives.append(letter + ':/') + volumeName = '' + nameBuffer = ctypes.create_unicode_buffer(1024) + if windll.kernel32.GetVolumeInformationW(ctypes.c_wchar_p(letter + ':/'), nameBuffer, ctypes.sizeof(nameBuffer), None, None, None, None, 0) == 0: + volumeName = nameBuffer.value + if volumeName == '': + volumeName = 'NO NAME' + + drives.append(('%s (%s:)' % (volumeName, letter), letter + ':/', volumeName)) bitmask >>= 1 elif platform.system() == "Darwin": for volume in glob.glob('/Volumes/*'): if stat.S_ISLNK(os.lstat(volume).st_mode): continue #'Ejectable: Yes' in os.system('diskutil info \'%s\'' % (volume)) - drives.append(volume) + drives.append((os.path.basename(volume), os.path.basename(volume), volume)) else: for volume in glob.glob('/media/*'): - drives.append(volume) + drives.append((os.path.basename(volume), os.path.basename(volume), volume)) return drives