modify readme

This commit is contained in:
funshine 2014-11-10 17:16:07 +08:00
parent 3a2797c222
commit 5b60a38a47

225
README.md
View File

@ -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,14 +211,73 @@ 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
filename: file to be removed
####Returns
nil
####Example
```
//remove "foo.lua" from user flash.
file.remove("foo.lua")
```
####See also
**-** [file.open()](#fl_open)<br />
**-** [file.close()](#fl_close)
<a id="fl_open"></a>
## file.open()
####Description
open file.
####Syntax
file.open(filename, mode)
####Parameters
filename: file to be opened, directories are not supported<br />
mode:<br />
"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
nil
####Example
```
//open 'init.lua', print the first line.
file.open("init.lua", "r")
print(file.readline())
file.close()
```
####See also
**-** [file.close()](#fl_close)<br />
**-** [file.readline()](#fl_readline)
<a id="fl_close"></a>
## file.close()
####Description
close the file.
####Syntax
file.close()
####Parameters ####Parameters
nil nil
@ -224,114 +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()
``` ```
####See also ####See also
**-** [log.start()](#lg_start)<br /> **-** [file.open()](#fl_open)<br />
**-** [log.stop()](#lg_stop) **-** [file.readline()](#fl_readline)
<a id="lg_start"></a> <a id="fl_readline"></a>
## log.start() ## file.readline()
####Description ####Description
start to log input read one line of file which is opened before line by line.
####Syntax ####Syntax
log.start(filename, noparse) file.readline()
####Parameters
filename: log file, directories are not supported<br />
noparse: 1 for lua VM doesnt parse input, 0 for lua VM parse input
####Returns
nil
####Example
```
//record log to init.lua. Call the file after system restart.
log.format()
log.start("init.lua", 1)
print("hello world")
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
```
####See also
**-** [log.format()](#lg_format)<br />
**-** [log.stop()](#lg_stop)
<a id="lg_stop"></a>
## log.stop()
####Description
stop log.
####Syntax
log.stop()
####Parameters ####Parameters
nil nil
####Returns ####Returns
nil file content in string, line by line
####Example
```
//record log to init.lua. Call the file after system restart.
log.format()
log.start("init.lua", 1)
print("hello world")
log.stop()
//At this point, the content of init.lua is "print("hello world")". When system restart, print("hello world") are excuted.
```
####See also
**-** [log.format()](#lg_format)<br />
**-** [log.start()](#lg_start)
<a id="lg_open"></a>
## log.open()
####Description
open the log file
####Syntax
log.open(filename)
####Parameters
filename: log file, directories are not supported
####Returns
nil
####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
####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
####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