mirror of
https://github.com/lazuscripts/utility.git
synced 2024-11-16 03:14:21 +00:00
Add fs.size() (#4)
This commit is contained in:
parent
3616fc80e5
commit
e918bbe5f1
21
fs.moon
21
fs.moon
@ -1,10 +1,23 @@
|
||||
exists = (file_path) ->
|
||||
handle = io.open file_path, "r"
|
||||
if handle
|
||||
handle\close!
|
||||
if file = io.open file_path, "r"
|
||||
file\close!
|
||||
return true
|
||||
return false
|
||||
else
|
||||
return false
|
||||
|
||||
size = (file_or_path) ->
|
||||
if "string" == type file_or_path
|
||||
file = io.open file_or_path, "r"
|
||||
size = file\seek "end"
|
||||
file\close!
|
||||
return size
|
||||
else
|
||||
current = file\seek!
|
||||
size = file\seek "end"
|
||||
file\seek "set", current
|
||||
return size
|
||||
|
||||
{
|
||||
:exists
|
||||
:size
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user