fixed filesystem erroring out when seeking while not buffered

This commit is contained in:
Ponali
2025-10-11 10:22:31 +02:00
parent 33f2573eb6
commit 1798d63864
+3 -7
View File
@@ -294,10 +294,7 @@ function filesystem.open(path, mode, buffered) -- opens a file and returns its h
end end
local startSByte = ((readCursor - 1) % sectorSize) + 1 local startSByte = ((readCursor - 1) % sectorSize) + 1
local sect = unmanagedProxy.readSector(startSector) local sect = unmanagedProxy.readSector(startSector)
unmanagedProxy.writeSector( unmanagedProxy.writeSector(startSector, sect:sub(1, startSByte - 1) .. data:sub(1, sectorSize - startSByte + 1))
startSector,
sect:sub(1, startSByte - 1) .. data:sub(1, sectorSize - startSByte + 1)
)
for i = 2, (#data + startSByte) // sectorSize do for i = 2, (#data + startSByte) // sectorSize do
if startSector + i - 1 > sectorCount then if startSector + i - 1 > sectorCount then
return nil, "not enough space" return nil, "not enough space"
@@ -375,7 +372,7 @@ function filesystem.open(path, mode, buffered) -- opens a file and returns its h
readCursor = 1 readCursor = 1
return newPos return newPos
else else
return component.invoke(self.address, "seek", self.handle, whence, math.max(offset, -currentAbsolutePos)) return component.invoke(self.address, "seek", self.handle, whence, offset)
end end
end end
@@ -562,8 +559,7 @@ function filesystem.rename(fromPath, toPath)
copyRecursive(fromAddress, fromAbsPath, toAddress, toAbsPath) copyRecursive(fromAddress, fromAbsPath, toAddress, toAbsPath)
filesystem.remove(fromPath) -- component.invoke(fromAddress,"remove", fromAbsPath) filesystem.remove(fromPath) -- component.invoke(fromAddress,"remove", fromAbsPath)
else else
local handle, data, tmpdata = filesystem.open(fromPath), "", local handle, data, tmpdata = filesystem.open(fromPath), "", nil -- component.invoke(fromAddress, "open", fromAbsPath, "r"), "", nil
nil -- component.invoke(fromAddress, "open", fromAbsPath, "r"), "", nil
repeat repeat
tmpdata = handle:read(math.huge or math.maxinteger) -- component.invoke(fromAddress, "read", handle, math.huge or math.maxinteger) tmpdata = handle:read(math.huge or math.maxinteger) -- component.invoke(fromAddress, "read", handle, math.huge or math.maxinteger)
data = data .. (tmpdata or "") data = data .. (tmpdata or "")