Commit 5b60a38a authored by funshine's avatar funshine
Browse files

modify readme

parent 3a2797c2
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
###version 0.1 2014-10-11 ###version 0.1 2014-10-11
###change log: ###change log:
2014-11-10<br />
change log module to file module<br />
now file operation support multiple read/write<br />
for now file module only allowed one file opened<br />
2014-11-5<br /> 2014-11-5<br />
delete log operation api from node module<br /> delete log operation api from node module<br />
add log module<br /> add log module<br />
...@@ -206,17 +211,17 @@ nil ...@@ -206,17 +211,17 @@ nil
####See also ####See also
**-** []() **-** []()
#log module #file module
<a id="lg_format"></a> <a id="fl_remove"></a>
## log.format() ## file.remove()
####Description ####Description
format flash for users. remove file from user flash.
####Syntax ####Syntax
log.format() file.remove(filename)
####Parameters ####Parameters
nil filename: file to be removed
####Returns ####Returns
nil nil
...@@ -224,29 +229,31 @@ nil ...@@ -224,29 +229,31 @@ nil
####Example ####Example
``` ```
//record log to init.lua. Call the file after system restart. //remove "foo.lua" from user flash.
log.format() file.remove("foo.lua")
log.start("init.lua", 1)
print("hello world")
log.stop()
``` ```
####See also ####See also
**-** [log.start()](#lg_start)<br /> **-** [file.open()](#fl_open)<br />
**-** [log.stop()](#lg_stop) **-** [file.close()](#fl_close)
<a id="lg_start"></a> <a id="fl_open"></a>
## log.start() ## file.open()
####Description ####Description
start to log input open file.
####Syntax ####Syntax
log.start(filename, noparse) file.open(filename, mode)
####Parameters ####Parameters
filename: file to be opened, directories are not supported<br />
filename: log file, directories are not supported<br /> mode:<br />
noparse: 1 for lua VM doesn’t parse input, 0 for lua VM parse input "r": read mode (the default)<br />
"w": write mode<br />
"a": append mode<br />
"r+": update mode, all previous data is preserved<br />
"w+": update mode, all previous data is erased<br />
"a+": append update mode, previous data is preserved, writing is only allowed at the end of file
####Returns ####Returns
nil nil
...@@ -254,25 +261,23 @@ nil ...@@ -254,25 +261,23 @@ nil
####Example ####Example
``` ```
//record log to init.lua. Call the file after system restart. //open 'init.lua', print the first line.
log.format() file.open("init.lua", "r")
log.start("init.lua", 1) print(file.readline())
print("hello world") file.close()
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
``` ```
####See also ####See also
**-** [log.format()](#lg_format)<br /> **-** [file.close()](#fl_close)<br />
**-** [log.stop()](#lg_stop) **-** [file.readline()](#fl_readline)
<a id="lg_stop"></a> <a id="fl_close"></a>
## log.stop() ## file.close()
####Description ####Description
stop log. close the file.
####Syntax ####Syntax
log.stop() file.close()
####Parameters ####Parameters
nil nil
...@@ -283,55 +288,53 @@ nil ...@@ -283,55 +288,53 @@ nil
####Example ####Example
``` ```
//record log to init.lua. Call the file after system restart. //open 'init.lua', print the first line.
log.format() file.open("init.lua", "r")
log.start("init.lua", 1) print(file.readline())
print("hello world") file.close()
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
``` ```
####See also ####See also
**-** [log.format()](#lg_format)<br /> **-** [file.open()](#fl_open)<br />
**-** [log.start()](#lg_start) **-** [file.readline()](#fl_readline)
<a id="lg_open"></a> <a id="fl_readline"></a>
## log.open() ## file.readline()
####Description ####Description
open the log file read one line of file which is opened before line by line.
####Syntax ####Syntax
log.open(filename) file.readline()
####Parameters ####Parameters
filename: log file, directories are not supported nil
####Returns ####Returns
nil file content in string, line by line
####Example ####Example
``` ```
//print the first line of 'init.lua' //print the first line of 'init.lua'
log.open("init.lua") file.open("init.lua", "r")
print(log.readline()) print(file.readline())
log.close() file.close()
``` ```
####See also ####See also
**-** [log.close()](#lg_close)<br /> **-** [file.open()](#fl_open)<br />
**-** [log.readline()](#lg_readline) **-** [file.close()](#fl_close)
<a id="lg_close"></a> <a id="fl_writeline"></a>
## log.close() ## file.writeline()
####Description ####Description
close the log file which opened before write new line to file with a '\n' at the end.
####Syntax ####Syntax
log.close() file.writeline(string)
####Parameters ####Parameters
nil string: content to be write to file
####Returns ####Returns
nil nil
...@@ -339,50 +342,52 @@ nil ...@@ -339,50 +342,52 @@ nil
####Example ####Example
``` ```
//print the first line of 'init.lua' //open 'init.lua' in 'a+' mode
log.open("init.lua") file.open("init.lua", "a+")
print(log.readline()) //write 'foo bar' to the end of the file
log.close() file.writeline('foo bar')
file.close()
``` ```
####See also ####See also
**-** [log.open()](#lg_open)<br /> **-** [file.open()](#fl_open)<br />
**-** [log.readline()](#lg_readline) **-** [file.write()](#fl_write)
<a id="lg_readline"></a> <a id="fl_write"></a>
## log.readline() ## file.write()
####Description ####Description
read log file which is opened before line by line. write string to file.
####Syntax ####Syntax
log.readline() file.write(string)
####Parameters ####Parameters
nil string: content to be write to file.
####Returns ####Returns
log file content in string, line by line nil
####Example ####Example
``` ```
//print the first line of 'init.lua' //open 'init.lua' in 'a+' mode
log.open("init.lua") file.open("init.lua", "a+")
print(log.readline()) //write 'foo bar' to the end of the file
log.close() file.write('foo bar')
file.close()
``` ```
####See also ####See also
**-** [log.open()](#lg_open) **-** [file.open()](#fl_open)<br />
**-** [log.close()](#lg_close) **-** [file.writeline()](#fl_writeline)
<a id="lg_list"></a> <a id="fl_list"></a>
## log.list() ## file.list()
####Description ####Description
list all files. list all files.
####Syntax ####Syntax
log.list() file.list()
####Parameters ####Parameters
nil nil
...@@ -393,14 +398,14 @@ a lua table which contains the {file name: file size} pairs ...@@ -393,14 +398,14 @@ a lua table which contains the {file name: file size} pairs
####Example ####Example
``` ```
l = log.list(); l = file.list();
for k,v in l do for k,v in l do
print("name:"..k..", size:"..v) print("name:"..k..", size:"..v)
end end
``` ```
####See also ####See also
**-** [log.format()](#lg_format) **-** [file.remove()](#fl_remove)
#wifi module #wifi module
##CONSTANT ##CONSTANT
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment