Java Canonical Path Create getCanonicalPath(IPath fullPath)

Here you can find the source of getCanonicalPath(IPath fullPath)

Description

Return the canonical path (or the passed in path, if one couldn't be found).

License

Open Source License

Parameter

Parameter Description
fullPath a parameter

Return

canonicalized IPath or passed in fullPath.

Declaration

public static IPath getCanonicalPath(IPath fullPath) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2004, 2014 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors://ww  w. j  av a 2 s  .c o  m
 *     QNX Software Systems - initial API and implementation
 *     Markus Schorn (Wind River Systems)
 *     Ed Swartz (Nokia)
 *     Sergey Prigogin (Google)
 *     James Blackburn (Broadcom Corp.)
 *******************************************************************************/

import java.io.File;
import java.io.IOException;

import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;

public class Main {
    /**
     * Return the canonical path (or the passed in path, if one couldn't be found).
     * @param fullPath
     * @return canonicalized IPath or passed in fullPath.
     */
    public static IPath getCanonicalPath(IPath fullPath) {
        if (!fullPath.isAbsolute())
            return fullPath;

        File file = fullPath.toFile();
        try {
            String canonPath = file.getCanonicalPath();
            IPath canonicalPath = new Path(canonPath);
            if (fullPath.getDevice() == null)
                canonicalPath = canonicalPath.setDevice(null);
            return canonicalPath;
        } catch (IOException ex) {
        }
        return fullPath;
    }
}

Related

  1. getCanonicalPath(File inFile, boolean inThrowRuntimeException)
  2. getCanonicalPath(final File file)
  3. getCanonicalPath(final File file)
  4. getCanonicalPath(final String path)
  5. getCanonicalPath(IPath fullPath)
  6. getCanonicalPath(String basePath, String path)
  7. getCanonicalPath(String filePath, String prefix)
  8. getCanonicalPath(String inPath)
  9. getCanonicalPath(String name)