CaptainSpaceCat

append

May 17th, 2015
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.56 KB | None | 0 0
  1. tArgs = {...}
  2. num = 0
  3. while fs.exists("tempFile" .. tostring(num)) do
  4.   num = num + 1
  5. end
  6. num = tostring(num)
  7. shell.run("copy " .. tArgs[2] .. " tempFile".. num)
  8. tempWrite = fs.open(tArgs[2], "w")
  9. tempWrite.writeLine("--==ORIGINAL CODE==--")
  10. for line in io.lines("tempFile" .. num) do
  11.   tempWrite.writeLine(line)
  12. end
  13. tempWrite.writeLine("--==APPENDED CODE==--")
  14. for line in io.lines(tArgs[1]) do
  15.   tempWrite.writeLine(line)
  16. end
  17. tempWrite.flush()
  18. tempWrite.close()
  19. shell.run("delete tempFile" .. num)
  20. print(tArgs[1] .. " successfully appended to " .. tArgs[2])
Add Comment
Please, Sign In to add comment