the long awaited feature "blinking label" is now available
[enigma2.git] / lib / python / Tools / Directories.py
index 982db6f07940e90296b6efed76af900ce2d643bb..1df24fcb08f16077a8795f9c4f3001fab5d184d8 100644 (file)
@@ -6,24 +6,34 @@ SCOPE_FONTS = 2
 SCOPE_SKIN = 3
 SCOPE_SKIN_IMAGE = 4
 SCOPE_USERETC = 5
 SCOPE_SKIN = 3
 SCOPE_SKIN_IMAGE = 4
 SCOPE_USERETC = 5
+SCOPE_CONFIG = 6
+
+PATH_CREATE = 0
+PATH_DONTCREATE = 1
 
 defaultPaths = {
 
 defaultPaths = {
-               SCOPE_TRANSPONDERDATA: "/etc/",
-               SCOPE_SYSETC: "/etc/",
-               SCOPE_FONTS: "/usr/share/fonts/",
+               SCOPE_TRANSPONDERDATA: ("/etc/", PATH_DONTCREATE),
+               SCOPE_SYSETC: ("/etc/", PATH_DONTCREATE),
+               SCOPE_FONTS: ("/usr/share/fonts/", PATH_DONTCREATE),
+               SCOPE_CONFIG: ("/etc/enigma2/", PATH_CREATE),
 
 
-               SCOPE_SKIN: "/usr/share/tuxbox/enigma2/",
-               SCOPE_SKIN_IMAGE: "/usr/share/tuxbox/enigma2/",
+               SCOPE_SKIN: ("/usr/share/tuxbox/enigma2/", PATH_DONTCREATE),
+               SCOPE_SKIN_IMAGE: ("/usr/share/tuxbox/enigma2/", PATH_DONTCREATE),
                
                
-               SCOPE_USERETC: "" # user home directory
+               SCOPE_USERETC: ("", PATH_DONTCREATE) # user home directory
        }
 
 def resolveFilename(scope, base):
        # in future, we would check for file existence here,
        # so we can provide default/fallbacks.
        
        }
 
 def resolveFilename(scope, base):
        # in future, we would check for file existence here,
        # so we can provide default/fallbacks.
        
+       path = defaultPaths[scope]
+       if path[1] == PATH_CREATE:
+               if (not os.path.exists(path[0])):
+                       os.mkdir(path[0])
+       
        # FIXME: we also have to handle DATADIR etc. here.
        # FIXME: we also have to handle DATADIR etc. here.
-       return defaultPaths[scope] + base
+       return path[0] + base
 
        # this is only the BASE - an extension must be added later.
 def getRecordingFilename(basename):
 
        # this is only the BASE - an extension must be added later.
 def getRecordingFilename(basename):
@@ -41,8 +51,9 @@ def getRecordingFilename(basename):
        while True:
                path = "/hdd/movies/" + filename
                if i > 0:
        while True:
                path = "/hdd/movies/" + filename
                if i > 0:
-                       path += str(i)
-#              if os.glob(path + "*").size() == 0:
-#                      return path
-               return path
-               i+=1
+                       path += "_%03d" % i
+               try:
+                       open(path + ".ts")
+                       i += 1
+               except IOError:
+                       return path