当前位置: 首页>>代码示例>>Java>>正文


Java Files.readSymbolicLink方法代码示例

本文整理汇总了Java中java.nio.file.Files.readSymbolicLink方法的典型用法代码示例。如果您正苦于以下问题:Java Files.readSymbolicLink方法的具体用法?Java Files.readSymbolicLink怎么用?Java Files.readSymbolicLink使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.nio.file.Files的用法示例。


在下文中一共展示了Files.readSymbolicLink方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: syncSymbolicLink

import java.nio.file.Files; //导入方法依赖的package包/类
private static void syncSymbolicLink(
    final Path source, final Path target, final Path sourceFile, final Path targetFile)
    throws IOException {
  final Path sourceLink = Files.readSymbolicLink(sourceFile);
  final Path expectedTargetLink = equivalentSubpath(source, target, sourceLink);

  if (Files.exists(targetFile)) {
    final Path actualTargetLink = Files.readSymbolicLink(targetFile);

    if (expectedTargetLink.toRealPath().equals(actualTargetLink.toRealPath())) {
      return;
    }
  }

  Files.deleteIfExists(targetFile);
  Files.createSymbolicLink(targetFile, expectedTargetLink);
}
 
开发者ID:spotify,项目名称:bazel-tools,代码行数:18,代码来源:PathUtils.java

示例2: toFileName

import java.nio.file.Files; //导入方法依赖的package包/类
public static String toFileName(String path) throws IOException {
  File f = new File(path);
  String fileName = f.getName();
  if(Files.isSymbolicLink(f.toPath())) {
    Path p = Files.readSymbolicLink(f.toPath());
    fileName = p.getFileName().toFile().getName();
  }
  return fileName;
}
 
开发者ID:simonellistonball,项目名称:metron-field-demos,代码行数:10,代码来源:DemoLoader.java

示例3: readLink

import java.nio.file.Files; //导入方法依赖的package包/类
private static Path readLink(final Path path) {
  try {
    return Files.readSymbolicLink(path);
  } catch (IOException e) {
    throw new UncheckedIOException("Could not read link " + path, e);
  }
}
 
开发者ID:spotify,项目名称:bazel-tools,代码行数:8,代码来源:Main.java

示例4: verifySymLinks

import java.nio.file.Files; //导入方法依赖的package包/类
private void verifySymLinks(String bindir) throws IOException {
    File binDir = new File(bindir);
    System.err.println("verifying links in: " + bindir);
    File isaDir = new File(binDir, getArch()).getAbsoluteFile();
    if (!isaDir.exists()) {
        throw new RuntimeException("dir: " + isaDir + " does not exist");
    }
    try (DirectoryStream<Path> ds = Files.newDirectoryStream(binDir.toPath())) {
        for (Path p : ds) {
            if (symlinkExcludes.matcher(p.toString()).matches() ||
                    Files.isDirectory(p, NOFOLLOW_LINKS)) {
                continue;
            }
            Path link = new File(isaDir, p.getFileName().toString()).toPath();
            if (Files.isSymbolicLink(link)) {
                Path target = Files.readSymbolicLink(link);
                if (target.startsWith("..") && p.endsWith(target.getFileName())) {
                    // System.out.println(target + " OK");
                    continue;
                }
                System.err.println("target:" + target);
                System.err.println("file:" + p);
            }
            throw new RuntimeException("could not find link to " + p);
        }
    }

}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:29,代码来源:ExecutionEnvironment.java

示例5: getPackagePath

