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

Class _SharedFile

tools/python-3.11.9-amd64/Lib/zipfile.py:756–793  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

754
755
756class _SharedFile:
757 def __init__(self, file, pos, close, lock, writing):
758 self._file = file
759 self._pos = pos
760 self._close = close
761 self._lock = lock
762 self._writing = writing
763 self.seekable = file.seekable
764
765 def tell(self):
766 return self._pos
767
768 def seek(self, offset, whence=0):
769 with self._lock:
770 if self._writing():
771 raise ValueError("Can't reposition in the ZIP file while "
772 "there is an open writing handle on it. "
773 "Close the writing handle before trying to read.")
774 self._file.seek(offset, whence)
775 self._pos = self._file.tell()
776 return self._pos
777
778 def read(self, n=-1):
779 with self._lock:
780 if self._writing():
781 raise ValueError("Can't read from the ZIP file while there "
782 "is an open writing handle on it. "
783 "Close the writing handle before trying to read.")
784 self._file.seek(self._pos)
785 data = self._file.read(n)
786 self._pos = self._file.tell()
787 return data
788
789 def close(self):
790 if self._file is not None:
791 fileobj = self._file
792 self._file = None
793 self._close(fileobj)
794
795# Provide the tell method for unseekable stream
796class _Tellable:

Callers 1

openMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected