コード例 #1
0
ファイル: StaticResource.java プロジェクト: hds1989824/lizar
 private static void read_file(EventLoader event_loader, String path, boolean need_cache) {
   Pair<Long, List<String>> b = null;
   try {
     b = read(path);
   } catch (FileNotFoundException e) {
     response_not_found(event_loader, path);
     return;
   } catch (IOException e) {
     event_loader.log.error(
         "request:" + event_loader.request_path() + " read failed for read file " + path, e);
     response_not_found(event_loader, path);
     return;
   }
   if (b == null || b.getValue().isEmpty()) {
     response_not_found(event_loader, path);
     return;
   } else {
     if (need_cache && b.getKey() < instance.file_max_size) {
       Resource r = new Resource(b.getValue());
       r.file = new File(path);
       r.last_modify_time = last_modify_time(path);
       file_map.put(MyMath.encryptionWithMD5(path), r);
     }
     write(b.getValue(), event_loader);
   }
 }