Skip to content

Commit

Permalink
Optimized filesystem.name() / Fix filesystem.copy() (#2432)
Browse files Browse the repository at this point in the history
* Fixed possible error reporting bug in filesystem.copy()

Made local data initialize to false. Previously was nil and if the function was unable to open either file, this would cause the function to return true as its first value. data becomes nil when copying is finished, so this sorts itself out.
Added arg checking to filesystem.name
  • Loading branch information
SDPhantom authored and payonel committed Jun 23, 2017
1 parent ed99999 commit da05975
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ function filesystem.path(path)
end

function filesystem.name(path)
checkArg(1, path, "string")
local parts = segments(path)
return parts[#parts]
end
Expand Down Expand Up @@ -436,7 +437,7 @@ function filesystem.rename(oldPath, newPath)
end

function filesystem.copy(fromPath, toPath)
local data
local data = false
local input, reason = filesystem.open(fromPath, "rb")
if input then
local output, reason = filesystem.open(toPath, "wb")
Expand Down

0 comments on commit da05975

Please sign in to comment.