public final P makePath(P dir, Iterable<String> path) throws IllegalArgumentException, IOException { if (!isDir(dir)) { throw new IllegalArgumentException("Dir is not an effective dir"); } for (String name : path) { dir = makePath(dir, name); } return dir; }
public final P makePath(Iterable<String> path) throws IOException { return makePath(getRoot(), path); }
public final P makePath(P dir, Iterable<String> path) throws IllegalArgumentException, IOException { if (!isDir(dir)) { throw new IllegalArgumentException("Dir is not an effective dir"); } for (String name : path) { dir = makePath(dir, name); } return dir; }
public final P makePath(Iterable<String> path) throws IOException { return makePath(getRoot(), path); }
public JavaFileObjectImpl getWritable(FileKey key) throws IOException { JavaFileObjectImpl entry = getReadable(key); if (entry == null) { if (fs instanceof ReadWriteFileSystem<?>) { ReadWriteFileSystem<P> rwFS = (ReadWriteFileSystem<P>)fs; P file = rwFS.makePath(key.names); entries.put(key, entry = new JavaFileObjectImpl<P>(location, key, fs, file)); } else { throw new IOException("File system is not writable"); } } return entry; }
public JavaFileObjectImpl getWritable(FileKey key) throws IOException { JavaFileObjectImpl entry = getReadable(key); if (entry == null) { if (fs instanceof ReadWriteFileSystem<?>) { ReadWriteFileSystem<P> rwFS = (ReadWriteFileSystem<P>)fs; P file = rwFS.makePath(key.names); entries.put(key, entry = new JavaFileObjectImpl<P>(location, key, fs, file)); } else { throw new IOException("File system is not writable"); } } return entry; }
boolean accept = dir ? filter.acceptDir(next, name) : filter.acceptFile(next, name); if (accept) { a = dst.makePath(dstPath, name); copy(next, filter, dst, a);
@Test public void testGetNames() throws IOException { ReadWriteFileSystem<P> fs = create(); assertFalse(fs.getNames(fs.getRoot()).iterator().hasNext()); List<String> expected = Tools.list("a", "b", "c"); P path = fs.makePath(expected); List<String> test = Tools.list(fs.getNames(path)); assertEquals(expected, test); }
@Test public void testGetNames() throws IOException { ReadWriteFileSystem<P> fs = create(); assertFalse(fs.getNames(fs.getRoot()).iterator().hasNext()); List<String> expected = Tools.list("a", "b", "c"); P path = fs.makePath(expected); List<String> test = Tools.list(fs.getNames(path)); assertEquals(expected, test); }
boolean accept = dir ? filter.acceptDir(next, name) : filter.acceptFile(next, name); if (accept) { a = dst.makePath(dstPath, name); copy(next, filter, dst, a);
public FileResource<I> assertAddSource(String name, String ext, String content) { try { ReadWriteFileSystem<I> fs = strategy.sourcePath; String[] atoms = Tools.split(name, '.'); I path; if (atoms.length > 1) { path = fs.makePath(Tools.iterable(atoms, 0, atoms.length - 1)); fs.createDir(path); } else { path = fs.getRoot(); } path = fs.makePath(path, atoms[atoms.length - 1] + "." + ext); fs.updateResource(path, new Resource(content)); return new FileResource<I>(fs, path); } catch (IOException e) { throw AbstractTestCase.failure(e); } }
public FileResource<I> assertAddSource(String name, String ext, String content) { try { ReadWriteFileSystem<I> fs = strategy.sourcePath; String[] atoms = Tools.split(name, '.'); I path; if (atoms.length > 1) { path = fs.makePath(Tools.iterable(atoms, 0, atoms.length - 1)); fs.createDir(path); } else { path = fs.getRoot(); } path = fs.makePath(path, atoms[atoms.length - 1] + "." + ext); fs.updateResource(path, new Resource(content)); return new FileResource<I>(fs, path); } catch (IOException e) { throw AbstractTestCase.failure(e); } }
@Test public void testLifeCycle() throws Exception { ReadWriteFileSystem<P> fs = create(); // The root exist P foo = fs.makePath(Collections.singleton("foo")); P bar = fs.makePath(foo, "bar"); assertEquals(1, fs.size(ReadFileSystem.PATH)); // Now create fs.updateResource(bar, new Resource("FOO")); // assertEquals(3, fs.size(ReadFileSystem.PATH)); assertEquals(2, fs.size(ReadFileSystem.DIR)); assertEquals(1, fs.size(ReadFileSystem.FILE)); } }
@Test public void testLifeCycle() throws Exception { ReadWriteFileSystem<P> fs = create(); // The root exist P foo = fs.makePath(Collections.singleton("foo")); P bar = fs.makePath(foo, "bar"); assertEquals(1, fs.size(ReadFileSystem.PATH)); // Now create fs.updateResource(bar, new Resource("FOO")); // assertEquals(3, fs.size(ReadFileSystem.PATH)); assertEquals(2, fs.size(ReadFileSystem.DIR)); assertEquals(1, fs.size(ReadFileSystem.FILE)); } }
File foo = output.makePath(output.getRoot(), "foo.txt"); output.updateResource(foo, new Resource("foo_value"));
File foo = output.makePath(output.getRoot(), "foo.txt"); output.updateResource(foo, new Resource("foo_value"));
@Test public void testDelete() throws Exception { DeleteResourceProcessor processor = new DeleteResourceProcessor(); CompilerAssert<File, File> compiler = compiler("compiler.deleteresource").with(compilerProvider).with(processor); File foo = compiler.getClassOutput().makePath(compiler.getClassOutput().getRoot(), "foo.txt"); Tools.write("foo", foo); compiler.assertCompile(); assertTrue(processor.done); boolean expected = compilerProvider == JavaCompilerProvider.ECJ; assertEquals(expected, processor.deleted); assertEquals(!expected, foo.exists()); }
@Test public void testDelete() throws Exception { DeleteResourceProcessor processor = new DeleteResourceProcessor(); CompilerAssert<File, File> compiler = compiler("compiler.deleteresource").with(compilerProvider).with(processor); File foo = compiler.getClassOutput().makePath(compiler.getClassOutput().getRoot(), "foo.txt"); Tools.write("foo", foo); compiler.assertCompile(); assertTrue(processor.done); boolean expected = compilerProvider == JavaCompilerProvider.ECJ; assertEquals(expected, processor.deleted); assertEquals(!expected, foo.exists()); }
@Test public void testIncremental() throws IOException, CompilationException { CompilerAssert<File, File> compiler = compiler(true, Name.parse("compiler.incremental"), ""). with(compilerProvider). with((Provider<? extends Processor>)null); compiler.assertCompile(); // ReadWriteFileSystem<File> classOutput = compiler.getClassOutput(); assertEquals(1, classOutput.size(ReadFileSystem.FILE)); // ReadWriteFileSystem<File> sourcePath = (ReadWriteFileSystem<File>)compiler.getSourcePath(); File b = sourcePath.makePath(sourcePath.getPath("compiler", "incremental"), "B.java"); sourcePath.updateResource(b, new Resource("package compiler.incremental; public class B extends A {}")); compiler.assertCompile(); assertEquals(2, classOutput.size(ReadFileSystem.FILE)); }
@Test public void testIncremental() throws IOException, CompilationException { CompilerAssert<File, File> compiler = compiler(true, Name.parse("compiler.incremental"), ""). with(compilerProvider). with((Provider<? extends Processor>)null); compiler.assertCompile(); // ReadWriteFileSystem<File> classOutput = compiler.getClassOutput(); assertEquals(1, classOutput.size(ReadFileSystem.FILE)); // ReadWriteFileSystem<File> sourcePath = (ReadWriteFileSystem<File>)compiler.getSourcePath(); File b = sourcePath.makePath(sourcePath.getPath("compiler", "incremental"), "B.java"); sourcePath.updateResource(b, new Resource("package compiler.incremental; public class B extends A {}")); compiler.assertCompile(); assertEquals(2, classOutput.size(ReadFileSystem.FILE)); }