Skip to content

Commit

Permalink
Add is_bin argument to utils.writefile
Browse files Browse the repository at this point in the history
  • Loading branch information
mpeterv committed Jul 22, 2016
1 parent 684c1dd commit 1fb1e0e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lua/pl/utils.lua
Expand Up @@ -133,13 +133,15 @@ end
--- write a string to a file
-- @param filename The file path
-- @param str The string
-- @param is_bin open in binary mode
-- @return true or nil
-- @return error message
-- @raise error if filename or str aren't strings
function utils.writefile(filename,str)
function utils.writefile(filename,str,is_bin)
local mode = is_bin and 'b' or ''
utils.assert_string(1,filename)
utils.assert_string(2,str)
local f,err = io.open(filename,'w')
local f,err = io.open(filename,'w'..mode)
if not f then return raise(err) end
f:write(str)
f:close()
Expand Down

0 comments on commit 1fb1e0e

Please sign in to comment.