diff --git a/bunker/files/tarfile.py b/bunker/files/tarfile.py index ffa5d36..5afdd71 100644 --- a/bunker/files/tarfile.py +++ b/bunker/files/tarfile.py @@ -98,3 +98,16 @@ class RewriteableTarFile(object): new_handle.addfile(member, handle.extractfile(member)) new_handle.close() + def has_file(self, member): + if(isinstance(member, tarfile.TarInfo)): + member_name = member.name + elif(isinstance(member, str)): + member_name = member + else: + raise TypeError("member must be TarInfo or str, not {}".format(type(member))) + + handle = self._open_handle() + + return member_name in handle.getnames() + +