Fixed: Issue #39 reading a file returns nil being trimmed

This commit is contained in:
Deyan Dobromirov 2022-09-11 10:29:40 +03:00
parent 52a91beb07
commit a673b69fa0
2 changed files with 10 additions and 7 deletions

View File

@ -91,7 +91,7 @@ local asmlib = trackasmlib; if(not asmlib) then -- Module present
------------ CONFIGURE ASMLIB ------------
asmlib.InitBase("track","assembly")
asmlib.SetOpVar("TOOL_VERSION","8.688")
asmlib.SetOpVar("TOOL_VERSION","8.689")
asmlib.SetIndexes("V" ,1,2,3)
asmlib.SetIndexes("A" ,1,2,3)
asmlib.SetIndexes("WV",1,2,3)

View File

@ -564,15 +564,18 @@ function GetViewRadius(pPly, vPos, nMul)
end
--[[
* Golden retriever. Retrieves file line as string
* But seriously returns the sting line and EOF flag
* pFile > The file to read the line of characters from
* bCons > Keeps data consistency. Enable to ignore trimming
* Golden retriever. Retrieves file line as string
* But seriously returns the sting line and EOF flag
* pFile > The file to read the line of characters from
* bCons > Keeps data consistency. Enable to skip trim
* Reurns line contents and reaching EOF flag
* sLine > The line being read from the file
* isEOF > Flag indicating pointer reached EOF
]]
function GetStringFile(pFile, bCons)
if(not pFile) then LogInstance("No file"); return "", true end
local sLine = pFile:ReadLine() -- Read one line at once
local isEOF = pFile:EndOfFile() -- Check for EOF status
local sLine = (pFile:ReadLine() or "") -- Read one line at once
local isEOF = pFile:EndOfFile() -- Check for file EOF status
if(not bCons) then sLine = sLine:Trim() end
return sLine, isEOF
end