Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.
(self)
| 2111 | # The public methods which TarFile provides: |
| 2112 | |
| 2113 | def close(self): |
| 2114 | """Close the TarFile. In write-mode, two finishing zero blocks are |
| 2115 | appended to the archive. |
| 2116 | """ |
| 2117 | if self.closed: |
| 2118 | return |
| 2119 | |
| 2120 | self.closed = True |
| 2121 | try: |
| 2122 | if self.mode in ("a", "w", "x"): |
| 2123 | self.fileobj.write(NUL * (BLOCKSIZE * 2)) |
| 2124 | self.offset += (BLOCKSIZE * 2) |
| 2125 | # fill up the end with zero-blocks |
| 2126 | # (like option -b20 for tar does) |
| 2127 | blocks, remainder = divmod(self.offset, RECORDSIZE) |
| 2128 | if remainder > 0: |
| 2129 | self.fileobj.write(NUL * (RECORDSIZE - remainder)) |
| 2130 | finally: |
| 2131 | if not self._extfileobj: |
| 2132 | self.fileobj.close() |
| 2133 | |
| 2134 | def getmember(self, name): |
| 2135 | """Return a TarInfo object for member 'name'. If 'name' can not be |