1 |
/* ZipOutputStream.java -- |
/* ZipOutputStream.java -- |
2 |
Copyright (C) 2001, 2004 Free Software Foundation, Inc. |
Copyright (C) 2001, 2004, 2005 Free Software Foundation, Inc. |
3 |
|
|
4 |
This file is part of GNU Classpath. |
This file is part of GNU Classpath. |
5 |
|
|
40 |
|
|
41 |
import java.io.IOException; |
import java.io.IOException; |
42 |
import java.io.OutputStream; |
import java.io.OutputStream; |
43 |
|
import java.io.UnsupportedEncodingException; |
44 |
import java.util.Enumeration; |
import java.util.Enumeration; |
45 |
import java.util.Vector; |
import java.util.Vector; |
46 |
|
|
103 |
public void setComment(String comment) |
public void setComment(String comment) |
104 |
{ |
{ |
105 |
byte[] commentBytes; |
byte[] commentBytes; |
106 |
commentBytes = comment.getBytes(); |
try |
107 |
|
{ |
108 |
|
commentBytes = comment.getBytes("UTF-8"); |
109 |
|
} |
110 |
|
catch (UnsupportedEncodingException uee) |
111 |
|
{ |
112 |
|
throw new AssertionError(uee); |
113 |
|
} |
114 |
if (commentBytes.length > 0xffff) |
if (commentBytes.length > 0xffff) |
115 |
throw new IllegalArgumentException("Comment too long."); |
throw new IllegalArgumentException("Comment too long."); |
116 |
zipComment = commentBytes; |
zipComment = commentBytes; |
234 |
writeLeInt(0); |
writeLeInt(0); |
235 |
writeLeInt(0); |
writeLeInt(0); |
236 |
} |
} |
237 |
byte[] name = entry.getName().getBytes(); |
byte[] name; |
238 |
|
try |
239 |
|
{ |
240 |
|
name = entry.getName().getBytes("UTF-8"); |
241 |
|
} |
242 |
|
catch (UnsupportedEncodingException uee) |
243 |
|
{ |
244 |
|
throw new AssertionError(uee); |
245 |
|
} |
246 |
if (name.length > 0xffff) |
if (name.length > 0xffff) |
247 |
throw new ZipException("Name too long."); |
throw new ZipException("Name too long."); |
248 |
byte[] extra = entry.getExtra(); |
byte[] extra = entry.getExtra(); |
373 |
writeLeInt((int)entry.getCompressedSize()); |
writeLeInt((int)entry.getCompressedSize()); |
374 |
writeLeInt((int)entry.getSize()); |
writeLeInt((int)entry.getSize()); |
375 |
|
|
376 |
byte[] name = entry.getName().getBytes(); |
byte[] name; |
377 |
|
try |
378 |
|
{ |
379 |
|
name = entry.getName().getBytes("UTF-8"); |
380 |
|
} |
381 |
|
catch (UnsupportedEncodingException uee) |
382 |
|
{ |
383 |
|
throw new AssertionError(uee); |
384 |
|
} |
385 |
if (name.length > 0xffff) |
if (name.length > 0xffff) |
386 |
throw new ZipException("Name too long."); |
throw new ZipException("Name too long."); |
387 |
byte[] extra = entry.getExtra(); |
byte[] extra = entry.getExtra(); |
388 |
if (extra == null) |
if (extra == null) |
389 |
extra = new byte[0]; |
extra = new byte[0]; |
390 |
String strComment = entry.getComment(); |
String str = entry.getComment(); |
391 |
byte[] comment = strComment != null |
byte[] comment; |
392 |
? strComment.getBytes() : new byte[0]; |
try |
393 |
|
{ |
394 |
|
comment = str != null ? str.getBytes("UTF-8") : new byte[0]; |
395 |
|
} |
396 |
|
catch (UnsupportedEncodingException uee) |
397 |
|
{ |
398 |
|
throw new AssertionError(uee); |
399 |
|
} |
400 |
if (comment.length > 0xffff) |
if (comment.length > 0xffff) |
401 |
throw new ZipException("Comment too long."); |
throw new ZipException("Comment too long."); |
402 |
|
|