| 1 | require 'find' |
|---|
| 2 | |
|---|
| 3 | def add_license(filename,txt) |
|---|
| 4 | filename2=filename+'_tmp' |
|---|
| 5 | s = File.readlines(filename) |
|---|
| 6 | if s[0]=~/BEGIN LICENSE/ |
|---|
| 7 | return false |
|---|
| 8 | end |
|---|
| 9 | file2 = File.new(filename2,"w") |
|---|
| 10 | file2.write(txt) |
|---|
| 11 | file2.write(s) |
|---|
| 12 | file2.close |
|---|
| 13 | File.delete(filename) |
|---|
| 14 | File.rename(filename2,filename) |
|---|
| 15 | true |
|---|
| 16 | end |
|---|
| 17 | |
|---|
| 18 | for_cs = <<EOS |
|---|
| 19 | /* ***** BEGIN LICENSE BLOCK ***** |
|---|
| 20 | * Version: MPL 1.1 |
|---|
| 21 | * |
|---|
| 22 | * The contents of this file are subject to the Mozilla Public License |
|---|
| 23 | * Version 1.1 (the "License"); you may not use this file except in |
|---|
| 24 | * compliance with the License. You may obtain a copy of the License at |
|---|
| 25 | * http://www.mozilla.org/MPL/ |
|---|
| 26 | * |
|---|
| 27 | * Software distributed under the License is distributed on an "AS IS" |
|---|
| 28 | * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|---|
| 29 | * License for the specific language governing rights and limitations |
|---|
| 30 | * under the License. |
|---|
| 31 | * |
|---|
| 32 | * The Original Code is tyzoh.jp code. |
|---|
| 33 | * |
|---|
| 34 | * The Initial Developer of the Original Code is Kazutaka Kurihara. |
|---|
| 35 | * Portions created by the Initial Developer are Copyright (C) 2007 |
|---|
| 36 | * the Initial Developer. All Rights Reserved. |
|---|
| 37 | * |
|---|
| 38 | * Contributor(s): |
|---|
| 39 | * |
|---|
| 40 | * ***** END LICENSE BLOCK ***** */ |
|---|
| 41 | EOS |
|---|
| 42 | |
|---|
| 43 | for_xml = <<EOS |
|---|
| 44 | <!-- ***** BEGIN LICENSE BLOCK ***** |
|---|
| 45 | - Version: MPL 1.1 |
|---|
| 46 | - |
|---|
| 47 | - The contents of this file are subject to the Mozilla Public License |
|---|
| 48 | - Version 1.1 (the "License"); you may not use this file except in |
|---|
| 49 | - compliance with the License. You may obtain a copy of the License at |
|---|
| 50 | - http://www.mozilla.org/MPL/ |
|---|
| 51 | - |
|---|
| 52 | - Software distributed under the License is distributed on an "AS IS" |
|---|
| 53 | - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|---|
| 54 | - License for the specific language governing rights and limitations |
|---|
| 55 | - under the License. |
|---|
| 56 | - |
|---|
| 57 | - The Original Code is tyzoh.jp code. |
|---|
| 58 | - |
|---|
| 59 | - The Initial Developer of the Original Code is Kazutaka Kurihara. |
|---|
| 60 | - Portions created by the Initial Developer are Copyright (C) 2007 |
|---|
| 61 | - the Initial Developer. All Rights Reserved. |
|---|
| 62 | - |
|---|
| 63 | - Contributor(s): |
|---|
| 64 | - |
|---|
| 65 | - ***** END LICENSE BLOCK ***** --> |
|---|
| 66 | EOS |
|---|
| 67 | |
|---|
| 68 | Find.find('.') do |path| |
|---|
| 69 | if path=~/\.cs$/ then |
|---|
| 70 | if add_license(path,for_cs) |
|---|
| 71 | puts path |
|---|
| 72 | end |
|---|
| 73 | end |
|---|
| 74 | end |
|---|