diff --git a/libarchive/entry.py b/libarchive/entry.py index 20f1adb..70701ef 100644 --- a/libarchive/entry.py +++ b/libarchive/entry.py @@ -433,10 +433,6 @@ def rdevminor(self): def rdevminor(self, value): ffi.entry_set_rdevminor(self._entry_p, value) - @property - def format_name(self): - return ffi.format_name(self._pointer) - class ConsumedArchiveEntry(ArchiveEntry): diff --git a/libarchive/read.py b/libarchive/read.py index fd18667..3451376 100644 --- a/libarchive/read.py +++ b/libarchive/read.py @@ -39,6 +39,10 @@ def filter_names(self): count = ffi.filter_count(self._pointer) return [ffi.filter_name(self._pointer, i) for i in range(count - 1)] + @property + def format_name(self): + return ffi.format_name(self._pointer) + @contextmanager def new_archive_read(format_name='all', filter_name='all', passphrase=None): diff --git a/tests/test_rwx.py b/tests/test_rwx.py index 5daf201..77c16fc 100644 --- a/tests/test_rwx.py +++ b/tests/test_rwx.py @@ -26,6 +26,8 @@ def test_buffers(tmpdir): # Read the archive and check that the data is correct with libarchive.memory_reader(buf) as archive: check_archive(archive, tree) + assert archive.format_name == b'GNU tar format' + assert archive.filter_names == [b'xz'] # Extract the archive in tmpdir and check that the data is intact with in_dir(tmpdir.strpath): @@ -50,6 +52,8 @@ def test_fd(tmpdir): archive_file.seek(0) with libarchive.fd_reader(fd) as archive: check_archive(archive, tree) + assert archive.format_name == b'GNU tar format' + assert archive.filter_names == [b'bzip2'] # Extract the archive in tmpdir and check that the data is intact archive_file.seek(0) @@ -73,6 +77,8 @@ def test_files(tmpdir): # Read the archive and check that the data is correct with libarchive.file_reader(archive_path) as archive: check_archive(archive, tree) + assert archive.format_name == b'POSIX ustar format' + assert archive.filter_names == [b'gzip'] # Extract the archive in tmpdir and check that the data is intact with in_dir(tmpdir.strpath): @@ -95,6 +101,8 @@ def test_custom_writer_and_stream_reader(): # Read the archive and check that the data is correct with libarchive.stream_reader(stream, 'zip') as archive: check_archive(archive, tree) + assert archive.format_name == b'ZIP 2.0 (deflation)' + assert archive.filter_names == [] @patch('libarchive.ffi.write_fail')