From da059756b9bbb210351420c79ebb72fda666a6a7 Mon Sep 17 00:00:00 2001 From: SDPhantom Date: Thu, 22 Jun 2017 18:50:09 -0700 Subject: [PATCH] Optimized filesystem.name() / Fix filesystem.copy() (#2432) * 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 --- .../assets/opencomputers/loot/openos/lib/filesystem.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/assets/opencomputers/loot/openos/lib/filesystem.lua b/src/main/resources/assets/opencomputers/loot/openos/lib/filesystem.lua index 8f7c553d0..2e4ab54a0 100644 --- a/src/main/resources/assets/opencomputers/loot/openos/lib/filesystem.lua +++ b/src/main/resources/assets/opencomputers/loot/openos/lib/filesystem.lua @@ -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 @@ -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")