fix encoding
[enigma2.git] / lib / python / Tools / Directories.py
index d6ffeeea65f96eb43fb155b0d47c268aac6d574e..adf7afd06c25198c81d2c023914cca5606a1c413 100644 (file)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import os
 
 SCOPE_TRANSPONDERDATA = 0
@@ -42,10 +43,14 @@ fallbackPaths = {
                SCOPE_HDD: [("/hdd/movies", PATH_MOVE)]
        }
 
-def resolveFilename(scope, base = ""):
+def resolveFilename(scope, base = "", path_prefix = None):
+       if base[0:2] == "~/":
+               # you can only use the ~/ if we have a prefix directory
+               assert path_prefix is not None
+               base = os.path.join(path_prefix, base[2:])
 
        # don't resolve absolute paths
-       if len(base) and base[0] == '/':
+       if base[0:1] == '/':
                return base
 
        path = defaultPaths[scope]
@@ -89,6 +94,15 @@ def resolveFilename(scope, base = ""):
 def pathExists(path):
        return os.path.exists(path)
 
+def createDir(path):
+       try:
+               os.mkdir(path)
+       except:
+               ret = 0
+       else:
+               ret = 1
+       return ret
+
 def fileExists(f):
        try:
                file = open(f)
@@ -100,7 +114,7 @@ def fileExists(f):
 
 def getRecordingFilename(basename):
                # filter out non-allowed characters
-       non_allowed_characters = "/.\\"
+       non_allowed_characters = "/.\\:*?<>|\""
        filename = ""
        
        basename = basename.replace('\xc2\x86', '').replace('\xc2\x87', '')
@@ -125,3 +139,5 @@ def getRecordingFilename(basename):
 def InitFallbackFiles():
        resolveFilename(SCOPE_CONFIG, "userbouquet.favourites.tv")
        resolveFilename(SCOPE_CONFIG, "bouquets.tv")
+       resolveFilename(SCOPE_CONFIG, "userbouquet.favourites.radio")
+       resolveFilename(SCOPE_CONFIG, "bouquets.radio")