def _enumerateFiles(self, accept_object, vol_path, root_path, root_id): names = os.listdir(_path_join(vol_path, root_path)) names.sort() for name in names: full_path = _path_join(vol_path, _path_join(root_path, name)) try: st = os.stat(full_path) except OSError: print "Warning: Cannot stat " + full_path + " - will appear as empty file" st = Const.VIRTUAL_FILE_STAT arc_flag = Const.ARC_NONE is_sfx = 0 if self.recurseArchives and not stat.S_ISDIR(st[stat.ST_MODE]): if Archivers.getArchiver(name): arc_flag = Const.ARC_IS_ARCHIVE elif Archivers.isSFX(name, st): arc_flag = Const.ARC_IS_ARCHIVE is_sfx = 1 current_id = accept_object.accept(root_id, name, st, arc_flag, fullPath = full_path) if stat.S_ISDIR(st[stat.ST_MODE]): self._enumerateFiles(accept_object, vol_path, _path_join(root_path, name), current_id) elif arc_flag != Const.ARC_NONE: if is_sfx: arc_flag = Const._ARC_IS_SFX archive_enum = GenericCommandLineArchiver.GenericCommandLineArchiver(string.replace(root_path, "\\", "/") + "/" + name, full_path, current_id, arc_flag) if archive_enum.enumerateFiles(accept_object) == 0: accept_object.updateArchiveFlag(current_id, Const.ARC_NONE) archive_enum.close()
def enumerateFiles(self, accept_object): if self.arc_flag == Const._ARC_IS_SFX: numFiles = 0 for archiverType in diskat_config.archive_sfx_use_archivers: archiver = diskat_config.archiver_type[archiverType] f = os.popen(archiver["command"] % self.filename, "r") numFiles = self.parseListing(f, accept_object, archiver) if numFiles > 0: break return numFiles else: archiver = Archivers.getArchiver(self.filename) f = os.popen(archiver["command"] % self.filename, "r") return self.parseListing(f, accept_object, archiver)