Advertisement
minimite

zsf

Jun 4th, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.52 KB | None | 0 0
  1. --ZSF by Atenefyr--
  2. --v1.2--
  3. local version = "1.2"
  4. local tArgs = {...}
  5. if #tArgs == 0 then
  6.   print("Usage: zsf <zippy archive>")
  7.   error()
  8. end
  9. local filen = tArgs[1]
  10. if not fs.exists(filen) or fs.isDir(filen) then
  11.   printError("Invalid file!")
  12.   error()
  13. end
  14. local open = fs.open(filen, "r")
  15. local text = open.readAll()
  16. open.close()
  17. --Generate random amount of = signs
  18. local es = ""
  19. for i = 1, math.random(5, 15) do
  20.   es = es .. "="
  21. end
  22. --Format file text
  23. local f = "[" .. es .. "[" .. text .. "]" .. es .. "]"
  24.  
  25. local file = [[
  26. ---Self-Extracting Zippy Archive---
  27. --File generated with Atenefyr's ZSF--
  28. --v]] .. version .. [[--
  29. local file = ]] .. f .. [[
  30.  
  31. --[=[
  32. The MIT License (MIT)
  33.  
  34. Copyright (c) 2015 Shefla
  35.  
  36. Permission is hereby granted, free of charge, to any person obtaining a copy
  37. of this software and associated documentation files (the "Software"), to deal
  38. in the Software without restriction, including without limitation the rights
  39. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  40. copies of the Software, and to permit persons to whom the Software is
  41. furnished to do so, subject to the following conditions:
  42.  
  43. The above copyright notice and this permission notice shall be included in
  44. all copies or substantial portions of the Software.
  45.  
  46. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  47. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  48. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  49. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  50. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  51. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  52. THE SOFTWARE.
  53. ]=]
  54. --Load Zippy API--
  55. local dl = false
  56. function load()
  57.         if fs.exists("zippy") then
  58.         os.loadAPI("zippy")
  59.                 return true
  60.         end
  61.         local txt = http.get("http://pastebin.com/raw.php?i=23QEETmW").readAll()
  62.         local open = fs.open("zippy", "w")
  63.         open.write(txt)
  64.         open.close()
  65.         os.loadAPI("zippy")
  66.         dl = true
  67.         return true
  68. end
  69. load()
  70. --Save file--
  71. local open = fs.open(".archive", "w")
  72. open.write(file)
  73. open.close()
  74. --Extract file--
  75. extract(".archive", "/")
  76. --Delete file--
  77. fs.delete(".archive")
  78. --Delete API if downloaded--
  79. if dl then
  80.   fs.delete("zippy")
  81. end
  82. --Exit program--
  83. print("Done extracting!")
  84. ]]
  85.  
  86. local open = fs.open(filen .. ".zsf", "w")
  87. open.write(file)
  88. open.close()
  89. print("Saved archive to " .. filen .. ".zsf")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement