Java 类com.intellij.util.io.SafeFileOutputStream 实例源码

项目:intellij-ce-playground    文件:LocalFileSystemBase.java   
@Override
@NotNull
public OutputStream getOutputStream(@NotNull VirtualFile file, Object requestor, long modStamp, final long timeStamp) throws IOException {
  final File ioFile = convertToIOFileAndCheck(file);
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final OutputStream stream = shallUseSafeStream(requestor, file) ?
                              new SafeFileOutputStream(ioFile, SystemInfo.isUnix) : new FileOutputStream(ioFile);
  return new BufferedOutputStream(stream) {
    @Override
    public void close() throws IOException {
      super.close();
      if (timeStamp > 0 && ioFile.exists()) {
        if (!ioFile.setLastModified(timeStamp)) {
          LOG.warn("Failed: " + ioFile.getPath() + ", new:" + timeStamp + ", old:" + ioFile.lastModified());
        }
      }
    }
  };
}
项目:tools-idea    文件:LocalFileSystemBase.java   
@Override
@NotNull
public OutputStream getOutputStream(@NotNull VirtualFile file, Object requestor, long modStamp, final long timeStamp) throws IOException {
  final File ioFile = convertToIOFileAndCheck(file);
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final OutputStream stream = shallUseSafeStream(requestor, file) ?
                              new SafeFileOutputStream(ioFile, SystemInfo.isUnix) : new FileOutputStream(ioFile);
  return new BufferedOutputStream(stream) {
    @Override
    public void close() throws IOException {
      super.close();
      if (timeStamp > 0 && ioFile.exists()) {
        if (!ioFile.setLastModified(timeStamp)) {
          LOG.warn("Failed: " + ioFile.getPath() + ", new:" + timeStamp + ", old:" + ioFile.lastModified());
        }
      }
    }
  };
}
项目:consulo    文件:LocalFileSystemBase.java   
@Override
@Nonnull
public OutputStream getOutputStream(@Nonnull VirtualFile file, Object requestor, long modStamp, final long timeStamp) throws IOException {
  final File ioFile = convertToIOFileAndCheck(file);
  @SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
  final OutputStream stream = shallUseSafeStream(requestor, file) ?
                              new SafeFileOutputStream(ioFile, SystemInfo.isUnix) : new FileOutputStream(ioFile);
  return new BufferedOutputStream(stream) {
    @Override
    public void close() throws IOException {
      super.close();
      if (timeStamp > 0 && ioFile.exists()) {
        if (!ioFile.setLastModified(timeStamp)) {
          LOG.warn("Failed: " + ioFile.getPath() + ", new:" + timeStamp + ", old:" + ioFile.lastModified());
        }
      }
    }
  };
}