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

Class _LowLevelFile

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

Low-level file object. Supports reading and writing. It is used instead of a regular file object for streaming access.

Source from the content-addressed store, hash-verified

306# internal stream interface
307#---------------------------
308class _LowLevelFile:
309 """Low-level file object. Supports reading and writing.
310 It is used instead of a regular file object for streaming
311 access.
312 """
313
314 def __init__(self, name, mode):
315 mode = {
316 "r": os.O_RDONLY,
317 "w": os.O_WRONLY | os.O_CREAT | os.O_TRUNC,
318 }[mode]
319 if hasattr(os, "O_BINARY"):
320 mode |= os.O_BINARY
321 self.fd = os.open(name, mode, 0o666)
322
323 def close(self):
324 os.close(self.fd)
325
326 def read(self, size):
327 return os.read(self.fd, size)
328
329 def write(self, s):
330 os.write(self.fd, s)
331
332class _Stream:
333 """Class that serves as an adapter between TarFile and

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected