Skip to content

Commit

Permalink
Fix #313
Browse files Browse the repository at this point in the history
  • Loading branch information
inumanag committed Feb 26, 2025
1 parent 205351b commit d13e0ae
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stdlib/internal/file.codon
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d13e0ae

Please sign in to comment.