Created
July 4, 2011 05:26
-
-
Save drx/1062937 to your computer and use it in GitHub Desktop.
Inject a file into another file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import os | |
try: | |
fn = sys.argv[1] | |
except IndexError: | |
fn = 'LOOPTEST.SND' | |
out_fn = 'NULL.DAT' | |
in_data = open(fn, 'rb').read() | |
if len(in_data) > os.path.getsize(out_fn): | |
raise Exception('Input file larger than output file') | |
out_f = open(out_fn, 'r+b') | |
out_f.seek(0) | |
out_f.write(in_data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment