@Override public String getSeparator() { return delegate.getSeparator(); }
public PathResourceManager setBase(final File base) { if (base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } this.fileSystem = FileSystems.getDefault(); String basePath = base.getAbsolutePath(); if (!basePath.endsWith(fileSystem.getSeparator())) { basePath = basePath + fileSystem.getSeparator(); } this.base = basePath; return this; }
private String pathToString(Path value, boolean nameOnly) { String pathAsString = (nameOnly && value.getNameCount() != 0 ? value.getFileName() : value).toString(); String separator = value.getFileSystem().getSeparator(); return !pathAsString.endsWith(separator) && Files.isDirectory(value) ? pathAsString + separator : pathAsString; }
public PathResourceManager setBase(final Path base) { if (base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } this.fileSystem = base.getFileSystem(); String basePath = base.toAbsolutePath().toString(); if (!basePath.endsWith(fileSystem.getSeparator())) { basePath = basePath + fileSystem.getSeparator(); } this.base = basePath; return this; }
@Override public List<Resource> list() { final List<Resource> resources = new ArrayList<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(file)) { for (Path child : stream) { resources.add(new PathResource(child, manager, path + file.getFileSystem().getSeparator() + child.getFileName().toString())); } } catch (IOException e) { throw new RuntimeException(e); } return resources; }
private BufferedWriter createWriter(final String packageName, final String fileName) throws IOException { if (reportPath == null) { return new BufferedWriter(processingEnv.getFiler().createResource(StandardLocation.SOURCE_OUTPUT, packageName, fileName).openWriter()); } final Path outputPath = Paths.get(reportPath, packageName.replace(".", FileSystems.getDefault().getSeparator()), fileName); Files.createDirectories(outputPath.getParent()); return Files.newBufferedWriter(outputPath, StandardCharsets.UTF_8, StandardOpenOption.CREATE); }
/** * Return the relative path. Path elements are separated with / char. * * @param baseDir * a parent directory of {@code file} * @param file * the file to get the relative path * @return the relative path */ public static String relativize(Path baseDir, Path file) { String path = baseDir.toUri().relativize(file.toUri()).getPath(); if (!"/".equals(baseDir.getFileSystem().getSeparator())) { // For windows return path.replace(baseDir.getFileSystem().getSeparator(), "/"); } else { return path; } } }
for (String safePath : this.safePaths) { if (safePath.length() > 0) { if (safePath.startsWith(fileSystem.getSeparator())) { String absSafePath = base + fileSystem.getSeparator() + safePath; Path absSafePathFile = fileSystem.getPath(absSafePath); String canonicalSafePath = absSafePathFile.toRealPath().toString();
private PathResourceManager(Builder builder) { this.allowResourceChangeListeners = builder.allowResourceChangeListeners; if (builder.base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } this.fileSystem = builder.base.getFileSystem(); String basePath = builder.base.normalize().toAbsolutePath().toString(); if (!basePath.endsWith(fileSystem.getSeparator())) { basePath = basePath + fileSystem.getSeparator(); } this.base = basePath; this.transferMinSize = builder.transferMinSize; this.caseSensitive = builder.caseSensitive; this.followLinks = builder.followLinks; if (this.followLinks) { if (builder.safePaths == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("safePaths"); } for (final String safePath : builder.safePaths) { if (safePath == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("safePaths"); } } this.safePaths.addAll(Arrays.asList(builder.safePaths)); } this.eTagFunction = builder.eTagFunction; }
final String notSeparatorPattern = getNotSeparatorPattern(fs.getSeparator());
public void setUp() throws Exception { super.setUp(); java.nio.file.FileSystem fs = FileSystems.getDefault(); pathSep = fs.getSeparator(); File ftestDir = testFolder.newFolder(); testDir = ftestDir.toString(); }
if(compare.startsWith(fileSystem.getSeparator())) { compare = compare.substring(fileSystem.getSeparator().length()); if(relative.startsWith(fileSystem.getSeparator())) { relative = relative.substring(fileSystem.getSeparator().length());
@Test public void testGetters() throws IOException { try (FileSystem fs = CloudStorageFileSystem.forBucket("bucket")) { assertThat(fs.isOpen()).isTrue(); assertThat(fs.isReadOnly()).isFalse(); assertThat(fs.getRootDirectories()).containsExactly(fs.getPath("/")); assertThat(fs.getFileStores()).isEmpty(); assertThat(fs.getSeparator()).isEqualTo("/"); assertThat(fs.supportedFileAttributeViews()).containsExactly("basic", "gcs"); } }
java.nio.file.FileSystems.getDefault().getSeparator();
policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", permissions)); if (VERSION_IS_AT_LEAST_JAVA_9) { if (path.toString().equals(realPath.toString()) == false) { policy.add(new FilePermission(realPath.toString(), permissions)); policy.add(new FilePermission(realPath.toString() + realPath.getFileSystem().getSeparator() + "-", permissions));
public void setUp() throws Exception { super.setUp(); java.nio.file.FileSystem fs = FileSystems.getDefault(); pathSep = fs.getSeparator(); File ftestDir = testFolder.newFolder(); testDir = ftestDir.toString(); }
public PathResourceManager setBase(final File base) { if (base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } this.fileSystem = FileSystems.getDefault(); String basePath = base.getAbsolutePath(); if (!basePath.endsWith(fileSystem.getSeparator())) { basePath = basePath + fileSystem.getSeparator(); } this.base = basePath; return this; }
public PathResourceManager setBase(final Path base) { if (base == null) { throw UndertowMessages.MESSAGES.argumentCannotBeNull("base"); } this.fileSystem = base.getFileSystem(); String basePath = base.toAbsolutePath().toString(); if (!basePath.endsWith(fileSystem.getSeparator())) { basePath = basePath + fileSystem.getSeparator(); } this.base = basePath; return this; }
@Override public List<Resource> list() { final List<Resource> resources = new ArrayList<>(); try (DirectoryStream<Path> stream = Files.newDirectoryStream(file)) { for (Path child : stream) { resources.add(new PathResource(child, manager, path + file.getFileSystem().getSeparator() + child.getFileName().toString())); } } catch (IOException e) { throw new RuntimeException(e); } return resources; }
private String linkToDoc(Path src, DocumentationElement dst) { Path from = src; if (from.getParent() != null) { from = from.getParent(); } // The replace is to have a valid relative uri on Windows... // I'd rather use URI::relativize, but it only works when one URI is the strict prefix of the other // i.e. can't generate relative URIs containing '..' (what a shame!) return from.relativize(docFile(dst)).toString().replace(FileSystems.getDefault().getSeparator(), "/") + (dst.id().isEmpty() ? "" : ("#" + dst.id())); }