#!/usr/bin/env python3; ############################################################################### # This program reads bytes from a binary file and copies them to another file. # # Copyright © 2021 Richard Lesh. All rights reserved. ############################################################################### import Utils import sys def copyBinaryFile(fromFilespec, toFilespec) : ifh = open(fromFilespec, "rb") ofh = open(toFilespec, "wb") c = Utils.getbyte(ifh) while c != None : ofh.write(c.to_bytes(1, byteorder='big', signed=False)) c = Utils.getbyte(ifh) ifh.close() ofh.close() # Begin Main if (len(sys.argv) != 3) : print("Syntax: " + sys.argv[0] + " {fromFilespec} {toFilespec}") sys.exit(1) fromFilespec = sys.argv[1] toFilespec = sys.argv[2] try : copyBinaryFile(fromFilespec, toFilespec) except OSError as ex : print("Error: " + str(ex))