summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jack/src/com/android/jack/Options.java6
-rw-r--r--jack/src/com/android/jack/incremental/CommonFilter.java4
-rw-r--r--jack/tests/com/android/jack/TestTools.java4
-rw-r--r--sched/src/com/android/sched/util/codec/DirectDirInputOutputVFSCodec.java4
-rw-r--r--sched/src/com/android/sched/util/codec/DirectFSCodec.java4
-rw-r--r--sched/src/com/android/sched/vfs/CachedDirectFS.java311
-rw-r--r--sched/src/com/android/sched/vfs/ReadWriteZipFS.java4
-rw-r--r--sched/tests/com/android/sched/vfs/VFSTest.java43
8 files changed, 13 insertions, 367 deletions
diff --git a/jack/src/com/android/jack/Options.java b/jack/src/com/android/jack/Options.java
index 7028a8d..820aa17 100644
--- a/jack/src/com/android/jack/Options.java
+++ b/jack/src/com/android/jack/Options.java
@@ -64,8 +64,8 @@ import com.android.sched.util.location.StringLocation;
import com.android.sched.util.log.LoggerFactory;
import com.android.sched.util.log.TracerFactory;
import com.android.sched.util.log.tracer.StatsTracerFtl;
-import com.android.sched.vfs.CachedDirectFS;
import com.android.sched.vfs.Container;
+import com.android.sched.vfs.DirectFS;
import com.android.sched.vfs.OutputVFS;
import com.android.sched.vfs.VFS;
@@ -626,8 +626,8 @@ public class Options {
} else {
configBuilder.set(GENERATE_JACK_LIBRARY, true);
configBuilder.set(LIBRARY_OUTPUT_CONTAINER_TYPE, Container.DIR);
- configBuilder.set(Options.LIBRARY_OUTPUT_DIR, new CachedDirectFS(
- createTempDirForTypeDexFiles(hooks), Permission.READ | Permission.WRITE));
+ configBuilder.set(Options.LIBRARY_OUTPUT_DIR,
+ new DirectFS(createTempDirForTypeDexFiles(hooks), Permission.READ | Permission.WRITE));
}
switch (multiDexKind) {
diff --git a/jack/src/com/android/jack/incremental/CommonFilter.java b/jack/src/com/android/jack/incremental/CommonFilter.java
index f0ceb3d..2f76ce8 100644
--- a/jack/src/com/android/jack/incremental/CommonFilter.java
+++ b/jack/src/com/android/jack/incremental/CommonFilter.java
@@ -39,8 +39,8 @@ import com.android.sched.util.file.FileOrDirectory.Existence;
import com.android.sched.util.file.FileOrDirectory.Permission;
import com.android.sched.util.file.InputZipFile;
import com.android.sched.util.log.LoggerFactory;
-import com.android.sched.vfs.CachedDirectFS;
import com.android.sched.vfs.Container;
+import com.android.sched.vfs.DirectFS;
import com.android.sched.vfs.ReadZipFS;
import com.android.sched.vfs.VFS;
@@ -182,7 +182,7 @@ public abstract class CommonFilter {
throws IOException {
final VFS vfs;
if (dirOrZip.isDirectory()) {
- vfs = new CachedDirectFS(new Directory(dirOrZip.getPath(), hooks, Existence.MUST_EXIST,
+ vfs = new DirectFS(new Directory(dirOrZip.getPath(), hooks, Existence.MUST_EXIST,
Permission.READ, ChangePermission.NOCHANGE), Permission.READ);
} else { // zip
vfs = new ReadZipFS(new InputZipFile(dirOrZip.getPath(), hooks, Existence.MUST_EXIST,
diff --git a/jack/tests/com/android/jack/TestTools.java b/jack/tests/com/android/jack/TestTools.java
index 5dd7dc5..ac502d8 100644
--- a/jack/tests/com/android/jack/TestTools.java
+++ b/jack/tests/com/android/jack/TestTools.java
@@ -44,7 +44,7 @@ import com.android.sched.util.file.FileOrDirectory.ChangePermission;
import com.android.sched.util.file.FileOrDirectory.Existence;
import com.android.sched.util.file.FileOrDirectory.Permission;
import com.android.sched.util.file.FileUtils;
-import com.android.sched.vfs.CachedDirectFS;
+import com.android.sched.vfs.DirectFS;
import junit.framework.Assert;
@@ -452,7 +452,7 @@ public class TestTools {
OutputJackLibrary outputLibrary = null;
try {
- outputLibrary = JackLibraryFactory.getOutputLibrary(new CachedDirectFS(new Directory(
+ outputLibrary = JackLibraryFactory.getOutputLibrary(new DirectFS(new Directory(
TestTools.createTempDir("unused", "").getPath(), hooks, Existence.MUST_EXIST,
Permission.READ | Permission.WRITE, ChangePermission.NOCHANGE),
Permission.READ | Permission.WRITE),
diff --git a/sched/src/com/android/sched/util/codec/DirectDirInputOutputVFSCodec.java b/sched/src/com/android/sched/util/codec/DirectDirInputOutputVFSCodec.java
index 0e79e2f..4630b85 100644
--- a/sched/src/com/android/sched/util/codec/DirectDirInputOutputVFSCodec.java
+++ b/sched/src/com/android/sched/util/codec/DirectDirInputOutputVFSCodec.java
@@ -19,7 +19,7 @@ package com.android.sched.util.codec;
import com.android.sched.util.file.Directory;
import com.android.sched.util.file.FileOrDirectory.Existence;
-import com.android.sched.vfs.CachedDirectFS;
+import com.android.sched.vfs.DirectFS;
import com.android.sched.vfs.GenericInputOutputVFS;
import com.android.sched.vfs.InputOutputVFS;
@@ -49,7 +49,7 @@ public class DirectDirInputOutputVFSCodec extends InputOutputVFSCodec
public InputOutputVFS checkString(@Nonnull CodecContext context,
@Nonnull final String string) throws ParsingException {
try {
- return new GenericInputOutputVFS(new CachedDirectFS(new Directory(string,
+ return new GenericInputOutputVFS(new DirectFS(new Directory(string,
context.getRunnableHooks(), existence, permissions, change), permissions));
} catch (IOException e) {
throw new ParsingException(e);
diff --git a/sched/src/com/android/sched/util/codec/DirectFSCodec.java b/sched/src/com/android/sched/util/codec/DirectFSCodec.java
index 78a69a7..beedf8b 100644
--- a/sched/src/com/android/sched/util/codec/DirectFSCodec.java
+++ b/sched/src/com/android/sched/util/codec/DirectFSCodec.java
@@ -22,7 +22,7 @@ import com.android.sched.util.file.Directory;
import com.android.sched.util.file.FileOrDirectory.ChangePermission;
import com.android.sched.util.file.FileOrDirectory.Existence;
import com.android.sched.util.file.FileOrDirectory.Permission;
-import com.android.sched.vfs.CachedDirectFS;
+import com.android.sched.vfs.DirectFS;
import com.android.sched.vfs.VFS;
import java.io.IOException;
@@ -90,7 +90,7 @@ public class DirectFSCodec extends FileOrDirCodec implements StringCodec<VFS> {
public VFS checkString(@Nonnull CodecContext context,
@Nonnull final String string) throws ParsingException {
try {
- return new CachedDirectFS(new Directory(string,
+ return new DirectFS(new Directory(string,
context.getRunnableHooks(), existence, permissions, change), permissions);
} catch (IOException e) {
throw new ParsingException(e);
diff --git a/sched/src/com/android/sched/vfs/CachedDirectFS.java b/sched/src/com/android/sched/vfs/CachedDirectFS.java
deleted file mode 100644
index 4530f72..0000000
--- a/sched/src/com/android/sched/vfs/CachedDirectFS.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * Copyright (C) 2015 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.sched.vfs;
-
-import com.android.sched.util.ConcurrentIOException;
-import com.android.sched.util.file.AbstractStreamFile;
-import com.android.sched.util.file.CannotCreateFileException;
-import com.android.sched.util.file.CannotDeleteFileException;
-import com.android.sched.util.file.Directory;
-import com.android.sched.util.file.FileAlreadyExistsException;
-import com.android.sched.util.file.FileOrDirectory;
-import com.android.sched.util.file.FileOrDirectory.Permission;
-import com.android.sched.util.file.WrongPermissionException;
-import com.android.sched.util.location.DirectoryLocation;
-import com.android.sched.util.location.FileLocation;
-import com.android.sched.util.location.Location;
-import com.android.sched.vfs.CachedDirectFS.CachedParentVDir;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.Set;
-
-import javax.annotation.CheckForNull;
-import javax.annotation.Nonnull;
-
-/**
- * A {@link VFS} implementation backed by a real file system, but where directories are cached in
- * memory.
- */
-public class CachedDirectFS extends BaseVFS<CachedParentVDir, ParentVFile> implements VFS {
-
- static class CachedParentVDir extends InMemoryVDir {
-
- @CheckForNull
- private CachedParentVDir parent;
-
- CachedParentVDir(@Nonnull BaseVFS<? extends CachedParentVDir, ? extends ParentVFile> vfs,
- @Nonnull String name) {
- super(vfs, name);
- }
-
- CachedParentVDir(@Nonnull BaseVFS<? extends CachedParentVDir, ? extends ParentVFile> vfs,
- @Nonnull CachedParentVDir parent, @Nonnull String name) {
- super(vfs, name);
- this.parent = parent;
- }
-
- @Override
- @Nonnull
- public VPath getPath() {
- if (parent != null) {
- return parent.getPath().clone().appendPath(new VPath(name, '/'));
- } else {
- return VPath.ROOT;
- }
- }
- }
-
- @Nonnull
- private final Directory dir;
- @Nonnull
- private final CachedParentVDir root;
- @Nonnull
- private final Set<Capabilities> capabilities;
-
- public CachedDirectFS(@Nonnull Directory dir, int permissions) {
- this.dir = dir;
- this.root = new CachedParentVDir(this, "");
-
- Set<Capabilities> capabilities = EnumSet.noneOf(Capabilities.class);
- if ((permissions & Permission.READ) != 0) {
- capabilities.add(Capabilities.READ);
- capabilities.add(Capabilities.PARALLEL_READ);
- }
- if ((permissions & Permission.WRITE) != 0) {
- capabilities.add(Capabilities.WRITE);
- capabilities.add(Capabilities.PARALLEL_WRITE);
- }
- capabilities.add(Capabilities.UNIQUE_ELEMENT);
- this.capabilities = Collections.unmodifiableSet(capabilities);
-
- fillVDirFromRealDirectory(dir.getFile(), root);
- }
-
- private void fillVDirFromRealDirectory(@Nonnull File dir, @Nonnull CachedParentVDir vDir) {
- for (File element : dir.listFiles()) {
- try {
- if (element.isDirectory()) {
- vDir.createVDir(element.getName());
- } else {
- vDir.createVFile(element.getName());
- }
- } catch (CannotCreateFileException e) {
- throw new AssertionError(e);
- }
- }
- }
-
- @Override
- @Nonnull
- public String getDescription() {
- return "directory on disk with cache";
- }
-
- @Nonnull
- @Override
- public Set<Capabilities> getCapabilities() {
- return capabilities;
- }
-
- @Override
- @Nonnull
- public Location getLocation() {
- return root.getLocation();
- }
-
- @Override
- public synchronized void close() {
- closed = true;
- }
-
- @Override
- @Nonnull
- public String getPath() {
- return dir.getPath();
- }
-
- @Override
- public CachedParentVDir getRootDir() {
- return root;
- }
-
- @Override
- @Nonnull
- InputStream openRead(@Nonnull ParentVFile file) throws WrongPermissionException {
- assert !isClosed();
- assert capabilities.contains(Capabilities.READ);
-
- File path = getNativeFile(file.getPath());
- try {
- return new FileInputStream(path);
- } catch (FileNotFoundException e) {
- FileOrDirectory.checkPermissions(path, file.getLocation(), Permission.READ);
- throw new ConcurrentIOException(e);
- }
- }
-
- @Nonnull
- @Override
- OutputStream openWrite(@Nonnull ParentVFile file) throws WrongPermissionException {
- assert !isClosed();
- assert capabilities.contains(Capabilities.WRITE);
-
- File path = getNativeFile(file.getPath());
- try {
- return new FileOutputStream(path);
- } catch (FileNotFoundException e) {
- FileOrDirectory.checkPermissions(path, file.getLocation(), Permission.WRITE);
- throw new ConcurrentIOException(e);
- }
- }
-
- @Nonnull
- @Override
- Collection<? extends BaseVElement> list(@Nonnull CachedParentVDir dir) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- boolean isEmpty(@Nonnull CachedParentVDir dir) {
- assert !isClosed();
- assert capabilities.contains(Capabilities.READ);
-
- return getNativeFile(dir.getPath()).listFiles().length == 0;
- }
-
- @Override
- @Nonnull
- ParentVFile createVFile(@Nonnull CachedParentVDir parent, @Nonnull String name)
- throws CannotCreateFileException {
- assert !isClosed();
- assert capabilities.contains(Capabilities.WRITE);
-
- File path = getNativeFile(parent.getPath(), name);
- try {
- AbstractStreamFile.create(path, new FileLocation(path));
- } catch (FileAlreadyExistsException e) {
- // Nothing to do
- }
-
- return new ParentVFile(this, parent, name);
- }
-
- @Override
- @Nonnull
- CachedParentVDir getVDir(@Nonnull CachedParentVDir parent, @Nonnull String name) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Nonnull
- ParentVFile getVFile(@Nonnull CachedParentVDir parent, @Nonnull String name) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- @Nonnull
- void delete(@Nonnull ParentVFile file) throws CannotDeleteFileException {
- assert !isClosed();
- assert capabilities.contains(Capabilities.WRITE);
-
- File path = getNativeFile(file.getPath());
- if (!path.delete() || path.exists()) {
- throw new CannotDeleteFileException(file.getLocation());
- }
- }
-
- @Override
- @Nonnull
- CachedParentVDir createVDir(@Nonnull CachedParentVDir parent, @Nonnull String name)
- throws CannotCreateFileException {
- assert !isClosed();
- assert capabilities.contains(Capabilities.WRITE);
-
- File path = getNativeFile(parent.getPath(), name);
- try {
- Directory.create(path, new DirectoryLocation(path));
- } catch (FileAlreadyExistsException e) {
- // Nothing to do
- }
-
- return new CachedParentVDir(this, parent, name);
- }
-
- @Override
- public boolean needsSequentialWriting() {
- return false;
- }
-
- @Override
- synchronized boolean isClosed() {
- return closed;
- }
-
- @Override
- @Nonnull
- FileLocation getVFileLocation(@Nonnull ParentVFile file) {
- return new FileLocation(getNativeFile(file.getPath()));
- }
-
- @Override
- @Nonnull
- FileLocation getVFileLocation(@Nonnull CachedParentVDir parent, @Nonnull String name) {
- return new FileLocation(getNativeFile(parent.getPath(), name));
- }
-
- @Override
- @Nonnull
- DirectoryLocation getVDirLocation(@Nonnull CachedParentVDir dir) {
- return new DirectoryLocation(getNativeFile(dir.getPath()));
- }
-
- @Override
- @Nonnull
- DirectoryLocation getVDirLocation(@Nonnull CachedParentVDir parent, @Nonnull String name) {
- return new DirectoryLocation(getNativeFile(parent.getPath(), name));
- }
-
- @Override
- @Nonnull
- FileLocation getVFileLocation(CachedParentVDir parent, VPath path) {
- return new FileLocation(getNativeFile(parent.getPath().clone().appendPath(path)));
- }
-
- @Override
- @Nonnull
- DirectoryLocation getVDirLocation(CachedParentVDir parent, VPath path) {
- return new DirectoryLocation(getNativeFile(parent.getPath().clone().appendPath(path)));
- }
-
- @Nonnull
- private File getNativeFile(@Nonnull VPath path) {
- return new File(dir.getFile(), path.getPathAsString(File.separatorChar));
- }
-
- @Nonnull
- private File getNativeFile(@Nonnull VPath path, @Nonnull String name) {
- return new File(new File(dir.getFile(), path.getPathAsString(File.separatorChar)), name);
- }
-}
diff --git a/sched/src/com/android/sched/vfs/ReadWriteZipFS.java b/sched/src/com/android/sched/vfs/ReadWriteZipFS.java
index 7664e4c..6ce9d0a 100644
--- a/sched/src/com/android/sched/vfs/ReadWriteZipFS.java
+++ b/sched/src/com/android/sched/vfs/ReadWriteZipFS.java
@@ -62,8 +62,8 @@ public class ReadWriteZipFS extends BaseVFS<BaseVDir, BaseVFile> implements VFS
CannotCreateFileException {
int permissions = Permission.READ | Permission.WRITE;
dir = Files.createTempDir();
- CachedDirectFS workVFS = new CachedDirectFS(new Directory(dir.getPath(), null,
- Existence.MUST_EXIST, permissions, ChangePermission.NOCHANGE), permissions);
+ DirectFS workVFS = new DirectFS(new Directory(dir.getPath(), null, Existence.MUST_EXIST,
+ permissions, ChangePermission.NOCHANGE), permissions);
WriteZipFS finalVFS = new WriteZipFS(file);
this.vfs = new VFSToVFSWrapper(workVFS, finalVFS);
}
diff --git a/sched/tests/com/android/sched/vfs/VFSTest.java b/sched/tests/com/android/sched/vfs/VFSTest.java
index 22d0b8f..401e3d1 100644
--- a/sched/tests/com/android/sched/vfs/VFSTest.java
+++ b/sched/tests/com/android/sched/vfs/VFSTest.java
@@ -141,49 +141,6 @@ public class VFSTest {
}
@Test
- public void testCachedDirectFS()
- throws NotDirectoryException,
- CannotCreateFileException,
- WrongPermissionException,
- CannotSetPermissionException,
- NoSuchFileException,
- FileAlreadyExistsException,
- IOException {
- File file = null;
- InputOutputVFS directVFS = null;
- InputOutputVFS directVFS2 = null;
- try {
- file = File.createTempFile("vfs", "dir");
- String path = file.getAbsolutePath();
- Assert.assertTrue(file.delete());
-
- directVFS = new GenericInputOutputVFS(new CachedDirectFS(new Directory(path, null,
- Existence.NOT_EXIST, Permission.WRITE, ChangePermission.NOCHANGE),
- Permission.READ | Permission.WRITE));
-
- testOutputVFS(directVFS);
- testInputVFS(directVFS);
- directVFS.close();
-
- directVFS2 =
- new GenericInputOutputVFS(new DirectFS(new Directory(path, null, Existence.MUST_EXIST,
- Permission.WRITE, ChangePermission.NOCHANGE), Permission.READ | Permission.WRITE));
- testInputVFS(directVFS2);
-
- } finally {
- if (directVFS != null) {
- directVFS.close();
- }
- if (directVFS2 != null) {
- directVFS2.close();
- }
- if (file != null) {
- FileUtils.deleteDir(file);
- }
- }
- }
-
- @Test
public void testDeflateFS()
throws NotDirectoryException,
CannotCreateFileException,