mirror of
https://github.com/grp/Wii.py.git
synced 2025-06-19 07:15:49 -04:00
updated compression.py and fixed common.py from printing random shit
This commit is contained in:
parent
c65d1e23b7
commit
cb6b94a323
@ -41,8 +41,6 @@ def hexdump2(src, length = 16): # dumps to a "hex editor" style output
|
|||||||
result.append("0x%04X %-*s %s\n" % (i, (length * 3) + 2, hexa, printable))
|
result.append("0x%04X %-*s %s\n" % (i, (length * 3) + 2, hexa, printable))
|
||||||
return ''.join(result)
|
return ''.join(result)
|
||||||
|
|
||||||
print hexdump2("RANDOM STRING \x01 TESTING \x214 TEST OF STrasneljkasdhfleasdklhglkaje;shadlkghehaosehlgasdlkfhe;lakhsdglhaelksejdfffffffjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjasdfsadf")
|
|
||||||
|
|
||||||
class Crypto(object):
|
class Crypto(object):
|
||||||
"""This is a Cryptographic/hash class used to abstract away things (to make changes easier)"""
|
"""This is a Cryptographic/hash class used to abstract away things (to make changes easier)"""
|
||||||
align = 64
|
align = 64
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from common import *
|
from common import *
|
||||||
|
|
||||||
class LZ77():
|
class LZ77(WiiHeader):
|
||||||
class WiiLZ77: #class by marcan
|
class WiiLZ77: # class by marcan, used under scope of BSD license
|
||||||
TYPE_LZ77 = 1
|
TYPE_LZ77 = 1
|
||||||
def __init__(self, file, offset):
|
def __init__(self, file, offset):
|
||||||
self.file = file
|
self.file = file
|
||||||
@ -42,34 +42,15 @@ class LZ77():
|
|||||||
break
|
break
|
||||||
self.data = dout
|
self.data = dout
|
||||||
return self.data
|
return self.data
|
||||||
def __init__(self, f):
|
def remove(self):
|
||||||
self.f = f
|
hdr = self.data[:4]
|
||||||
def decompress(self, fn = ""):
|
|
||||||
"""This uncompresses a LZ77 compressed file, specified in f in the initializer. It outputs the file in either fn, if it isn't empty, or overwrites the input if it is. Returns the output filename."""
|
|
||||||
file = open(self.f, "rb")
|
|
||||||
hdr = file.read(4)
|
|
||||||
if hdr != "LZ77":
|
if hdr != "LZ77":
|
||||||
if(fn == ""):
|
return self.data
|
||||||
return self.f
|
file = StringIO.StringIO(self.data)
|
||||||
else:
|
file.seek(4)
|
||||||
data = open(self.f, "rb").read()
|
|
||||||
open(fn, "wb").write(data)
|
|
||||||
unc = self.WiiLZ77(file, file.tell())
|
unc = self.WiiLZ77(file, file.tell())
|
||||||
data = unc.uncompress()
|
data = unc.uncompress()
|
||||||
file.close()
|
|
||||||
|
|
||||||
if(fn != ""):
|
return data
|
||||||
open(fn, "wb").write(data)
|
|
||||||
return fn
|
|
||||||
else:
|
|
||||||
open(self.f, "wb").write(data)
|
|
||||||
return self.f
|
|
||||||
def compress(self, fn = ""):
|
def compress(self, fn = ""):
|
||||||
"""This will eventually add LZ77 compression to a file. Does nothing for now."""
|
raise NotImplementedError
|
||||||
if(fn != ""):
|
|
||||||
#subprocess.call(["./gbalzss", self.f, fn, "-pack"])
|
|
||||||
return fn
|
|
||||||
else:
|
|
||||||
#subprocess.call(["./gbalzss", self.f, self.f, "-pack"])
|
|
||||||
return self.f
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user