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
local startSByte = ((readCursor - 1) % sectorSize) + 1
local sect = unmanagedProxy.readSector(startSector)
unmanagedProxy.writeSector(
startSector,
sect:sub(1, startSByte - 1) .. data:sub(1, sectorSize - startSByte + 1)
)
unmanagedProxy.writeSector(startSector, sect:sub(1, startSByte - 1) .. data:sub(1, sectorSize - startSByte + 1))
for i = 2, (#data + startSByte) // sectorSize do
if startSector + i - 1 > sectorCount then
return nil, "not enough space"
@@ -375,7 +372,7 @@ function filesystem.open(path, mode, buffered) -- opens a file and returns its h
readCursor = 1
return newPos
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
@@ -562,8 +559,7 @@ function filesystem.rename(fromPath, toPath)
copyRecursive(fromAddress, fromAbsPath, toAddress, toAbsPath)
filesystem.remove(fromPath) -- component.invoke(fromAddress,"remove", fromAbsPath)
else
local handle, data, tmpdata = filesystem.open(fromPath), "",
nil -- component.invoke(fromAddress, "open", fromAbsPath, "r"), "", nil
local handle, data, tmpdata = filesystem.open(fromPath), "", nil -- component.invoke(fromAddress, "open", fromAbsPath, "r"), "", nil
repeat
tmpdata = handle:read(math.huge or math.maxinteger) -- component.invoke(fromAddress, "read", handle, math.huge or math.maxinteger)
data = data .. (tmpdata or "")