-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathego.lua
36 lines (31 loc) · 817 Bytes
/
ego.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module (..., package.seeall)
function saveFile( fileName, fileData )
--Path for file
local path = system.pathForFile( fileName, system.DocumentsDirectory )
--Open the file
local file = io.open( path, "w+" )
--Save specified value to the file
if file then
file:write( fileData )
io.close( file )
end
end
--Load function
function loadFile( fileName )
--Path for file
local path = system.pathForFile( fileName, system.DocumentsDirectory )
--Open the file
local file = io.open( path, "r" )
--If the file exists return the data
if file then
local fileData = file:read( "*a" )
io.close( file )
return fileData
--If the file doesn't exist create it and write it with "empty"
else
file = io.open( path, "w" )
file:write( "empty" )
io.close( file )
return "empty"
end
end