Refine search
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { Files.createDirectories(dest.resolve(src.relativize(dir))); return FileVisitResult.CONTINUE; } @Override
private String getRelativeStringBy(File file, File reference) { File actualReference = reference.getParentFile(); if (actualReference == null) { actualReference = reference; } return actualReference.toPath().relativize(file.toPath()).toString().replace("\\", "/"); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relativePath = oldApkPath.relativize(file); Path newPath = newApkPath.resolve(relativePath); String patternKey = relativePath.toString().replace("\\", "/"); if (Utils.checkFileInPattern(config.mResFilePattern, patternKey)) { //not contain in new path, is deleted if (!newPath.toFile().exists()) { deletedFiles.add(patternKey); writeResLog(newPath.toFile(), file.toFile(), TypedValue.DEL); } return FileVisitResult.CONTINUE; } return FileVisitResult.CONTINUE; } }
public boolean isPrimaryDex(File dexFile) { Path dexFilePath = dexFile.toPath(); Path parentPath = config.mTempUnzipOldDir.toPath(); if (!dexFilePath.startsWith(parentPath)) { parentPath = config.mTempUnzipNewDir.toPath(); } return DexFormat.DEX_IN_JAR_NAME.equals(parentPath.relativize(dexFilePath).toString().replace('\\', '/')); } }
@Override public FileVisitResult visitFile(Path srcFile, BasicFileAttributes attrs) throws IOException { if (!srcFile.getFileName().toString().endsWith(".java")) { log.println("Copying resource " + srcFile + " to " + dstPath); Path dstFile = dstPath.resolve(srcPath.relativize(srcFile)); Files.copy(srcFile, dstFile, StandardCopyOption.REPLACE_EXISTING); } return FileVisitResult.CONTINUE; } };
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, dest.resolve(src.relativize(file)), StandardCopyOption.REPLACE_EXISTING); return FileVisitResult.CONTINUE; } });
private String relativize(Path sourceFilePath) { return baseDir.relativize(sourceFilePath).toString(); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { String fileName = file.getFileName().toString(); if (fileName.endsWith(".sh") || fileName.endsWith(".bat")) { Path f = out.resolve(cfg.relativize(file)); BaseCmd.createParentDirectories(f); Files.copy(file, f, StandardCopyOption.REPLACE_EXISTING); if (fileName.endsWith(".sh")) { setExec(f); } } return super.visitFile(file, attrs); } });
@Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { Files.createDirectories(dest.resolve(src.relativize(dir))); return FileVisitResult.CONTINUE; } @Override
public String getRelativePathStringToOldFile(File oldFile) { return config.mTempUnzipOldDir.toPath().relativize(oldFile.toPath()).toString().replace("\\", "/"); }
@Test public void withFiles_savedToLocatorSpecifiedRelativeDir() throws Exception { String[] extensions = {"zip"}; Path workingDirPath = getWorkingDirectory().toPath(); Path subdirPath = workingDirPath.resolve("some").resolve("test").resolve("directory"); Path relativeDir = workingDirPath.relativize(subdirPath); // Expects locator to produce file in own working directory when connected via JMX gfshConnector.executeCommand("export logs --dir=" + relativeDir.toString()); assertThat(listFiles(getWorkingDirectory(), extensions, false)).isEmpty(); assertThat(listFiles(getWorkingDirectory(), extensions, true)).isNotEmpty(); assertThat(listFiles(subdirPath.toFile(), extensions, false)).isNotEmpty(); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, dest.resolve(src.relativize(file)), StandardCopyOption.REPLACE_EXISTING); return FileVisitResult.CONTINUE; } });
public String getRelativePathStringToNewFile(File newFile) { return config.mTempUnzipNewDir.toPath().relativize(newFile.toPath()).toString().replace("\\", "/"); }
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relativePath = newApkPath.relativize(file); Path oldPath = oldApkPath.resolve(relativePath); oldFile = oldPath.toFile(); String patternKey = relativePath.toString().replace("\\", "/");
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, target.resolve(source.relativize(file)), StandardCopyOption.REPLACE_EXISTING); return FileVisitResult.CONTINUE; } });
public String getParentRelativePathStringToNewFile(File newFile) { return config.mTempUnzipNewDir.toPath().relativize(newFile.getParentFile().toPath()).toString().replace("\\", "/"); }
Path outdir = this.basedir.toPath().resolve("node_modules").resolve(library.replace("/", ".")); Optional<Path> basedir = Try.apply(() -> Paths.get(uri)).toOptional(); String libroot = Route.normalize("/" + library); stream.filter(it -> !Files.isDirectory(it)) .forEach(it -> { String relative = basedir.map(d -> d.relativize(it).toString()) .orElseGet(() -> { String fname = it.toString(); if (fname.startsWith(libroot)) { fname = fname.substring(libroot.length()); Path output = outdir.resolve(relative); File fout = output.toFile(); boolean copy = !fout.exists()
@Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Path relative = sourcePath.relativize(file); Path target = targetPath.resolve(relative); Files.copy(file, target, StandardCopyOption.COPY_ATTRIBUTES); return FileVisitResult.CONTINUE; } });
@Override public String getRealResourceName() { return root.relativize(path).toString(); }
.getProjectDir() .toPath() .relativize(project.getProjectDir().toPath()) .toString()) .collect(MoreCollectors.toImmutableSet()); Map<String, Set<Rule>> pathToRules = new HashMap<>(); rootBuckProject.getRootDir().toPath().resolve(entry.getKey()).resolve(BUCK).toFile(); try (OutputStream os = new FileOutputStream(buckFile, currentProjectPaths.contains(entry.getKey()))) {