import java.nio.file.Files; //导入方法依赖的package包/类
synchronized Path getPackagePath(String pkgName) throws IOException {
    // check the cache first
    if (pkgDirs.containsKey(pkgName)) {
        return pkgDirs.get(pkgName);
    }

    Path pkgLink = fs.getPath("/packages/" + pkgName.replace('/', '.'));
    // check if /packages/$PACKAGE directory exists
    if (Files.isDirectory(pkgLink)) {
       try (DirectoryStream<Path> stream = Files.newDirectoryStream(pkgLink)) {
            for (Path p : stream) {
                // find first symbolic link to module directory
                if (Files.isSymbolicLink(p)) {
                    Path modDir = Files.readSymbolicLink(p);
                    if (Files.isDirectory(modDir)) {
                        // get package subdirectory under /modules/$MODULE/
                        Path pkgDir = fs.getPath(modDir.toString() + "/" + pkgName);
                        if (Files.isDirectory(pkgDir)) {
                            // it is a package directory only if contains
                            // at least one .class file
                            try (DirectoryStream<Path> pstream =
                                    Files.newDirectoryStream(pkgDir)) {
                                for (Path f : pstream) {
                                    if (Files.isRegularFile(f)
                                            && f.toString().endsWith(".class")) {
                                        pkgDirs.put(pkgName, pkgDir);
                                        return pkgDir;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:40,代码来源:ClassPath.java

示例6: testPackagesLinks

import java.nio.file.Files; //导入方法依赖的package包/类
@Test(dataProvider = "packagesLinks")
public void testPackagesLinks(String link) throws Exception {
    FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/"));
    Path path = fs.getPath(link);
    assertTrue(Files.exists(path), link + " missing");
    assertTrue(Files.isSymbolicLink(path), path + " is not a link");
    path = Files.readSymbolicLink(path);
    assertEquals(path.toString(), "/modules" + link.substring(link.lastIndexOf("/")));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Basic.java

示例7: getSymbolicLinkTargetFile

import java.nio.file.Files; //导入方法依赖的package包/类
public static Path getSymbolicLinkTargetFile(Path path) {
    if (!Files.isSymbolicLink(path)) {
        return path;
    }

    try {
        Path targetPath = Files.readSymbolicLink(path);
        return getSymbolicLinkTargetFile(targetPath);
    } catch (IOException e) {
        throw new RuntimeException("Failed to read symbolic link: " + path, e);
    }
}
 
开发者ID:uber,项目名称:uberscriptquery,代码行数:13,代码来源:FileUtils.java

示例8: getLinkPath

import java.nio.file.Files; //导入方法依赖的package包/类
public static Path getLinkPath (final Path p) throws IOException {
    return Files.readSymbolicLink(p);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:Utils.java

示例9: readSymbolicLink

import java.nio.file.Files; //导入方法依赖的package包/类
@Override
public Path readSymbolicLink(Path link) throws IOException {
    Path target = Files.readSymbolicLink(unwrap(link));
    triggerEx(target, "readSymbolicLink");
    return new PassThroughFileSystem.PassThroughPath(delegate, target);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:FaultyFileSystem.java

示例10: getEntry

import java.nio.file.Files; //导入方法依赖的package包/类
synchronized Entry getEntry(RelativeDirectory rd) throws IOException {
    SoftReference<Entry> ref = entries.get(rd);
    Entry e = (ref == null) ? null : ref.get();
    if (e == null) {
        Map<String, Path> files = new LinkedHashMap<>();
        Set<RelativeDirectory> subdirs = new LinkedHashSet<>();
        Path dir;
        if (rd.path.isEmpty()) {
            dir = jrtfs.getPath("/modules");
        } else {
            Path pkgs = jrtfs.getPath("/packages");
            dir = pkgs.resolve(rd.getPath().replaceAll("/$", "").replace("/", "."));
        }
        if (Files.exists(dir)) {
            try (DirectoryStream<Path> modules = Files.newDirectoryStream(dir)) {
                for (Path module: modules) {
                    if (Files.isSymbolicLink(module))
                        module = Files.readSymbolicLink(module);
                    Path p = rd.resolveAgainst(module);
                    if (!Files.exists(p))
                        continue;
                    try (DirectoryStream<Path> stream = Files.newDirectoryStream(p)) {
                        for (Path entry: stream) {
                            String name = entry.getFileName().toString();
                            if (Files.isRegularFile(entry)) {
                                // TODO: consider issue of files with same name in different modules
                                files.put(name, entry);
                            } else if (Files.isDirectory(entry)) {
                                subdirs.add(new RelativeDirectory(rd, name));
                            }
                        }
                    }
                }
            }
        }
        e = new Entry(Collections.unmodifiableMap(files),
                Collections.unmodifiableSet(subdirs),
                getCtInfo(rd));
        entries.put(rd, new SoftReference<>(e));
    }
    return e;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:43,代码来源:JRTIndex.java


注:本文中的java.nio.file.Files.readSymbolicLink方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。