MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / close

Method close

tools/python-3.11.9-amd64/Lib/tarfile.py:1957–1976  ·  view source on GitHub ↗

Close the TarFile. In write-mode, two finishing zero blocks are appended to the archive.

(self)

Source from the content-addressed store, hash-verified

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

Callers 1

__exit__Method · 0.95

Calls 2

writeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected