南锋

南奔万里空,脱死锋镝余

Cocos2dx-lua Return Size of a Specified File

Returns the size of a specified file. If it fails, it returns false.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
-- @function [parent=#io] filesize
-- @param string path Full path to the file
-- @return integer#integer

function io.filesize(path)
local size = false
local file = io.open(path, "r")
if file then
local current = file:seek()
size = file:seek("end")
file:seek("set", current)
io.close(file)
end
return size
end
+