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

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

本文整理了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

private static File normalizeFileOnMac(final File file) {
  File retVal = file;
  try {
    // URI.normalize removes ../ and ./ sequences nicely.            
    File absoluteFile = Utilities.toFile(Utilities.toURI(file).normalize());
    File canonicalFile = file.getCanonicalFile();
    String absolutePath = absoluteFile.getAbsolutePath();
    if (absolutePath.equals("/..")) { // NOI18N
      // Special treatment.
      absoluteFile = new File(absolutePath = "/"); // NOI18N
    }
    boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absolutePath);
    if (isSymLink) {
      retVal = normalizeSymLinkOnMac(absoluteFile);
    } else {
      retVal = canonicalFile;
    }
  } catch (IOException ioe) {
    LOG.log(Level.FINE, "Normalization failed on file " + file, ioe);
    // OK, so at least try to absolutize the path
    retVal = file.getAbsoluteFile();
  }
  return retVal;
}

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

private static File normalizeFileOnMac(final File file) {
  File retVal = file;
  try {
    // URI.normalize removes ../ and ./ sequences nicely.            
    File absoluteFile = new File(file.toURI().normalize());
    File canonicalFile = file.getCanonicalFile();
    boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absoluteFile.getAbsolutePath());
    if (isSymLink) {
      retVal = normalizeSymLinkOnMac(absoluteFile);
    } else {
      retVal = canonicalFile;                
    }
  } catch (IOException ioe) {
    ErrorManager.getDefault().log(ErrorManager.ERROR, "Normalization failed on file " + file + ": " + ioe);             
    // OK, so at least try to absolutize the path
    retVal = file.getAbsoluteFile();
  }
  return retVal;
}

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

private static File normalizeFileOnMac(final File file) {
  File retVal = file;
  try {
    // URI.normalize removes ../ and ./ sequences nicely.            
    File absoluteFile = new File(file.toURI().normalize());
    File canonicalFile = file.getCanonicalFile();
    boolean isSymLink = !canonicalFile.getAbsolutePath().equalsIgnoreCase(absoluteFile.getAbsolutePath());
    if (isSymLink) {
      retVal = normalizeSymLinkOnMac(absoluteFile);
    } else {
      retVal = canonicalFile;                
    }
  } catch (IOException ioe) {
    ErrorManager.getDefault().log(ErrorManager.ERROR, "Normalization failed on file " + file + ": " + ioe);             
    // OK, so at least try to absolutize the path
    retVal = file.getAbsoluteFile();
  }
  return retVal;
}

相关文章