From ad8a4813ee40692f762c7b4638fb99d116e37e8d Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Sun, 6 Aug 2023 11:10:13 +1000 Subject: [PATCH] no longer strip nulls from the end of all sectors, only the last one. still trying to figure out a nice way to handle it properly. --- rtfs/lib/rtfs.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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