Init.
This commit is contained in:
commit
a70defc85f
7 changed files with 83 additions and 0 deletions
30
compress.py
Executable file
30
compress.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env -S python3
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
[_, input] = sys.argv
|
||||
input_tar = input + ".tar"
|
||||
output = input + ".cprmt"
|
||||
print("Compressing '" + input + "' into '" + output + "'.")
|
||||
subprocess.Popen(["tar", "cf", input_tar, input]).wait()
|
||||
input_tar_fd = open(input_tar, "rb")
|
||||
output_fd = open(output, "wb")
|
||||
byte_index = 0
|
||||
while True:
|
||||
read = input_tar_fd.read(1024)
|
||||
if len(read) == 0:
|
||||
break
|
||||
for byte in read:
|
||||
if byte_index == 0:
|
||||
output_fd.write(bytes([5, byte]))
|
||||
else:
|
||||
output_fd.write(bytes([byte]))
|
||||
byte_index += 1
|
||||
byte_index %= 4
|
||||
print("Done.")
|
||||
|
||||
|
||||
if __name__ == "__main__": main()
|
Loading…
Add table
Add a link
Reference in a new issue