diff --git a/rtfs/lib/rtfs.lua b/rtfs/lib/rtfs.lua index ec7fe0d..0d98efa 100644 --- a/rtfs/lib/rtfs.lua +++ b/rtfs/lib/rtfs.lua @@ -392,14 +392,16 @@ function proxy:writeHandle(h,s) return true end function proxy:readHandle(h,s) - local handle = self.handles[h] - if handle.currentSector <= handle.ft[3] - 1 then + local handle, rb = self.handles[h] + if handle.currentSector < handle.ft[3] - 1 then + local rb = self.d.readSector(handle.ft[2] + handle.currentSector) + if handle.currentSector == handle.ft[3] - 1 then local rb = self.d.readSector(handle.ft[2] + handle.currentSector):gsub("\0+$","") - handle.currentSector = handle.currentSector + 1 - return rb else return nil end + handle.currentSector = handle.currentSector + 1 + return rb end -- primarily for debugging