public OutputStream openFile()

in report-builder/src/jetbrains/coverage/report/impl/html/fs/ZipFileSystem.java [47:88]


  public OutputStream openFile(@NotNull File path) throws IOException {
    String rel = IOUtil.makeRelative(myBase, path);
    if (!myFiles.add(rel)) {
      System.err.println(getClass().getCanonicalName() + ": Attepting to write to " + rel + " second time. Fake output stream will be returned to avoid error");
      return new OutputStream() {
        @Override
        public void write(int b) throws IOException {
        }
      };
    }

    if (!myIsWriting.compareAndSet(false, true)) {
      throw new IOException("Failed to open more than one writer into zip");
    }

    myZos.putNextEntry(new ZipEntry(rel));
    return new OutputStream() {
      @Override
      public void write(int b) throws IOException {
        myZos.write(b);
      }

      @Override
      public void write(byte[] b) throws IOException {
        myZos.write(b);
      }

      @Override
      public void write(byte[] b, int off, int len) throws IOException {
        myZos.write(b, off, len);
      }

      @Override
      public void close() throws IOException {
        try {
          myZos.closeEntry();
        } finally {
          myIsWriting.set(false);
        }
      }
    };
  }