def _do_import(self, fn): sf = ps2save.ps2_save_file() f = file(fn, "rb") try: ft = ps2save.detect_file_type(f) f.seek(0) if ft == "max": sf.load_max_drive(f) elif ft == "psu": sf.load_ems(f) elif ft == "psv": sf.load_psv(f) elif ft == "cbs": sf.load_codebreaker(f) elif ft == "sps": sf.load_sharkport(f) elif ft == "npo": self.error_box(fn + ": nPort saves" " are not supported.") return else: self.error_box(fn + ": Save file format not" " recognized.") return finally: f.close() if not self.mc.import_save_file(sf, True): self.error_box(fn + ": Save file already present.")
def _do_import(self, fn): sf = ps2save.ps2_save_file() f = file(fn, "rb") try: ft = ps2save.detect_file_type(f) f.seek(0) if ft == "max": sf.load_max_drive(f) elif ft == "psu": sf.load_ems(f) elif ft == "cbs": sf.load_codebreaker(f) elif ft == "sps": sf.load_sharkport(f) elif ft == "npo": self.error_box(fn + ": nPort saves" " are not supported.") return else: self.error_box(fn + ": Save file format not" " recognized.") return finally: f.close() if not self.mc.import_save_file(sf, True): self.error_box(fn + ": Save file already present.")
def do_import(cmd, mc, opts, args, opterr): if len(args) < 1: opterr("Filename required.") args = glob_args(args, glob) if opts.directory != None and len(args) > 1: opterr("The -d option can only be used with a" "single savefile.") for filename in args: sf = ps2save.ps2_save_file() f = file(filename, "rb") try: ftype = ps2save.detect_file_type(f) f.seek(0) if ftype == "max": sf.load_max_drive(f) elif ftype == "psu": sf.load_ems(f) elif ftype == "psv": sf.load_psv(f) elif ftype == "cbs": sf.load_codebreaker(f) elif ftype == "sps": sf.load_sharkport(f) elif ftype == "npo": raise io_error, (EIO, "nPort saves" " are not supported.", filename) else: raise io_error, (EIO, "Save file format not" " recognized", filename) finally: f.close() dirname = opts.directory if dirname == None: dirname = sf.get_directory()[8] print "Importing", filename, "to", dirname if not mc.import_save_file(sf, opts.ignore_existing, opts.directory): print (filename + ": already in memory card image," " ignored.")
def export_save_file(self, filename): (dir_dirloc, dirent, is_dir) = self.path_search(filename) if dir_dirloc == None: raise path_not_found, filename if dirent == None: raise dir_not_found, filename if not is_dir: raise io_error, (ENOTDIR, "not a directory", filename) if dir_dirloc == (0, 0): raise io_error, (EACCES, "can't export root directory", filename) sf = ps2save.ps2_save_file() files = [] f = None dir = self._directory(dir_dirloc, dirent[4], dirent[2], "rb", filename) try: for i in range(2, dirent[2]): ent = dir[i] if not mode_is_file(ent[0]): print ("warning: %s/%s is not a file," " ingored." % (dirent[8], ent[8])) continue f = self.file((dirent[4], i), ent[4], ent[2], "rb") data = f.read(ent[2]) f.close() assert len(data) == ent[2] files.append((ent, data)) finally: if f != None: f.close() dir.close() dirent[2] = len(files) sf.set_directory(dirent) for (i, (ent, data)) in enumerate(files): sf.set_file(i, ent, data) return sf
def do_import(cmd, mc, opts, args, opterr): if len(args) < 1: opterr("Filename required.") args = glob_args(args, glob) if opts.directory != None and len(args) > 1: opterr("The -d option can only be used with a" "single savefile.") for filename in args: sf = ps2save.ps2_save_file() f = file(filename, "rb") try: ftype = ps2save.detect_file_type(f) f.seek(0) if ftype == "max": sf.load_max_drive(f) elif ftype == "psu": sf.load_ems(f) elif ftype == "psv": sf.load_psv(f) elif ftype == "cbs": sf.load_codebreaker(f) elif ftype == "sps": sf.load_sharkport(f) elif ftype == "npo": raise io_error, (EIO, "nPort saves" " are not supported.", filename) else: raise io_error, (EIO, "Save file format not" " recognized", filename) finally: f.close() dirname = opts.directory if dirname == None: dirname = sf.get_directory()[8] print "Importing", filename, "to", dirname if not mc.import_save_file(sf, opts.ignore_existing, opts.directory): print(filename + ": already in memory card image," " ignored.")