Esempio n. 1
0
				f = Fs.factory(filePath)
				f.open(filePath, 'rb')
				dir = os.path.splitext(os.path.basename(filePath))[0]
				f.unpack(dir)
				f.close()

		if args.create:
			Print.info('creating ' + args.create)
			nsp = Fs.Nsp.Nsp(None, None)
			nsp.path = args.create
			nsp.pack(args.file)

		if args.C:
			for filePath in args.file:
				try:
					nut.compress(filePath, 17 if args.level is None else args.level, args.output)

				except BaseException as e:
					Print.error(str(e))
					raise




		if args.info:
			f = Fs.factory(args.info)
			f.open(args.info, 'r+b')

			f.printInfo(args.depth+1)

		if args.verify_ncas:
Esempio n. 2
0
    def move(self, forceNsp=False):
        if not self.path:
            Print.error('no path set')
            return False

        if os.path.abspath(self.path).startswith(
                os.path.abspath(Config.paths.nspOut)
        ) and not self.path.endswith('.nsz') and not self.path.endswith(
                '.xcz') and Config.compression.auto:
            nszFile = nut.compress(self.path, Config.compression.level,
                                   os.path.abspath(Config.paths.nspOut))

            if nszFile:
                nsp = Fs.Nsp(nszFile, None)
                nsp.hasValidTicket = True
                nsp.move(forceNsp=True)
                Nsps.files[nsp.path] = nsp
                Nsps.save()

        newPath = self.fileName(forceNsp=forceNsp)

        if not newPath:
            Print.error('could not get filename for ' + self.path)
            return False

        if os.path.abspath(newPath).lower().replace(
                '\\',
                '/') == os.path.abspath(self.path).lower().replace('\\', '/'):
            return False

        if os.path.isfile(newPath):
            Print.info('\nduplicate title: ')
            Print.info(os.path.abspath(self.path))
            Print.info(os.path.abspath(newPath))
            Print.info('\n')
            return False

        if not self.verifyNcaHeaders():
            Print.error('verification failed: could not move title for ' +
                        str(self.titleId) + ' or ' +
                        str(Title.getBaseId(self.titleId)))
            return False

        try:
            Print.info(self.path + ' -> ' + newPath)

            if not Config.dryRun:
                os.makedirs(os.path.dirname(newPath), exist_ok=True)
            #newPath = self.fileName(forceNsp = forceNsp)

            if not Config.dryRun:
                if self.isOpen():
                    self.close()
                shutil.move(self.path, newPath)

                if self.path in Nsps.files:
                    del Nsps.files[self.path]
                Nsps.files[newPath] = self
                self.path = newPath
        except BaseException as e:
            Print.error('failed to rename file! %s -> %s  : %s' %
                        (self.path, newPath, e))
            if not Config.dryRun:
                self.moveDupe()

        return True
Esempio n. 3
0
                f.unpack(dir)
                f.close()

        if args.create:
            Print.info('creating ' + args.create)
            nsp = Fs.Nsp.Nsp(None, None)
            nsp.path = args.create
            nsp.pack(args.file)

        if args.C:
            for i in args.file:
                for filePath in expandFiles(i):
                    try:
                        if filePath.endswith('.nsp'):
                            nut.compress(
                                filePath,
                                17 if args.level is None else args.level,
                                args.solid, args.bs, args.output, args.threads)

                    except BaseException as e:
                        Print.error(str(e))
                        raise

        if args.D:
            for i in args.file:
                for filePath in expandFiles(i):
                    try:
                        if filePath.endswith('.nsz'):
                            print("Decompress NSZ is currently disabled")
                            #nut.decompress(filePath, args.output)

                    except BaseException as e: