Cakejoke

[CC] COS-CJE fsx API

Dec 22nd, 2012
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. function createLink(path, name)
  2.     local linkFile
  3.     if not path then
  4.         iox.colorPrint("No path given", colors.red)
  5.         return
  6.     end
  7.     if fs.isDir(path) then
  8.         iox.colorPrint(path.." is a directory, give path to a program file", colors.red)
  9.         return
  10.     end
  11.     if not name then
  12.         name = fs.getName(path)
  13.     end
  14.     if fs.exists("/"..name) then
  15.         iox.colorPrint("File exists: /"..name..", override or cancel? {o|c}", colors.orange)
  16.         local input
  17.         while true do
  18.             input = read()
  19.             if input == "o" then
  20.                 fs.delete("/"..name)
  21.                 break
  22.             elseif input == "c" then
  23.                 return
  24.             else
  25.                 iox.colorPrint("Invalid input, 'o' or 'c'", colors.red)
  26.             end
  27.         end
  28.     end
  29.     linkFile = fs.open(name, "w")
  30.     linkFile.write("shell.run(\""..path.."\", \"{...}\")")
  31.     linkFile.close()
  32. end
Advertisement
Add Comment
Please, Sign In to add comment