Skip to content

Instantly share code, notes, and snippets.

@drx
Created July 4, 2011 05:26
Show Gist options
  • Save drx/1062937 to your computer and use it in GitHub Desktop.
Save drx/1062937 to your computer and use it in GitHub Desktop.
Inject a file into another file
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