| Index: plugins/org.chromium.sdk.wipbackend.wk120709/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java
|
| diff --git a/plugins/org.chromium.sdk.wipbackend.wk120709/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java b/plugins/org.chromium.sdk.wipbackend.wk120709/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java
|
| deleted file mode 100644
|
| index 54135422379260ca7f94045b4575c65aa846f129..0000000000000000000000000000000000000000
|
| --- a/plugins/org.chromium.sdk.wipbackend.wk120709/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java
|
| +++ /dev/null
|
| @@ -1,69 +0,0 @@
|
| -// Copyright (c) 2011 The Chromium Authors. All rights reserved.
|
| -// Use of this source code is governed by a BSD-style license that can be
|
| -// found in the LICENSE file.
|
| -
|
| -package org.chromium.sdk.internal.wip.tools.protocolgenerator;
|
| -
|
| -import java.io.File;
|
| -import java.io.FileInputStream;
|
| -import java.io.FileOutputStream;
|
| -import java.io.IOException;
|
| -import java.io.OutputStream;
|
| -import java.io.OutputStreamWriter;
|
| -import java.io.StringWriter;
|
| -import java.io.Writer;
|
| -
|
| -/**
|
| - * A class that makes accurate java source file update. If only header
|
| - * (with source file revision and other comments) changed, the file is left intact.
|
| - * <p>User first writes all the content into a {@link Writer} provided and then
|
| - * calls {@link #update()}.
|
| - */
|
| -class JavaFileUpdater {
|
| - private final File file;
|
| - private final StringWriter writer;
|
| -
|
| - JavaFileUpdater(File file) {
|
| - this.file = file;
|
| - this.writer = new StringWriter();
|
| - }
|
| -
|
| - Writer getWriter() {
|
| - return writer;
|
| - }
|
| -
|
| - void update() throws IOException {
|
| - writer.close();
|
| -
|
| - String newContent = writer.getBuffer().toString();
|
| -
|
| - if (file.isFile()) {
|
| - String oldContent =
|
| - StreamUtil.readStringFromStream(new FileInputStream(file), StreamUtil.UTF8_CHARSET);
|
| -
|
| - if (stripHeader(oldContent).equals(stripHeader(newContent))) {
|
| - return;
|
| - }
|
| - } else {
|
| - File dir = file.getParentFile();
|
| - boolean dirCreated = dir.mkdirs();
|
| - if (!dirCreated && !dir.isDirectory()) {
|
| - throw new RuntimeException("Failed to create directory " + dir.getPath());
|
| - }
|
| - }
|
| -
|
| - OutputStream outputStream = new FileOutputStream(file);
|
| - Writer fileWriter = new OutputStreamWriter(outputStream, StreamUtil.UTF8_CHARSET);
|
| - fileWriter.write(newContent);
|
| - fileWriter.close();
|
| - outputStream.close();
|
| - }
|
| -
|
| - private static String stripHeader(String content) {
|
| - int pos = content.indexOf("\npackage ");
|
| - if (pos == -1) {
|
| - return content;
|
| - }
|
| - return content.substring(pos);
|
| - }
|
| -}
|
|
|