def _make_file_info(fs, path, info): file_info = {} file_info["filename"] = path file_info["emptystream"] = empty = info.is_dir or info.size == 0 file_info["origin"] = None if empty else _Origin(fs, path) created = info.get("details", "created") if created is not None: file_info["creationtime"] = ArchiveTimestamp.from_datetime(created) modified = info.get("details", "modified") if modified is not None: file_info["lastwritetime"] = ArchiveTimestamp.from_datetime( modified) accessed = info.get("details", "accessed") if created is not None: file_info["lastaccesstime"] = ArchiveTimestamp.from_datetime( accessed) if info.is_dir: file_info["attributes"] = stat.FILE_ATTRIBUTE_DIRECTORY file_info["attributes"] |= FILE_ATTRIBUTE_UNIX_EXTENSION file_info["attributes"] |= stat.S_IFDIR << 16 else: file_info["attributes"] = stat.FILE_ATTRIBUTE_ARCHIVE file_info["attributes"] |= FILE_ATTRIBUTE_UNIX_EXTENSION file_info["uncompressed"] = info.size permissions = info.get("access", "permissions") if permissions is not None: file_info["attributes"] |= Permissions.load(permissions).mode << 16 return file_info
def _write_times(self, fp: BinaryIO, propid, name: str) -> None: write_byte(fp, propid) defined = [] # type: List[bool] num_defined = 0 # type: int for f in self.files: if name in f.keys(): if f[name] is not None: defined.append(True) num_defined += 1 size = num_defined * 8 + 2 if not reduce(and_, defined): size += bits_to_bytes(num_defined) write_uint64(fp, size) write_boolean(fp, defined, all_defined=True) write_byte(fp, b'\x00') for i, file in enumerate(self.files): if defined[i]: write_real_uint64(fp, ArchiveTimestamp.from_datetime(file[name])) else: pass