VE Lua Documentation

Press F to search!

readFile

Definition


-- @/lua/common/utils.lua:890

-- reads the content of a file
function readFile(filename)
  profilerPushEvent("readFile open")
  local f = io.open(filename, "r")
  profilerPopEvent("readFile open")
  if f == nil then
    return nil
  end
  profilerPushEvent("readFile readClose")
  local content = f:read("*all")
  f:close()
  profilerPopEvent("readFile readClose")
  return content
end

Callers

@/lua/ge/extensions/editor/flowgraph/main.lua
                function(data)
                  local nodeData = readFile('/lua/ge/extensions/flowgraph/newNodeTemplate.lua')
                  nodeData = nodeData:gsub("New Node Template", data.filename:sub(1,-5)) -- change name
@/lua/common/jbeam/io.lua
local function _parseFileIntoCache(filename)
  local plainFileContent = readFile(filename)
  if plainFileContent then
@/lua/ge/extensions/editor/gen/lib/jbeam.lua
    local cnt
    local content = readFile(file)
    if content then
@/lua/vehicle/extensions/vehicleStatsLogger.lua
  log("I", logTag, "importing settings from file: " .. fpath)
  local json = readFile(fpath)
  local s = jsonDecode(json)
@/lua/ge/extensions/gameplay/rally/geometry.lua
      log("I", "", string.format("Generating rally pacenotes from '%s'", prevPacenoteSource))
      local route = lpack.decode(readFile(getRouteJsonPath()))
      pacenotes = getPacenotesFromRoute(route)
