1 /* -*- mode: java -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is [Open Source Virtual Machine.].
17 * The Initial Developer of the Original Code is
18 * Adobe System Incorporated.
19 * Portions created by the Initial Developer are Copyright (C) 2009
20 * the Initial Developer. All Rights Reserved.
25 * Alternatively, the contents of this file may be used under the terms of
26 * either the GNU General Public License Version 2 or later (the "GPL"), or
27 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 /* Utility to stitch ABC files together into a single swf.
43 * swfmake [-c] [-o filename] abcfile ...
45 * -o filename defines the name of the output file
47 * -c creates a compressed swf
49 * By default the name of the output file is the name of the first abc
50 * file with ".abc" replaced by ".swf", and the swf file is uncompressed.
59 var output_name
= null;
60 var compress
= undefined;
63 var argc
=System.argv
.length
;
69 if (output_name
!= null || i
+1 == argc
)
71 output_name
= argv
[i
+1];
75 if (compress
is Boolean)
80 else if (s
.charAt
(0) == "-") {
89 if (!(compress
is Boolean))
92 if (input_names
.length
== 0)
95 if (output_name
== null) {
97 if (s
.match
(/\.abc
$/))
98 output_name
= s
.replace
(/\.abc
$/, ".swf");
100 output_name
= s
+ ".swf";
103 var body
= new ByteArray();
104 body
.endian
= "littleEndian";
105 body
.writeByte
(2 << 3); // RECT: 2 bits per dim
106 body
.writeByte
(0); // and they're all zero
107 body
.writeShort
(0); // framerate
108 body
.writeShort
(0); // framecount
110 for ( i
=0 ; i
< input_names
.length
; i
++ ) {
112 var bytes
= ByteArray.readFile
(s
);
113 body
.writeShort
((82 << 6) | 63); // DoABC, extended length
114 body
.writeUnsignedInt
(bytes
.length
+ 4 + s
.length
+ 1);
115 body
.writeUnsignedInt
(0); // flags
116 for ( j
=0 ; j
< s
.length
; j
++ )
117 body
.writeByte
(s
.charCodeAt
(j
) & 255);
119 body
.writeBytes
(bytes
);
121 body
.writeShort
(0); // End
123 var numbytes
= body
.length
+ 8;
128 var result
= new ByteArray();
129 result
.endian
= "littleEndian";
130 result
.writeByte
((compress
? 'C' : 'F').charCodeAt
(0));
131 result
.writeByte
('W'.charCodeAt
(0));
132 result
.writeByte
('S'.charCodeAt
(0));
134 result
.writeUnsignedInt
(numbytes
);
135 result
.writeBytes
(body
);
136 File.writeByteArray
(output_name
, result
);
140 print
("Usage: avmshell swfmake.abc -- [-c] [-o filename] abcfile ...");