Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(800)

Unified Diff: plugins/org.chromium.sdk.wipbackend.wk118685/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java

Issue 11829027: drop old backends (Closed) Base URL: https://chromedevtools.googlecode.com/svn/trunk
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: plugins/org.chromium.sdk.wipbackend.wk118685/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java
diff --git a/plugins/org.chromium.sdk.wipbackend.wk118685/src-dynamic-impl/parser/org/chromium/sdk/internal/wip/tools/protocolgenerator/JavaFileUpdater.java b/plugins/org.chromium.sdk.wipbackend.wk118685/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.wk118685/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);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698