private static CharSequence getCanonicalKey(FileObject fileObject, CharSequence fileKey) { try { CharSequence res = CndFileUtils.getCanonicalPath(fileObject); res = FilePathCache.getManager().getString(res); if (fileKey.equals(res)) { return fileKey; } return res; } catch (IOException e) { // skip exception return fileKey; } }
void load(Properties properties, FileObject projectDir) { try { sourceRoots.clear(); this.sourceProjectName = CharSequences.create(properties.getProperty(PROJECT_TAG + "." + SOURCE_NAME)); final String destName = properties.getProperty(PROJECT_TAG + "." + DESTINATION_NAME); this.destinationProjectName = CharSequences.create(destName == null ? CndFileUtils.getCanonicalPath(projectDir) : destName); for (String key : properties.stringPropertyNames()) { if (key.matches(PROJECT_TAG + "\\d*[.]" + SOURCE_ROOT)) { //NOI18N String keyValue = key.substring(0, key.indexOf("." + SOURCE_ROOT)); //NOI18N String sourceRoot = properties.getProperty(key); String destRoot = properties.getProperty(keyValue + "." + DESTINATION_ROOT); addMapping(CharSequences.create(sourceRoot), CharSequences.create(destRoot)); } } } catch (IOException ex) { //log an ignore //Exceptions.printStackTrace(ex); } }
public static String toProperPath(FileObject base, FileObject path, MakeProjectOptions.PathMode pathMode) { switch (pathMode) { case REL_OR_ABS: return CndPathUtilities.toAbsoluteOrRelativePath(base, path); case REL: return CndPathUtilities.toRelativePath(base, path); case ABS: try { return CndFileUtils.getCanonicalPath(path); } catch (IOException e) { e.printStackTrace(System.err); return path.getPath(); } default: throw new IllegalStateException("Unexpected path mode: " + pathMode); //NOI18N } }
private void addFileItemBasedPath(NativeFileItem nativeFileItem) { FileObject fo = nativeFileItem.getFileObject(); FileObject parent = fo.getParent(); String path = CndFileUtils.normalizePath(parent); addPath(path); String canonicalPath; try { canonicalPath = CndFileUtils.getCanonicalPath(parent); if (!path.equals(canonicalPath)) { addPath(canonicalPath); } } catch (IOException ex) { DiagnosticExceptoins.register(ex); } }