org.openide.filesystems.FileUtil.normalizeSymLinkOnMac()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.5k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中org.openide.filesystems.FileUtil.normalizeSymLinkOnMac()方法的一些代码示例,展示了FileUtil.normalizeSymLinkOnMac()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtil.normalizeSymLinkOnMac()方法的具体详情如下:
包路径:org.openide.filesystems.FileUtil
类名称:FileUtil
方法名:normalizeSymLinkOnMac

FileUtil.normalizeSymLinkOnMac介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-openide-filesystems

  1. private static File normalizeFileOnMac(final File file) {
  2. File retVal = file;
  3. try {
  4. // URI.normalize removes ../ and ./ sequences nicely.
  5. File absoluteFile = Utilities.toFile(Utilities.toURI(file).normalize());
  6. File canonicalFile = file.getCanonicalFile();
  7. String absolutePath = absoluteFile.getAbsolutePath();
  8. if (absolutePath.equals("/..")) { // NOI18N
  9. // Special treatment.
  10. absoluteFile = new File(absolutePath = "/"); // NOI18N
  11. }
  12. boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absolutePath);
  13. if (isSymLink) {
  14. retVal = normalizeSymLinkOnMac(absoluteFile);
  15. } else {
  16. retVal = canonicalFile;
  17. }
  18. } catch (IOException ioe) {
  19. LOG.log(Level.FINE, "Normalization failed on file " + file, ioe);
  20. // OK, so at least try to absolutize the path
  21. retVal = file.getAbsoluteFile();
  22. }
  23. return retVal;
  24. }

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

  1. private static File normalizeFileOnMac(final File file) {
  2. File retVal = file;
  3. try {
  4. // URI.normalize removes ../ and ./ sequences nicely.
  5. File absoluteFile = new File(file.toURI().normalize());
  6. File canonicalFile = file.getCanonicalFile();
  7. boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absoluteFile.getAbsolutePath());
  8. if (isSymLink) {
  9. retVal = normalizeSymLinkOnMac(absoluteFile);
  10. } else {
  11. retVal = canonicalFile;
  12. }
  13. } catch (IOException ioe) {
  14. ErrorManager.getDefault().log(ErrorManager.ERROR, "Normalization failed on file " + file + ": " + ioe);
  15. // OK, so at least try to absolutize the path
  16. retVal = file.getAbsoluteFile();
  17. }
  18. return retVal;
  19. }

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

  1. private static File normalizeFileOnMac(final File file) {
  2. File retVal = file;
  3. try {
  4. // URI.normalize removes ../ and ./ sequences nicely.
  5. File absoluteFile = new File(file.toURI().normalize());
  6. File canonicalFile = file.getCanonicalFile();
  7. boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absoluteFile.getAbsolutePath());
  8. if (isSymLink) {
  9. retVal = normalizeSymLinkOnMac(absoluteFile);
  10. } else {
  11. retVal = canonicalFile;
  12. }
  13. } catch (IOException ioe) {
  14. ErrorManager.getDefault().log(ErrorManager.ERROR, "Normalization failed on file " + file + ": " + ioe);
  15. // OK, so at least try to absolutize the path
  16. retVal = file.getAbsoluteFile();
  17. }
  18. return retVal;
  19. }

相关文章