pass
class EndOfFile(Exception):
"""Signal end of file condition when they’re not an error."""
+ pass
#---------------------------
# internal stream interface
# support functionality for rescue mode
#---------------------------------------------------------
+def locate_tar_hdr_candidates (fd):
+ raise NotImplementedError ("too soon")
+
+
+def readable_tar_objects_offsets (ifd, cands):
+ raise NotImplementedError ("too soon")
+
+
def locate_gz_hdr_candidates (fd):
"""
Walk over instances of the GZ magic in the payload, collecting their
os.close (ifd)
+def reconstruct_offsets_tar (fname):
+ """
+ From the given file, retrieve all tar header-like offsets (“candidates”).
+ Then check each of those locations whether they can be processed as tar
+ data.
+ """
+ ifd = os.open (fname, os.O_RDONLY)
+
+ try:
+ cands = locate_tar_hdr_candidates (ifd)
+ return readable_tar_objects_offsets (ifd, cands)
+ finally:
+ os.close (ifd)
+
+
def read_tarobj_at_offset (fileobj, offset, mode, secret=None):
decr = None
offsets = crypto.reconstruct_offsets (backup_tar_path, secret)
elif mode == "#gz":
offsets = reconstruct_offsets_gz (backup_tar_path)
+ elif mode == "#":
+ offsets = reconstruct_offsets_tar (backup_tar_path)
+ else:
+ raise TarError ("no rescue handling for mode “%s”" % mode)
fileobj = bltn_open (backup_tar_path, "rb")
infos = [ (off, read_tarobj_at_offset (fileobj, off, mode, secret=secret))