serializeJsonToFile
Definition
-- @/lua/common/utils.lua:460
-- if "atomicWrite" is truthy, the function will write to a temp file first before renaming it to "filename"
-- if "atomicWrite" is a string, that string will be used as a temp filename, otherwise the function will use a default temp filename
function jsonWriteFile(filename, obj, pretty, numberPrecision, atomicWrite)
if not atomicWrite then
return jsonWriteFileActual(filename, obj, pretty, numberPrecision)
else
local tempFileName = (type(atomicWrite) == "string") and atomicWrite or (filename .. ".tmp")
if jsonWriteFileActual(tempFileName, obj, pretty, numberPrecision) then
if FS:renameFile(tempFileName, filename) == 0 then
return true
else
log("E", "save", "failed to copy temporary json!")
end
else
log("E", "save", "failed to write json!")
end
return false
end
end
Callers
@/lua/ge/extensions/editor/assetManagementTool.lua
linkJsonData["time"] = getDateTimeUTCString()
serializeJsonToFile(linkPath, linkJsonData, true)
editor.logInfo("\tCreated link '" .. linkPath .. "'")