mirror of
https://github.com/gvx/bitser.git
synced 2024-11-11 01:44:21 +00:00
Add assertions for dumpLoveFile and loadLoveFile (#11)
This will print useful error messages instead of just failing silently. E.g.: `lib/Bitser.lua:370: Could not open file prabs/test.lua. Does not exist.`
This commit is contained in:
parent
dd3034117f
commit
4f2680317c
@ -364,9 +364,10 @@ return {dumps = function(value)
|
|||||||
return ffi.string(buf, buf_pos)
|
return ffi.string(buf, buf_pos)
|
||||||
end, dumpLoveFile = function(fname, value)
|
end, dumpLoveFile = function(fname, value)
|
||||||
serialize(value)
|
serialize(value)
|
||||||
love.filesystem.write(fname, ffi.string(buf, buf_pos))
|
assert(love.filesystem.write(fname, ffi.string(buf, buf_pos)))
|
||||||
end, loadLoveFile = function(fname)
|
end, loadLoveFile = function(fname)
|
||||||
local serializedData = love.filesystem.newFileData(fname)
|
local serializedData, error = love.filesystem.newFileData(fname)
|
||||||
|
assert(serializedData, error)
|
||||||
Buffer_newDataReader(serializedData:getPointer(), serializedData:getSize())
|
Buffer_newDataReader(serializedData:getPointer(), serializedData:getSize())
|
||||||
return deserialize_value({})
|
return deserialize_value({})
|
||||||
end, loadData = function(data, size)
|
end, loadData = function(data, size)
|
||||||
|
Loading…
Reference in New Issue
Block a user