{simple,shoddy,smart} minsize-oriented linker
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

27 lines
625 B

#!/usr/bin/env python3
import argparse
import sys
def main(argv):
parser = argparse.ArgumentParser()
# TODO: output null -> in-place!
parser.add_argument('input', type=argparse.FileType('rb'), \
help="input file to truncate")
parser.add_argument('output', type=argparse.FileType('wb'), \
help="output file")
args = parser.parse_args()
data = args.input.read()
i = 0
while data[-i - 1] == 0:
i = i + 1
args.output.write(data[0:len(data)-i])
if __name__ == '__main__':
rv = main(sys.argv)
exit(0 if rv is None else rv)