comparison core/src/luan/modules/IoLuan.java @ 755:ff865e954934

fix zip to preserve file time
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 18 Jul 2016 05:01:38 -0600
parents ea5f3a254b76
children c29d11d675fd
comparison
equal deleted inserted replaced
754:1a101ac9ea46 755:ff865e954934
222 File file = new File(path,entry.getName()); 222 File file = new File(path,entry.getName());
223 file.getParentFile().mkdirs(); 223 file.getParentFile().mkdirs();
224 OutputStream out = new FileOutputStream(file); 224 OutputStream out = new FileOutputStream(file);
225 Utils.copyAll(in,out); 225 Utils.copyAll(in,out);
226 out.close(); 226 out.close();
227 file.setLastModified(entry.getTime());
227 } 228 }
228 in.close(); 229 in.close();
229 } 230 }
230 231
231 public LuanTable table() { 232 public LuanTable table() {
366 zip(out,basePath,children); 367 zip(out,basePath,children);
367 } else { 368 } else {
368 if( !filePath.startsWith(basePath) ) 369 if( !filePath.startsWith(basePath) )
369 throw new LuanException(filePath+" not in "+basePath); 370 throw new LuanException(filePath+" not in "+basePath);
370 String relPath = filePath.substring(basePath.length()); 371 String relPath = filePath.substring(basePath.length());
371 out.putNextEntry(new ZipEntry(relPath)); 372 ZipEntry entry = new ZipEntry(relPath);
373 entry.setTime(file.lastModified());
374 out.putNextEntry(entry);
372 InputStream in = new FileInputStream(file); 375 InputStream in = new FileInputStream(file);
373 Utils.copyAll(in,out); 376 Utils.copyAll(in,out);
374 in.close(); 377 in.close();
375 out.closeEntry(); 378 out.closeEntry();
376 } 379 }