FileGetSize: Difference between revisions
Jump to navigation
Jump to search
(add oop syntax) |
m (Portuguese version indexed) |
||
(One intermediate revision by one other user not shown) | |||
Line 21: | Line 21: | ||
if (newFile) then -- check if the creation succeeded | if (newFile) then -- check if the creation succeeded | ||
fileWrite(newFile, "This is a test file!") -- write a text line | fileWrite(newFile, "This is a test file!") -- write a text line | ||
local size = fileGetSize ( newFile ) -- get size | local size = fileGetSize(newFile) -- get size | ||
if size then | if size then | ||
outputChatBox("Size of test.txt is: " .. size, source) -- output size | outputChatBox("Size of test.txt is: "..size, source) -- output size | ||
end | end | ||
fileClose(newFile) -- close the file once you're done with it | fileClose(newFile) -- close the file once you're done with it | ||
Line 33: | Line 31: | ||
==See Also== | ==See Also== | ||
{{File functions}} | {{File functions}} | ||
[[pt-br:fileGetSize]] |
Latest revision as of 18:55, 20 December 2023
Returns the total size in bytes of the given file.
Syntax
int fileGetSize ( file theFile )
OOP Syntax Help! I don't understand this!
- Method: file:getSize(...)
- Variable: .size
Required Arguments
- theFile: the file handle you wish to get the size of.
Returns
Returns the file size if successful, or false if an error occured (e.g. an invalid file handle was passed).
Example
local newFile = fileCreate("test.txt") -- attempt to create a new file if (newFile) then -- check if the creation succeeded fileWrite(newFile, "This is a test file!") -- write a text line local size = fileGetSize(newFile) -- get size if size then outputChatBox("Size of test.txt is: "..size, source) -- output size end fileClose(newFile) -- close the file once you're done with it end