X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/505d05e2f9845ec8a8d28fb27e493f6259d02bde..7aaa13924d6d60f6fb66a262ce6ecd8088aee9b6:/lib/python/Tools/Directories.py?ds=sidebyside diff --git a/lib/python/Tools/Directories.py b/lib/python/Tools/Directories.py index 982db6f0..1df24fcb 100644 --- a/lib/python/Tools/Directories.py +++ b/lib/python/Tools/Directories.py @@ -6,24 +6,34 @@ SCOPE_FONTS = 2 SCOPE_SKIN = 3 SCOPE_SKIN_IMAGE = 4 SCOPE_USERETC = 5 +SCOPE_CONFIG = 6 + +PATH_CREATE = 0 +PATH_DONTCREATE = 1 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. + 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. - return defaultPaths[scope] + base + return path[0] + base # 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: - 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