add 'progress' source, 'progress to text' converter
[enigma2.git] / lib / python / Components / FileList.py
index d842cfefbe353de786cdb353f0bff09a3b0fbdf9..bba846f6abe0bb4f3940dd1db5bef16a79c12ae2 100644 (file)
@@ -42,8 +42,9 @@ def FileEntryComponent(name, absolute = None, isDir = False):
        return res
 
 class FileList(MenuList):
-       def __init__(self, directory, showDirectories = True, showFiles = True, matchingPattern = None, useServiceRef = False, isTop = False, enableWrapAround = False):
+       def __init__(self, directory, showDirectories = True, showFiles = True, matchingPattern = None, useServiceRef = False, isTop = False, enableWrapAround = False, additionalExtensions = None):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
+               self.additional_extensions = additionalExtensions
                self.mount_point = None
                self.current_directory = None
                self.useServiceRef = useServiceRef
@@ -78,7 +79,20 @@ class FileList(MenuList):
 
                # if we are just entering from the list of mount points:
                if self.current_directory is None:
-                       self.mount_point = directory
+                       if directory is None:
+                               self.mount_point = None
+                       else:
+                               # Sort Mountpoints by length (longest first)
+                               sortedp = harddiskmanager.getMountedPartitions()
+                               sortedp.sort(key=lambda p: 0 - len(p.mountpoint))
+
+                               # Search for the longest matching mp (should at least match /)
+                               for p in sortedp:
+                                       if directory.startswith(p.mountpoint):
+                                               self.mount_point = p.mountpoint
+                                               if p.mountpoint != "/":
+                                                       self.mount_point += "/"
+                                               break
                self.current_directory = directory
                directories = []
                files = []
@@ -94,6 +108,8 @@ class FileList(MenuList):
                        directories = [ ]
                elif self.useServiceRef:
                        root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory)
+                       if self.additional_extensions:
+                               root.setName(self.additional_extensions)
                        serviceHandler = eServiceCenter.getInstance()
                        list = serviceHandler.list(root)