diff options
author | Erlend E. Aasland <erlend@python.org> | 2023-08-17 14:14:01 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 14:14:01 (GMT) |
commit | 8a19f225b948db1eebe1d9fc71a486258841f578 (patch) | |
tree | aaacedcca87c8bacf7359907ca89c65433ce3c85 | |
parent | 2da67a5789a9247ae6611185bf786b697aa04fbe (diff) | |
download | cpython-8a19f225b948db1eebe1d9fc71a486258841f578.zip cpython-8a19f225b948db1eebe1d9fc71a486258841f578.tar.gz cpython-8a19f225b948db1eebe1d9fc71a486258841f578.tar.bz2 |
gh-107801: Document SEEK_HOLE and SEEK_DATA (#107936)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <antoine@python.org>
-rw-r--r-- | Doc/library/os.rst | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 9735baa..94b76e4 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1171,6 +1171,10 @@ as internal buffering of data. current position; :const:`SEEK_END` or ``2`` to set it relative to the end of the file. Return the new cursor position in bytes, starting from the beginning. + .. versionchanged:: 3.3 + + Add support for :const:`SEEK_HOLE` and :const:`SEEK_DATA`. + .. data:: SEEK_SET SEEK_CUR @@ -1179,9 +1183,30 @@ as internal buffering of data. Parameters to the :func:`lseek` function. Their values are 0, 1, and 2, respectively. + +.. data:: SEEK_HOLE + SEEK_DATA + + Parameters to the :func:`lseek` function and the :meth:`~io.IOBase.seek` + method on file objects, for seeking file data and holes on sparsely + allocated files. + + :data:`!SEEK_DATA` + Adjust the file offset to the next location containing data, + relative to the seek position. + + :data:`!SEEK_HOLE` + Adjust the file offset to the next location containing a hole, + relative to the seek position. + A hole is defined as a sequence of zeros. + + .. note:: + + These operations only make sense for filesystems that support them. + + .. availability:: Linux >= 3.1, macOS, Unix + .. versionadded:: 3.3 - Some operating systems could support additional values, like - :const:`os.SEEK_HOLE` or :const:`os.SEEK_DATA`. .. function:: open(path, flags, mode=0o777, *, dir_fd=None) |