Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.
(self)
| 2092 | # The public methods which TarFile provides: |
| 2093 | |
| 2094 | def close(self): |
| 2095 | """Close the TarFile. In write-mode, two finishing zero blocks are |
| 2096 | appended to the archive. |
| 2097 | """ |
| 2098 | if self.closed: |
| 2099 | return |
| 2100 | |
| 2101 | self.closed = True |
| 2102 | try: |
| 2103 | if self.mode in ("a", "w", "x"): |
| 2104 | self.fileobj.write(NUL * (BLOCKSIZE * 2)) |
| 2105 | self.offset += (BLOCKSIZE * 2) |
| 2106 | # fill up the end with zero-blocks |
| 2107 | # (like option -b20 for tar does) |
| 2108 | blocks, remainder = divmod(self.offset, RECORDSIZE) |
| 2109 | if remainder > 0: |
| 2110 | self.fileobj.write(NUL * (RECORDSIZE - remainder)) |
| 2111 | finally: |
| 2112 | if not self._extfileobj: |
| 2113 | self.fileobj.close() |
| 2114 | |
| 2115 | def getmember(self, name): |
| 2116 | """Return a TarInfo object for member 'name'. If 'name' can not be |