Modules/FileSystem/file/size: Difference between revisions
Jump to navigation
Jump to search
(Created page with "__NOTOC__ This function returns the size of a specific file/stream from beginning to end. Not all streams have to support this operation. ==Syntax== <syntaxhighlight lang="lua"> int file:size () </syntaxhighlight> ==Returns== Returns the amount of bytes that this file/stream object is made of. ==Example== <section name="Client" class="client" show="true"> This snippet returns the contents of a file in a string buffer. <syntaxhighlight lang="lua"> local function fileGe...") |
No edit summary |
||
Line 1: | Line 1: | ||
<pageclass class="#3cc882" subcaption="File function"></pageclass> | |||
__NOTOC__ | __NOTOC__ | ||
This function returns the size of a specific file/stream from beginning to end. Not all streams have to support this operation. | This function returns the size of a specific file/stream from beginning to end. Not all streams have to support this operation. |
Latest revision as of 03:10, 23 January 2022
This function returns the size of a specific file/stream from beginning to end. Not all streams have to support this operation.
Syntax
int file:size ()
Returns
Returns the amount of bytes that this file/stream object is made of.
Example
Click to collapse [-]
ClientThis snippet returns the contents of a file in a string buffer.
local function fileGetContents( path ) -- Prevent a warning being output by checking for file existance first. if not ( fileExists( path ) ) then return false; end; -- Open the requested file. local theFile = fileOpen( path ); if not ( theFile ) then return false; end; -- The the whole content of the file into a string buffer. local content = theFile:read( theFile:size() ); -- Clean up the file handle. theFile:destroy(); return content; end