Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.
(self)
| 1955 | # The public methods which TarFile provides: |
| 1956 | |
| 1957 | def close(self): |
| 1958 | """Close the TarFile. In write-mode, two finishing zero blocks are |
| 1959 | appended to the archive. |
| 1960 | """ |
| 1961 | if self.closed: |
| 1962 | return |
| 1963 | |
| 1964 | self.closed = True |
| 1965 | try: |
| 1966 | if self.mode in ("a", "w", "x"): |
| 1967 | self.fileobj.write(NUL * (BLOCKSIZE * 2)) |
| 1968 | self.offset += (BLOCKSIZE * 2) |
| 1969 | # fill up the end with zero-blocks |
| 1970 | # (like option -b20 for tar does) |
| 1971 | blocks, remainder = divmod(self.offset, RECORDSIZE) |
| 1972 | if remainder > 0: |
| 1973 | self.fileobj.write(NUL * (RECORDSIZE - remainder)) |
| 1974 | finally: |
| 1975 | if not self._extfileobj: |
| 1976 | self.fileobj.close() |
| 1977 | |
| 1978 | def getmember(self, name): |
| 1979 | """Return a TarInfo object for member `name'. If `name' can not be |