Example usage for java.io File getCanonicalFile

List of usage examples for java.io File getCanonicalFile

Introduction

In this page you can find the example usage for java.io File getCanonicalFile.

Prototype

public File getCanonicalFile() throws IOException 

Source Link

Document

Returns the canonical form of this abstract pathname.

Usage

From source file:org.nuxeo.ecm.core.client.NuxeoApp.java

public static Collection<File> getBundleFiles(File baseDir, String bundles, String delim) throws IOException {
    LinkedHashSet<File> result = new LinkedHashSet<File>();
    StringTokenizer tokenizer = new StringTokenizer(bundles, delim == null ? " \t\n\r\f" : delim);
    while (tokenizer.hasMoreTokens()) {
        String tok = tokenizer.nextToken();
        List<File> files = expandFiles(baseDir, tok);
        for (File file : files) {
            result.add(file.getCanonicalFile());
        }//from   w  w  w.ja v a  2s .  c om
    }
    return result;
}

From source file:Main.java

public static boolean isSymboliclink(File file) throws IOException {
    File canon;
    if (file.getParent() == null) {
        canon = file;//from ww w.j a  va2s  .co  m
    } else {
        File canonDir = file.getParentFile().getCanonicalFile();
        canon = new File(canonDir, file.getName());
    }
    return !canon.getCanonicalFile().equals(canon.getAbsoluteFile());
}

From source file:de.blizzy.backup.Utils.java

public static File toCanonicalFile(File file) {
    try {/*from  www  .j  av a  2  s. c o m*/
        return file.getCanonicalFile();
    } catch (IOException e) {
        // ignore
    }
    return file.getAbsoluteFile();
}

From source file:org.apache.wookie.util.WidgetFileUtils.java

/**
 * Delete a widget and its resources//from  ww w.  j  a  v a 2 s  . c o m
 * @param WIDGETFOLDER
 * @param widgetGuid
 * @return
 */
public static boolean removeWidgetResources(String WIDGETFOLDER, String widgetGuid) {
    String folder = WidgetPackageUtils.convertIdToFolderName(widgetGuid);
    String serverPath = WIDGETFOLDER + File.separator + folder;
    File pFolder = new File(WidgetPackageUtils.convertPathToPlatform(serverPath));
    try {
        _logger.debug("Deleting folder:" + pFolder.getCanonicalFile().toString()); //$NON-NLS-1$
        if (pFolder.getParent() != null) // never call on a root folder
            FileUtils.deleteDirectory(pFolder);
    } catch (Exception ex) {
        _logger.error(ex);
    }
    return true;
}

From source file:org.gradle.internal.FileUtils.java

/**
 * Canonicalizes the given file./*from   www. jav  a2  s  .  c  o  m*/
 */
