Changeset 13307
- Timestamp:
- 05/30/11 15:12:02 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abcl/src/org/armedbear/lisp/zip.java
r13016 r13307 37 37 38 38 import java.io.File; 39 import java.io.FileNotFoundException; 39 40 import java.io.FileInputStream; 40 41 import java.io.FileOutputStream; … … 84 85 } 85 86 File file = new File(namestring); 86 FileInputStream in = new FileInputStream(file); 87 ZipEntry entry = new ZipEntry(file.getName()); 88 out.putNextEntry(entry); 89 int n; 90 while ((n = in.read(buffer)) > 0) 91 out.write(buffer, 0, n); 92 out.closeEntry(); 93 in.close(); 87 makeEntry(out, file); 94 88 list = list.cdr(); 95 89 } … … 106 100 { 107 101 Pathname zipfilePathname = coerceToPathname(first); 108 byte[] buffer = new byte[4096];109 102 try { 110 103 String zipfileNamestring = zipfilePathname.getNamestring(); … … 152 145 continue; 153 146 } 154 FileInputStream in = new FileInputStream(file); 155 ZipEntry entry = new ZipEntry(directory + file.getName()); 156 out.putNextEntry(entry); 157 int n; 158 while ((n = in.read(buffer)) > 0) 159 out.write(buffer, 0, n); 160 out.closeEntry(); 161 in.close(); 147 makeEntry(out, file, directory + file.getName()); 162 148 list = list.cdr(); 163 149 } … … 170 156 } 171 157 158 private static final Primitive zip = new zip(); 172 159 173 private static final Primitive zip = new zip(); 160 private void makeEntry(ZipOutputStream zip, File file) 161 throws FileNotFoundException, IOException 162 { 163 makeEntry(zip, file, file.getName()); 164 } 165 166 private void makeEntry(ZipOutputStream zip, File file, String name) 167 throws FileNotFoundException, IOException 168 { 169 byte[] buffer = new byte[4096]; 170 long lastModified = file.lastModified(); 171 FileInputStream in = new FileInputStream(file); 172 ZipEntry entry = new ZipEntry(name); 173 if (lastModified > 0) { 174 entry.setTime(lastModified); 175 } 176 zip.putNextEntry(entry); 177 int n; 178 while ((n = in.read(buffer)) > 0) 179 zip.write(buffer, 0, n); 180 zip.closeEntry(); 181 in.close(); 182 } 183 174 184 }
Note: See TracChangeset
for help on using the changeset viewer.