@/lua/ge/extensions/career/modules/linearTutorial.lua

  local content = readFile("/gameplay/tutorials/pages/"..id.."/content.html"):gsub("\r\n","")
  local entry = {
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamBeautifier.lua
local function beautifyJBeamFile(filePath)
  local origJBeamStr = readFile(filePath)
  if not origJBeamStr then
@/lua/ge/extensions/core/vehicles.lua
    for _, fn in ipairs(filesJson) do
      local data = readFile(fn)
      if p then p:add("json read") end
    for _, fn in ipairs(filesPaints) do
      local data = readFile(fn)
      if p then p:add("paints read") end
    for _, fn in ipairs(filesPC) do
      local data = readFile(fn)
      if p then p:add("pc read") end
  if FS:fileExists("settings/cloud/forceLicencePlate.txt") then
    local content = readFile("settings/cloud/forceLicencePlate.txt")
    if content ~= nil then
@/lua/ge/extensions/career/modules/logbook.lua
M.logbookEntry = function(id)
  M.genericInfoUnlocked("ui.introPopup."..id..".title", readFile("/ui/modules/careerLogbook/pages/"..id.."/content.html"):gsub("\r\n",""), "/ui/modules/careerLogbook/pages/"..id.."/header.jpg")
end
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamTableVis.lua
local function parseJBeamFile(filename)
  local content = readFile(filename)
  if content then
@/lua/common/utils/simpleProfiler/report.lua

  local templateStr = readFile(templateFile)
  if not templateStr then
@/lua/ge/map.lua
  --log('D', 'map', 'loading map.json: '.. mapFilename)
  local content = readFile(mapFilename)
  if content == nil then
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamModifierLeakVis.lua
    if not jbeamCache[jbeamFilename] then
      local str = readFile(jbeamFilename)
      if str then
@/lua/ge/extensions/core/highscores.lua
local function checkOldHighscoreFile()
  local oldFile = readFile("highscores")
  local newFile = readFile(highscoreFile)
  local oldFile = readFile("highscores")
  local newFile = readFile(highscoreFile)
  local hasOld = not (oldFile == nil or oldFile == '')
  checkOldHighscoreFile()
  local content = readFile(highscoreFile)
  if content == nil or content == "" then
@/lua/console/test.lua
        for k,v in pairs(jbeamFiles) do
            local content = readFile(v)
            if content ~= nil then
@/lua/ge/extensions/util/logStreams.lua
  -- huge hack and not happy about it, but it works! finally! \o/
  return readFile(logfileWikitable):gsub('\n', '\\n')
end
  -- huge hack and not happy about it, but it works! finally! \o/
  return readFile(logfileRst):gsub('\n', '\\n')
end
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamSpellchecker.lua
local function parseFile(filename)
  local content = readFile(filename)
  if content then
@/lua/ge/extensions/editor/terrainEditor.lua
local function updateMaterialLibrary()
  local content = readFile(var.levelPath .. matFilePath)
  local jsonMaterials = json.decode(content)
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/vePartTree.lua

      local str = readFile(jbeamFilename)
      if not str then
@/lua/console/json-performance.lua
for _, filename in pairs(filenames) do
  fileContent[filename] = readFile(filename)
  totalSize = totalSize + string.len(fileContent[filename])
@/lua/common/utils.lua
function jsonReadFile(filename)
  local content = readFile(filename)
  if content == nil then
@/lua/ge/extensions/editor/assetBrowser.lua
    elseif file.type == "prefab" then
      file.inspectorData.rawdata = readFile(file.sourcefilename or file.path)
    elseif file.type == "datablock" then
    elseif file.type == "datablock" then
      file.inspectorData.rawdata = readFile(file.sourcefilename or file.path)
    elseif file.type == "lua" then
    elseif file.type == "lua" then
      file.inspectorData.rawdata = readFile(file.sourcefilename or file.path)
    elseif file.type == "html" then
    elseif file.type == "html" then
      file.inspectorData.rawdata = readFile(file.sourcefilename or file.path)
    elseif file.type == "txt" then
    elseif file.type == "txt" then
      file.inspectorData.rawdata = readFile(file.sourcefilename or file.path)
    elseif file.type == "image" then
@/lua/vehicle/partCondition.lua
local function testLoad()
  local data = jsonDecode(readFile("partConditionTest.json") or "{}")
  hasSetPartCondition = {} --kill data from last init to avoid dual init warning
@/lua/ge/extensions/editor/shapeEditor.lua
  if FS:fileExists(mcf) then
    local data = readFile(mcf)
    if not string.startswith(data,"//JSON:") then
@/lua/ge/extensions/core/input/bindings.lua
    local fileData
    local f = readFile(path)
    if f then
    if binding.ffb and binding.ffb.responseCorrected then
      local f = readFile(path)
      if not f then
@/lua/ge/extensions/gameplay/discover.lua
  end
  local content = readFile(file):gsub("\r\n","")
  local entry = {
@/lua/ge/extensions/util/sortLines.lua
  log('I', 'sortLines', 'Handling file: ' .. path)
  local content = readFile(path)
  local lines = {}
@/lua/ge/extensions/editor/tech/roadArchitect/import.lua
      -- Collect all the .xml data.
      local d = collect(readFile(data.filepath))
@/lua/common/json-ast.lua
local function testFile(filename, writeAST, addASTId)
  local str = readFile(filename)
  if not str then
@/lua/ge/extensions/editor/api/core.lua
    if newFilename:find(".json") or newFilename:find(".cs") then
      local content = readFile(newFilename)
      content = content:gsub(srcLevelName, levelName)
@/lua/ge/extensions/gameplay/missions/missionTypes/flowMission.lua
  for _, file in ipairs(rulesFiles) do
    local content = readFile(file):gsub("\r\n","")
    table.insert(pages, content)
@/lua/ge/extensions/util/inputSystemUtils.lua
    if filepath:find('inputmaps/') then
      local content = readFile(filepath)
      if not content then
@/lua/ge/extensions/util/jbeamStats.lua
  for _, filename in ipairs(jbeamFiles) do
    local content = readFile(filename)
    totalLineCount = totalLineCount + select(2, content:gsub('\n', '\n'))
@/lua/common/utils/simpleHttpServer.lua
  else
    body = readFile(fn)
  end
@/lua/common/csvlib.lua
local function readFileCSV(filename, sep)
  return decode(readFile(filename), sep)
end
@/lua/ge/extensions/editor/vehicleEditor/staticEditor/veJBeamVariablesChecker.lua
local function parseFile(filename)
  local content = readFile(filename)
  if content then
@/lua/ge/extensions/util/testJSONFilesSyntax.lua
    local dir, fileName, _ = path.splitWithoutExt(filePath)
    local fileText = readFile(filePath)
    local data = jsonDebugDecode(fileText, filePath)