Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File:readU...() and File:writeU...() #1887

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions lua/starfall/libs_cl/file.lua
Original file line number Diff line number Diff line change
Expand Up @@ -483,12 +483,31 @@ function file_methods:readLong()
return unwrap(self):ReadLong()
end

--- Reads an unsigned long and advances the file position
-- @return number UInt32 number
function file_methods:readULong()
return unwrap(self):ReadULong()
end

--- Reads a short and advances the file position
-- @return number Int16 number
function file_methods:readShort()
return unwrap(self):ReadShort()
end

--- Reads an unsigned short and advances the file position
-- @return number UInt16 number
function file_methods:readUShort()
return unwrap(self):ReadUShort()
end

--- Reads an unsigned 64-bit integer and advances the file position
--- Note: Since Lua cannot store full 64-bit integers, this function returns a string.
-- @return string UInt64 number
function file_methods:readUInt64()
return unwrap(self):ReadUInt64()
end

--- Writes a string to the file and advances the file position
-- @param string str The data to write
function file_methods:write(str)
Expand Down Expand Up @@ -531,11 +550,33 @@ function file_methods:writeLong(x)
unwrap(self):WriteLong(x)
end

--- Writes an unsigned long and advances the file position
-- @param number x The unsigned long to write
function file_methods:writeULong(x)
checkluatype (x, TYPE_NUMBER)
unwrap(self):WriteULong(x)
end

--- Writes a short and advances the file position
-- @param number x The short to write
function file_methods:writeShort(x)
checkluatype (x, TYPE_NUMBER)
unwrap(self):WriteShort(x)
end

--- Writes an unsigned short and advances the file position
-- @param number x The unsigned short to write
function file_methods:writeUShort(x)
checkluatype (x, TYPE_NUMBER)
unwrap(self):WriteUShort(x)
end

--- Writes an unsigned 64-bit integer and advances the file position
--- Note: Since Lua cannot store full 64-bit integers, this function takes a string.
-- @param string x The unsigned 64-bit integer to write
function file_methods:writeUInt64(x)
checkluatype (x, TYPE_STRING)
unwrap(self):WriteUInt64(x)
end

end
Loading