mirror of https://github.com/exaloop/codon.git
Fix #313
parent
205351bdab
commit
d13e0ae245
|
@ -17,6 +17,12 @@ class File:
|
|||
raise IOError(f"file {path} could not be opened")
|
||||
self._reset()
|
||||
|
||||
def __init__(self, fd: int, mode: str):
|
||||
self.fp = _C.fdopen(fd, mode.c_str())
|
||||
if not self.fp:
|
||||
raise IOError(f"file descriptor {fd} could not be opened")
|
||||
self._reset()
|
||||
|
||||
def _errcheck(self, msg: str):
|
||||
err = int(_C.ferror(self.fp))
|
||||
if err:
|
||||
|
@ -392,7 +398,7 @@ class bzFile:
|
|||
|
||||
return i
|
||||
|
||||
def open(path: str, mode: str = "r") -> File:
|
||||
def open(path, mode: str = "r") -> File:
|
||||
return File(path, mode)
|
||||
|
||||
def gzopen(path: str, mode: str = "r") -> gzFile:
|
||||
|
|
Loading…
Reference in New Issue