do not allow colon in filenames
[enigma2.git] / lib / python / Tools / Directories.py
index 7c8931592adf505eb0e9ce62d54ad09d29ad02b1..2156a9beba292a3ff54e96ee2373d2196abb02c2 100644 (file)
@@ -1,5 +1,4 @@
 import os
-from re import *
 
 SCOPE_TRANSPONDERDATA = 0
 SCOPE_SYSETC = 1
@@ -10,6 +9,8 @@ SCOPE_USERETC = 5
 SCOPE_CONFIG = 6
 SCOPE_LANGUAGE = 7
 SCOPE_HDD = 8
+SCOPE_PLUGINS = 9
+SCOPE_MEDIA = 10
 
 PATH_CREATE = 0
 PATH_DONTCREATE = 1
@@ -19,12 +20,14 @@ defaultPaths = {
                SCOPE_SYSETC: ("/etc/", PATH_DONTCREATE),
                SCOPE_FONTS: ("/usr/share/fonts/", PATH_DONTCREATE),
                SCOPE_CONFIG: ("/etc/enigma2/", PATH_CREATE),
+               SCOPE_PLUGINS: ("/usr/lib/enigma2/python/Plugins/", PATH_CREATE),
                                            
                SCOPE_LANGUAGE: ("/usr/share/enigma2/po/", PATH_CREATE),
 
                SCOPE_SKIN: ("/usr/share/enigma2/", PATH_DONTCREATE),
                SCOPE_SKIN_IMAGE: ("/usr/share/enigma2/", PATH_DONTCREATE),
                SCOPE_HDD: ("/hdd/movie/", PATH_DONTCREATE),
+               SCOPE_MEDIA: ("/media/", PATH_DONTCREATE),
                
                SCOPE_USERETC: ("", PATH_DONTCREATE) # user home directory
        }
@@ -40,11 +43,19 @@ fallbackPaths = {
        }
 
 def resolveFilename(scope, base = ""):
+
+       # don't resolve absolute paths
+       if len(base) and base[0] == '/':
+               return base
+
        path = defaultPaths[scope]
 
        if path[1] == PATH_CREATE:
                if (not pathExists(defaultPaths[scope][0])):
                        os.mkdir(path[0])
+                       
+       #if len(base) > 0 and base[0] == '/':
+               #path = ("", None)
        
        if not fileExists(path[0] + base):
                #try:
@@ -89,13 +100,10 @@ def fileExists(f):
 
 def getRecordingFilename(basename):
                # filter out non-allowed characters
-       non_allowed_characters = "/.\\"
+       non_allowed_characters = "/.\\:"
        filename = ""
        
-       re = compile('\xc2\x86')
-       basename = re.sub('', basename)
-       re = compile('\xc2\x87')
-       basename = re.sub('', basename)
+       basename = basename.replace('\xc2\x86', '').replace('\xc2\x87', '')
        
        for c in basename:
                if c in non_allowed_characters: