1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-06-26 07:03:22 +00:00
CC-Tweaked/src/main/resources/data/computercraft/lua/rom/programs/copy.lua
SquidDev 5e462adc5c Relocate all resource files
- textures/{block,item}s -> textures/{block,item}
 - assets/*/{advancements,lua,recipes} -> data/*/...
2019-04-02 13:18:43 +01:00

29 lines
746 B
Lua

local tArgs = { ... }
if #tArgs < 2 then
print( "Usage: cp <source> <destination>" )
return
end
local sSource = shell.resolve( tArgs[1] )
local sDest = shell.resolve( tArgs[2] )
local tFiles = fs.find( sSource )
if #tFiles > 0 then
for n,sFile in ipairs( tFiles ) do
if fs.isDir( sDest ) then
fs.copy( sFile, fs.combine( sDest, fs.getName(sFile) ) )
elseif #tFiles == 1 then
if fs.exists( sDest ) then
printError( "Destination exists" )
else
fs.copy( sFile, sDest )
end
else
printError( "Cannot overwrite file multiple times" )
return
end
end
else
printError( "No matching files" )
end