Created
December 9, 2011 13:45
-
-
Save sahib/1451589 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'find' | |
require 'tempfile' | |
$license = <<-eos | |
/* Cats insert there license here | |
* Hmm. Replace this. | |
*/ | |
eos | |
# Insert license at beginning, using a crappy tmp file. | |
def do_prepend path | |
Tempfile.open File.basename(path) do |tempfile| | |
tempfile << $license | |
File.open(path, 'r+') do |file| | |
tempfile << file.read | |
file.pos = tempfile.pos = 0 | |
file << tempfile.read | |
end | |
end | |
end | |
# Recurse everything in $pwd | |
Find.find('./') do |file| | |
if file.end_with? ".cc" or file.end_with? ".hh" | |
if File.writable? file | |
puts "Adding license to: #{file}" | |
do_prepend file | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment