Andy73

NOT FUNCTIONAL AndyCode Archiver Prototype

Apr 13th, 2014
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.63 KB | None | 0 0
  1. --[[
  2. Pure Lua archiver made by Andy73 a.k.a. viluon
  3.  
  4. Copyright 2014
  5. version 0.3 BETA (2nd public release)
  6.  
  7. usage: archiver <compress|extract|help> <file input path> <file output path>
  8.  
  9. NOT YET FUNCTIONAL!!!
  10.  
  11.  
  12. Dev notes:
  13. -add "ó","ď","ť" and "ň"
  14. -complete fs API translations
  15. -add IO API transl.
  16. -add string API transl.
  17. ]]
  18.  
  19. local s=48
  20.  
  21. local function help()
  22. print("Pure Lua archiver by Andy a.k.a. viluon copyright 2014")
  23. print("version 0.3 BETA")
  24. print("")
  25. print("Current dictionary size: "..s.." keywords")
  26. print("")
  27. print("Please note:Beta versions can cause unexpected data changes. Andy is not responsible for any data corruption or removals caused by this program. Use at your own risk.")
  28. end
  29.  
  30. local function usage()
  31. print("Usage:")
  32. print(" archiver <compress|extract|help> <file input path> <file output path>")
  33. print("'compress','extract' or 'help' can be shortened to 'c','e' or '?'")
  34. end
  35.  
  36. local tArgs={…}
  37.  
  38. if tArgs[1]=="compress" or "c" then
  39. compress(tArgs[2],tArgs[3])
  40. elseif tArgs[1]=="extract" or "e" then
  41. extract(tArgs[2],tArgs[3])
  42. elseif tArgs[1]=="help" or "?" then
  43. help()
  44. else
  45. usage()
  46. end
  47.  
  48. local function r(a,b)
  49. t=string.gsub(t,a,b)
  50. end
  51.  
  52. --COMPRESS
  53. local function compress(...)
  54. local args={...}
  55. local file=io.open(args[1],"r")
  56. print("FileSize original:"..fs.getSize(args[1]))
  57. local t=file.readAll()
  58. file:close()
  59. --t is a string, will be later saved
  60. --FIRST ROUND SYMBOL @ (12x)
  61. r("true","@ě") --new format
  62. r("false","@š")
  63. r("setTextScale","@č")
  64. r("setBackgroundColor","@ř")
  65. r("os.loadAPI","@ž")
  66. r("color","@ý")
  67. r("setTextColor","@á")
  68. r("text","@í")
  69. r("Text","@é")
  70. r("write","@ú")
  71. r("elseif","@ů")
  72. r("local","@ˇ")
  73. r("function","@´")
  74. --SECOND ROUND SYMBOL # (12x)
  75. r("then","#ě")
  76. r("end","#š")
  77. r("else","#č")
  78. r("tostring%(","#ř")
  79. r("tonumber%(","#ž")
  80. r("string","#ý")
  81. r("math","#á")
  82. r("=os.pullEventRaw%(","#í")
  83. r("=os.pullEvent%(","#é")
  84. r("= os.pullEventRaw%(","#ú")
  85. r("= os.pullEvent%(","#ů")
  86. r("window","#ˇ")
  87. r("process","#´")
  88. --THIRD ROUND SYMBOL ! (12x)
  89. r("and","!ě")
  90. r("not","!š")
  91. r("print","!č")
  92. r(" == ","!ř")
  93. r(" ~= ","!ž")
  94. r("= fs.exists%(","!ý")
  95. r("=pcall%(","!á")
  96. r("= pcall%(","!í")
  97. r("pcall%(","!é")
  98. r("=fs.open%(","!ú")
  99. r("= fs.open%(","!ů")
  100. r("fs.exists%(","!ˇ")
  101. r("print%(","!´")
  102. --FOURTH ROUND SYMBOL / (12x)
  103. r("=fs.isDir%(","/š")
  104. r("= fs.isDir%(","/č")
  105. r("fs.isDir%(","/ř")
  106. r("=fs.isReadOnly%(","/ž")
  107. r("= fs.isReadOnly%(","/ý")
  108. r("fs.isReadOnly%(","/á")
  109. r("=fs.getDrive%(","/í")
  110. r("= fs.getDrive%(","/é")
  111. r("fs.getDrive%(","/ú")
  112. r("=fs.getSize%(","/ů")
  113. r("= fs.getSize%(","/ˇ")
  114. r("fs.getSize%(","/´")
  115.  
  116. local target=fs.open(args[2],"w")
  117. target.write(t)
  118. target:close()
  119.  
  120. print("FileSize comprimed:"..fs.getSize(args[2]))
  121. one=fs.getSize(args[1])/100
  122. size=fs.getSize(args[2])
  123. percent=100-size/one
  124. print("comprimed by "..percent.."%")
  125. end
  126.  
  127.  
  128. --[[
  129. t=r(t,"true","/š")
  130. t=r(t,"true","/č")
  131. t=r(t,"true","/ř")
  132. t=r(t,"true","/ž")
  133. t=r(t,"true","/ý")
  134. t=r(t,"true","/á")
  135. t=r(t,"true","/í")
  136. t=r(t,"true","/é")
  137. t=r(t,"true","/ú")
  138. t=r(t,"true","/ů")
  139. t=r(t,"true","/ˇ")
  140. t=r(t,"true","/´")
  141. ]]
  142.  
  143. --EXTRACT
  144. local function extract(...)
  145. local args={...}
  146. local file=io.open(args[1],"r")
  147.  
  148. local t=file.readAll()
  149. file:close()
  150. --t is a string, will be later saved
  151. --FIRST ROUND SYMBOL @ (12x)
  152. r("@ě","true")
  153. r("@š","false")
  154. r("@č","setTextScale")
  155. r("@ř","setBackgroundColor")
  156. r("@ž","os.loadAPI")
  157. r("@ý","color")
  158. r("@á","setTextColor")
  159. r("@í","text")
  160. r("@é","Text")
  161. r("@ú","write")
  162. r("@ů","elseif")
  163. r("@ˇ","local")
  164. r("@´","function")
  165. --SECOND ROUND SYMBOL # (12x)
  166. r("#ě","then")
  167. r("#š","end")
  168. r("#č","else")
  169. r("#ř","tostring%(")
  170. r("#ž","tonumber%(")
  171. r("#ý","string")
  172. r("#á","math")
  173. r("#í","=os.pullEventRaw%(")
  174. r("#é","=os.pullEvent%(")
  175. r("#ú","= os.pullEventRaw%(")
  176. r("#ů","= os.pullEvent%(")
  177. r("#ˇ","window")
  178. r("#´","process")
  179. --THIRD ROUND SYMBOL ! (12x)
  180. r("!ě","and")
  181. r("!š","not")
  182. r("!č","print")
  183. r("!ř"," == ")
  184. r("!ž"," ~= ")
  185. r("!ý","= fs.exists%(")
  186. r("!á","=pcall%(")
  187. r("!í","= pcall%(")
  188. r("!é","pcall%(")
  189. r("!ú","=fs.open%(")
  190. r("!ů","= fs.open%(")
  191. r("!ˇ","fs.exists%(")
  192. r("!´","print%(")
  193. --FOURTH ROUND SYMBOL / (12x)
  194. r("/š","=fs.isDir%(")
  195. r("/č","= fs.isDir%(")
  196. r("/ř","fs.isDir%(")
  197. r("/ž","=fs.isReadOnly%(")
  198. r("/ý","= fs.isReadOnly%(")
  199. r("/á","fs.isReadOnly%(")
  200. r("/í","=fs.getDrive%(")
  201. r("/é","= fs.getDrive%(")
  202. r("/ú","fs.getDrive%(")
  203. r("/ů","=fs.getSize%(")
  204. r("/ˇ","= fs.getSize%(")
  205. r("/´","fs.getSize%(")
  206.  
  207. local target=fs.open(args[2],"w")
  208. target.write(t)
  209. target:close()
  210.  
  211. print("done!")
  212. end
Advertisement
Add Comment
Please, Sign In to add comment