public static File canonicalize(File src) {
    try {
        return src.getCanonicalFile();
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}

From source file:Main.java

public static String getRelativePath(String basePath, String pathToRelativize) throws IOException {
    File baseFile = new File(basePath);
    if (baseFile.isFile()) {
        baseFile = baseFile.getParentFile();
    }//from   ww  w  .ja  v a 2 s .c o m

    return getRelativeFileInternal(baseFile.getCanonicalFile(), new File(pathToRelativize).getCanonicalFile());
}

From source file:org.wso2.bps.samples.processcleanup.RegistryCleaner.java

/**
 * Cleans the registry at the regPath location
 *
 * @param regPath              registry path for the given package
 * @param packageName          given package name
 * @param clientTrustStorePath client trust store path
 * @param trustStorePassword   client trust store password
 * @param trustStoreType       trust store type
 * @return true if the given package is removed from the carbon registry
 *///from   w  w  w  . j  av a2  s  .  c o m
public static boolean deleteRegistry(String regPath, String packageName, String clientTrustStorePath,
        String trustStorePassword, String trustStoreType) {
    ResourceAdminServiceStub resourceAdminServiceStub;
    setKeyStore(clientTrustStorePath, trustStorePassword, trustStoreType);

    try {
        File file = new File("." + File.separator);
        System.setProperty(CleanupConstants.CARBON_HOME, file.getCanonicalFile().toString());

        if (System.getProperty(CleanupConstants.OS_NAME).startsWith(CleanupConstants.WINDOWS)) {
            prop.load(new FileInputStream(System.getProperty(CleanupConstants.CARBON_HOME) + File.separator
                    + CleanupConstants.REPOSITORY + File.separator + CleanupConstants.CONF + File.separator
                    + CleanupConstants.CLEANUP_PROPERTIES));
        } else {
            prop.load(new FileInputStream(System.getProperty(CleanupConstants.CARBON_HOME) + File.separator
                    + CleanupConstants.REPOSITORY + File.separator + CleanupConstants.CONF + File.separator
                    + CleanupConstants.CLEANUP_PROPERTIES));
        }

        String resourceAdminServiceURL = prop.getProperty(CleanupConstants.TENANT_CONTEXT)
                + CleanupConstants.RESOURCE_ADMIN_SERVICE_PATH;

        resourceAdminServiceStub = new ResourceAdminServiceStub(resourceAdminServiceURL);
        ServiceClient client = resourceAdminServiceStub._getServiceClient();
        Options option = client.getOptions();
        option.setManageSession(true);
        option.setProperty(org.apache.axis2.transport.http.HTTPConstants.COOKIE_STRING, login());
        resourceAdminServiceStub._getServiceClient().getOptions()
                .setTimeOutInMilliSeconds(CleanupConstants.TIME_OUT_MILLS);

        String regPathAppend = regPath + packageName.split("-\\d*$")[0];
        String regPathVersionsAppend = regPathAppend + CleanupConstants.VERSIONS_PATH;
        int count = resourceAdminServiceStub.getCollectionContent(regPathVersionsAppend).getChildCount();

        /* if the number of deployment units of the given package exceed one, then removes the
           relevant deployment unit from the path that it exists. */
        if (count > 1) {
            resourceAdminServiceStub.delete(regPathVersionsAppend + packageName);
            return true;
        }
        /* if the number of deployment units of the given package equals to one, then removes
           it from /_system/config/bpel/packages/<package> */
        else if (count == 1) {
            resourceAdminServiceStub.delete(regPathAppend);
            return true;
        }
    } catch (Exception e) {
        log.error("Error occurred while cleaning the registry.", e);
    }
    return false;
}

From source file:org.neo4j.doc.cypherdoc.Main.java

private static File getDestinationDir(String arg) throws IOException {
    String name = arg;// w  w w . j a va 2s. c  om
    File file = FileUtils.getFile(name);
    if (file.exists() && !file.isDirectory()) {
        throw new IllegalArgumentException("Destination directory must either not exist or be a directory.");
    }
    return file.getCanonicalFile();
}

From source file:jeplus.util.RelativeDirUtil.java

/**
 * break a path down into individual elements and add to a list. example : if a path is /a/b/c/d.txt, the breakdown will be
 * [d.txt,c,b,a]/*from w w w .ja va2 s .co  m*/
 *
 * @param f input file
 * @return a List collection with the individual elements of the path in reverse order
 */
private static List getPathList(File f) {
    List l = new ArrayList();
    File r;
    try {
        r = f.getCanonicalFile();
        while (r != null) {
            l.add(r.getName());
            r = r.getParentFile();
        }
    } catch (IOException e) {
        logger.error("", e);
        l = null;
    }
    return l;
}

From source file:org.jboss.test.compatibility.test.SerialVersionUIDUnitTestCase.java

static Map calcClassInfoMap() throws IOException {
    String jbossDist = System.getProperty("jbosstest.dist");
    File jbossHome = new File(jbossDist);
    jbossHome = jbossHome.getCanonicalFile();
    System.out.println("Calculating serialVersionUIDs for jbossHome: " + jbossHome);
    Map classInfoMap = SerialVersionUID.generateJBossSerialVersionUIDReport(jbossHome);
    return classInfoMap;
}