MCPcopy Index your code
hub / github.com/RustPython/RustPython / _LowLevelFile

Class _LowLevelFile

Lib/tarfile.py:305–327  ·  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

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