Skip to content

Commit

Permalink
use read1() for reads on console
Browse files Browse the repository at this point in the history
  • Loading branch information
cnvogelg committed Jan 19, 2025
1 parent 224fead commit 3bc6aee
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions amitools/vamos/lib/dos/FileHandle.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ def __init__(
self.unch = bytearray()
self.ch = -1
self.is_nil = is_nil
self.interactive = self.obj.isatty()

def __str__(self):
return "[FH:'%s'(ami='%s',sys='%s',nc=%s)@%06x=B@%06x]" % (
return "[FH:'%s'(ami='%s',sys='%s',nc=%s,af=%s,int=%s)@%06x=B@%06x]" % (
self.name,
self.ami_path,
self.sys_path,
self.need_close,
self.auto_flush,
self.interactive,
self.mem.addr,
self.b_addr,
)
Expand Down Expand Up @@ -65,7 +68,10 @@ def write(self, data):

def read(self, len):
try:
d = self.obj.read(len)
if self.interactive:
d = self.obj.read1(len)
else:
d = self.obj.read(len)
return d
except IOError:
return -1
Expand Down Expand Up @@ -147,13 +153,4 @@ def flush(self):
self.obj.flush()

def is_interactive(self):
fd = self.obj.fileno()
if hasattr(os, "ttyname"):
try:
os.ttyname(fd)
return True
except OSError:
return False
else:
# Not perfect, but best you can do on non-posix to detect a terminal.
return sys.stdin.isatty() or sys.stdout.isatty()
return self.interactive

0 comments on commit 3bc6aee

Please sign in to comment.