Advertisement
MjnMixael

Untitled

Sep 13th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. function filecopyblock(cfrom, cto, ctarg, cdest)
  2.  
  3. self.Copyfrom = ("data/" .. cfrom)
  4. self.Copyto = ("data/" .. cto)
  5. self.Targname = ctarg
  6. self.Destname = cdest
  7. if (self.Copyfrom == nil) then
  8. ba.print("Invalid variable 'copyfrom' in filecopy function...\n")
  9. end
  10. if (self.Copyto == nil) then
  11. ba.print("Invalid variable 'copyto' in filecopy function...\n")
  12. end
  13. if (self.Targname == nil) then
  14. ba.print("Invalid variable 'targname' in filecopy function...\n")
  15. end
  16. if (self.Destname == nil) then
  17. ba.print("Invalid variable 'destname' in filecopy function...\n")
  18. end
  19. if ((self.Copyfrom ~= nil) and (self.Copyto ~= nil) and (self.Targname ~= nil) and (self.Destname ~= nil)) then
  20. local file = cf.openFile(self.Targname, "r", self.Copyfrom)
  21. local mstring = file:read("*a")
  22.  
  23. file:close()
  24.  
  25. file = cf.openFile(self.Destname, "w+", self.Copyto)
  26. file:write(mstring)
  27. file:close()
  28. else
  29. ba.print("Warning: One or more necessary variables for filecopy function were nil! Operation cancelled...\n")
  30. end
  31.  
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement