Exemple #1
0
    def writeFiles(self,fileList,source,dest):
        utils.log("Writing files to: " + dest)
        self.filesTotal = len(fileList)
        self.filesLeft = self.filesTotal

        #write each file from source to destination
        for aFile in fileList:
            if(not self.checkCancel()):
                utils.log('Writing file: ' + source + aFile,xbmc.LOGDEBUG)
                self.updateProgress(aFile)
                if (aFile.startswith("-")):
                    vfs.mkdir(xbmc.makeLegalFilename(dest + aFile[1:],False))
                else:
                    vfs.copy(xbmc.makeLegalFilename(source + aFile),xbmc.makeLegalFilename(dest + aFile,False))
Exemple #2
0
    def move(cls, source, target):
        # Fail if target exists and is a file
        dst = unicode(target.path)
        src = unicode(source.path)
        try:
            target_file = isfile(dst)
        except UnicodeEncodeError:
            dst = dst.encode('utf-8')
            src = src.encode('utf-8')
            target_file = isfile(dst)
        if target_file:
            raise OSError, '[Errno 20] Not a directory'

        # If target is a folder, move inside it
        if isdir(dst):
            dst = target.path.resolve2(source.path[-1])
            dst = unicode(dst)

        try:
            rename(src, dst)
        except OSError:
            copy(src, dst)
            cls.remove(src)
Exemple #3
0
    def move(cls, source, target):
        # Fail if target exists and is a file
        dst = unicode(target.path)
        src = unicode(source.path)
        try:
            target_file = isfile(dst)
        except UnicodeEncodeError:
            dst = dst.encode('utf-8')
            src = src.encode('utf-8')
            target_file = isfile(dst)
        if target_file:
            raise OSError, '[Errno 20] Not a directory'

        # If target is a folder, move inside it
        if isdir(dst):
            dst = target.path.resolve2(source.path[-1])
            dst = unicode(dst)

        try:
            rename(src, dst)
        except OSError:
            copy(src, dst)
            cls.remove(src)