diff options
author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-08 21:05:56 +0000 |
---|---|---|
committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-07-08 21:05:56 +0000 |
commit | 408213f2633236690ba76f9c9d76e061c3c51237 (patch) | |
tree | 75012f1449ea10afbe2a9bbd87a016767eb5c8f2 /apps/plugins/helloworld.lua | |
parent | 90e3b727dd1af914c03049a1baee6007fd4cbb9e (diff) | |
download | rockbox-408213f2633236690ba76f9c9d76e061c3c51237.tar.gz rockbox-408213f2633236690ba76f9c9d76e061c3c51237.zip |
Helloworld.lua: fix file_put_contents depending on a wrong return value of io.write + use a cleaner version of if(file == nil) (thanks to Christophe Gragnic)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21731 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/helloworld.lua')
-rw-r--r-- | apps/plugins/helloworld.lua | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/apps/plugins/helloworld.lua b/apps/plugins/helloworld.lua index 94e55af3cc..aa2ef446d3 100644 --- a/apps/plugins/helloworld.lua +++ b/apps/plugins/helloworld.lua | |||
@@ -65,7 +65,7 @@ end | |||
65 | -- Helper function which reads the contents of a file | 65 | -- Helper function which reads the contents of a file |
66 | function file_get_contents(filename) | 66 | function file_get_contents(filename) |
67 | local file = io.open(filename, "r") | 67 | local file = io.open(filename, "r") |
68 | if(file == nil) then | 68 | if not file then |
69 | return nil | 69 | return nil |
70 | end | 70 | end |
71 | 71 | ||
@@ -78,11 +78,11 @@ end | |||
78 | -- Helper function which saves contents to a file | 78 | -- Helper function which saves contents to a file |
79 | function file_put_contents(filename, contents) | 79 | function file_put_contents(filename, contents) |
80 | local file = io.open(filename, "w+") -- See Lua manual for more information | 80 | local file = io.open(filename, "w+") -- See Lua manual for more information |
81 | if(file == nil) then | 81 | if not file then |
82 | return false | 82 | return false |
83 | end | 83 | end |
84 | 84 | ||
85 | local ret = file:write(contents) == 1 | 85 | local ret = file:write(contents) == true |
86 | file:close() -- GC takes care of this if you would've forgotten it | 86 | file:close() -- GC takes care of this if you would've forgotten it |
87 | return ret | 87 | return ret |
88 | end | 88 | end |