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

Method truncate

tools/python-3.11.9-amd64/Lib/_pyio.py:1750–1761  ·  view source on GitHub ↗

Truncate the file to at most size bytes. Size defaults to the current file position, as returned by tell(). The current file position is changed to the value of size.

(self, size=None)

Source from the content-addressed store, hash-verified

1748 return os.lseek(self._fd, 0, SEEK_CUR)
1749
1750 def truncate(self, size=None):
1751 """Truncate the file to at most size bytes.
1752
1753 Size defaults to the current file position, as returned by tell().
1754 The current file position is changed to the value of size.
1755 """
1756 self._checkClosed()
1757 self._checkWritable()
1758 if size is None:
1759 size = self.tell()
1760 os.ftruncate(self._fd, size)
1761 return size
1762
1763 def close(self):
1764 """Close the file.

Callers

nothing calls this directly

Calls 3

_checkWritableMethod · 0.95
tellMethod · 0.95
_checkClosedMethod · 0.45

Tested by

no test coverage detected