Skip to content

Commit

Permalink
Open files in binary mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
felipetavares committed Nov 24, 2019
1 parent f672287 commit 08f0717
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/apps/system/cp.nib/main.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function copy_file(from, to)
local f_from = io.open(from, 'r')
local f_from = io.open(from, 'rb')

if f_from then
local content = f_from:read('*all')

if content then
local f_to = io.open(to, 'w')
local f_to = io.open(to, 'wb')

if f_to then
f_to:write(content)
Expand All @@ -26,4 +26,4 @@ function init()
end

stop_app(0)
end
end
6 changes: 3 additions & 3 deletions src/apps/system/mv.nib/main.lua
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
function move_file(from, to)
local f_from = io.open(from, 'r')
local f_from = io.open(from, 'rb')

if f_from then
local content = f_from:read('*all')

if content then
local f_to = io.open(to, 'w')
local f_to = io.open(to, 'wb')

f_to:write(content)

Expand All @@ -28,4 +28,4 @@ function init()
end

stop_app(0)
end
end
4 changes: 2 additions & 2 deletions src/apps/system/new.nib/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ function make_file(file)
end

function copy_file(from, to)
local original = io.open(from, "r")
local original = io.open(from, "rb")

if original then
local content = original:read("*all")

if content then
make_file(to)

local destination = io.open(to, "w")
local destination = io.open(to, "wb")

if destination then
destination:write(content)
Expand Down

0 comments on commit 08f0717

Please sign in to comment.