Skip to content

Commit 3bdee1b

Browse files
committed
Partial merge of pull request #121 from inochisa/add-recursive
2 parents cbc7e0a + 24ef28c commit 3bdee1b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

libarchive/write.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ def add_entries(self, entries):
4444
write_finish_entry(write_p)
4545

4646
def add_files(
47-
self, *paths, flags=0, lookup=False, pathname=None, **attributes
47+
self, *paths, flags=0, lookup=False, pathname=None, recursive=True,
48+
**attributes
4849
):
4950
"""Read files through the OS and add them to the archive.
5051
@@ -58,6 +59,9 @@ def add_files(
5859
is called to enable the lookup of user and group names
5960
pathname (str | None):
6061
the path of the file in the archive, defaults to the source path
62+
recursive (bool):
63+
when False, if a path in `paths` is a directory,
64+
only the directory itself is added.
6165
attributes (dict): passed to `ArchiveEntry.modify()`
6266
6367
Raises:
@@ -103,6 +107,8 @@ def add_files(
103107
write_data(write_p, data, len(data))
104108
write_finish_entry(write_p)
105109
entry_clear(entry_p)
110+
if not recursive:
111+
break
106112

107113
def add_file(self, path, **kw):
108114
"Single-path alias of `add_files()`"

0 commit comments

Comments
 (0)