Exemplo n.º 1
0
 @Override
 public OutputStream getCacheOutputStream(SourceId sourceId) {
   if (sourceId.getSourceSupplier() != this) return null;
   if (sourceId.source1 != null) {
     return mySup1.getCacheOutputStream(sourceId.source1);
   } else {
     return mySup2.getCacheOutputStream(sourceId.source2);
   }
 }
Exemplo n.º 2
0
 @Override
 public boolean isAvailable(SourceId sourceId) {
   if (sourceId.getStorage() != this) return false;
   Path file = sourceFileForSource(sourceId);
   try {
     return Files.exists(file) && Files.getLastModifiedTime(file).equals(sourceId.myMtime);
   } catch (IOException ignored) {
   }
   return false;
 }
Exemplo n.º 3
0
 @Override
 public OutputStream getCacheOutputStream(SourceId sourceId) {
   if (sourceId.getStorage() != this) return null;
   Path file = cacheFileForSource(sourceId);
   try {
     Files.createDirectories(file.getParent());
     return Files.newOutputStream(file);
   } catch (IOException ignored) {
   }
   return null;
 }
Exemplo n.º 4
0
  @Override
  public Abstract.ClassDefinition loadSource(SourceId sourceId, ErrorReporter errorReporter)
      throws IOException {
    if (sourceId.getStorage() != this) return null;
    if (!isAvailable(sourceId)) return null;

    Path file = sourceFileForSource(sourceId);
    FileSource fileSource = new FileSource(sourceId, file);
    Abstract.ClassDefinition definition = fileSource.load(errorReporter);
    // Make sure we loaded the right revision
    return Files.getLastModifiedTime(file).equals(sourceId.myMtime) ? definition : null;
  }
Exemplo n.º 5
0
 @Override
 public InputStream getCacheInputStream(SourceId sourceId) {
   if (sourceId.getStorage() != this) return null;
   Path file = cacheFileForSource(sourceId);
   if (Files.isReadable(file)) {
     try {
       return Files.newInputStream(file);
     } catch (IOException ignored) {
     }
   }
   return null;
 }
Exemplo n.º 6
0
 private Path cacheFileForSource(SourceId sourceId) {
   return cacheFile(baseFile(sourceId.getModulePath()), sourceId.myMtime.toMillis());
 }
Exemplo n.º 7
0
 private Path sourceFileForSource(SourceId sourceId) {
   return sourceFile(baseFile(sourceId.getModulePath()));
 }