aboutsummaryrefslogtreecommitdiffstats
path: root/common/src/com/android/io/FileWrapper.java
diff options
context:
space:
mode:
authorXavier Ducrohet <xav@android.com>2012-12-06 16:46:55 -0800
committerXavier Ducrohet <xav@android.com>2012-12-06 16:49:45 -0800
commit9838fb6330c77935c09877066ff635a694aa87e1 (patch)
tree979b5589ce7ab81e8f239473e9e9dd956979c354 /common/src/com/android/io/FileWrapper.java
parent2b5876214e16f845d7b94857a39a83f8b8b7ef85 (diff)
downloadsdk-9838fb6330c77935c09877066ff635a694aa87e1.zip
sdk-9838fb6330c77935c09877066ff635a694aa87e1.tar.gz
sdk-9838fb6330c77935c09877066ff635a694aa87e1.tar.bz2
Refactor common lib folder structure.
Move folders around to match default gradle/maven folder structure. The custom structure confused some IDEs when importing the project as a Gradle project. Change-Id: I4c5b3ba0c145418c3a48fead2edf370864a56dd5
Diffstat (limited to 'common/src/com/android/io/FileWrapper.java')
-rw-r--r--common/src/com/android/io/FileWrapper.java158
1 files changed, 0 insertions, 158 deletions
diff --git a/common/src/com/android/io/FileWrapper.java b/common/src/com/android/io/FileWrapper.java
deleted file mode 100644
index 8be7859..0000000
--- a/common/src/com/android/io/FileWrapper.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.io;
-
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URI;
-
-/**
- * An implementation of {@link IAbstractFile} extending {@link File}.
- */
-public class FileWrapper extends File implements IAbstractFile {
- private static final long serialVersionUID = 1L;
-
- /**
- * Creates a new File instance matching a given {@link File} object.
- * @param file the file to match
- */
- public FileWrapper(File file) {
- super(file.getAbsolutePath());
- }
-
- /**
- * Creates a new File instance from a parent abstract pathname and a child pathname string.
- * @param parent the parent pathname
- * @param child the child name
- *
- * @see File#File(File, String)
- */
- public FileWrapper(File parent, String child) {
- super(parent, child);
- }
-
- /**
- * Creates a new File instance by converting the given pathname string into an abstract
- * pathname.
- * @param osPathname the OS pathname
- *
- * @see File#File(String)
- */
- public FileWrapper(String osPathname) {
- super(osPathname);
- }
-
- /**
- * Creates a new File instance from a parent abstract pathname and a child pathname string.
- * @param parent the parent pathname
- * @param child the child name
- *
- * @see File#File(String, String)
- */
- public FileWrapper(String parent, String child) {
- super(parent, child);
- }
-
- /**
- * Creates a new File instance by converting the given <code>file:</code> URI into an
- * abstract pathname.
- * @param uri An absolute, hierarchical URI with a scheme equal to "file", a non-empty path
- * component, and undefined authority, query, and fragment components
- *
- * @see File#File(URI)
- */
- public FileWrapper(URI uri) {
- super(uri);
- }
-
- @Override
- public InputStream getContents() throws StreamException {
- try {
- return new FileInputStream(this);
- } catch (FileNotFoundException e) {
- throw new StreamException(e, this, StreamException.Error.FILENOTFOUND);
- }
- }
-
- @Override
- public void setContents(InputStream source) throws StreamException {
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(this);
-
- byte[] buffer = new byte[1024];
- int count = 0;
- while ((count = source.read(buffer)) != -1) {
- fos.write(buffer, 0, count);
- }
- } catch (IOException e) {
- throw new StreamException(e, this);
- } finally {
- if (fos != null) {
- try {
- fos.close();
- } catch (IOException e) {
- throw new StreamException(e, this);
- }
- }
- }
- }
-
- @Override
- public OutputStream getOutputStream() throws StreamException {
- try {
- return new FileOutputStream(this);
- } catch (FileNotFoundException e) {
- throw new StreamException(e, this);
- }
- }
-
- @Override
- public PreferredWriteMode getPreferredWriteMode() {
- return PreferredWriteMode.OUTPUTSTREAM;
- }
-
- @Override
- public String getOsLocation() {
- return getAbsolutePath();
- }
-
- @Override
- public boolean exists() {
- return isFile();
- }
-
- @Override
- public long getModificationStamp() {
- return lastModified();
- }
-
- @Override
- public IAbstractFolder getParentFolder() {
- String p = this.getParent();
- if (p == null) {
- return null;
- }
- return new FolderWrapper(p);
- }
-}