List of usage examples for org.apache.commons.io FilenameUtils normalize
public static String normalize(String filename)
From source file:org.csc.phynixx.common.TmpDirectory.java
public File assertExitsFile(String filename) throws IOException { File parentDir = this.assertExitsDirectory(FilenameUtils.getPath(filename)); String name = FilenameUtils.getName(filename); String fullname = FilenameUtils.normalize(parentDir.getAbsolutePath() + File.separator + name); File file = new File(fullname); if (!file.createNewFile()) { file.delete();/*from w w w . jav a 2 s . c o m*/ file.createNewFile(); } return file; }
From source file:org.dcache.xrootd.standalone.DataServerHandler.java
private File getFile(String path) throws XrootdException { String normalized = FilenameUtils.normalize(path); if (normalized == null) { throw new XrootdException(kXR_ArgInvalid, "Invalid path: " + path); }// w ww.ja va 2 s . c o m return new File(_configuration.root, normalized); }
From source file:org.easycloud.las.core.util.Files.java
/** * Create a directory//from w w w . j a v a 2s . c o m * * @param parentDir the full name of the parent directory to be created * @param childDir the relative name of the child directory * @return the newly created directory */ public static File makeDirectory(String parentDir, String childDir) { File rc = null; try { String p = FilenameUtils.normalize(parentDir); String c = FilenameUtils.normalize(childDir); File f = new File(p, c); if (!f.exists()) { FileUtils.forceMkdir(f); } rc = f; } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getMessage(), e); } throw new FileOperationsException("failed directory create " + parentDir + "." + childDir, e); } return rc; }
From source file:org.easycloud.las.core.util.Files.java
/** * Create a directory//from w w w . ja v a 2 s . co m * * @param dir the full name of the directory to be created * @return the newly created directory */ public static File makeDirectory(String dir) { File rc = null; try { String n = FilenameUtils.normalize(dir); File f = new File(n); if (!f.exists()) { FileUtils.forceMkdir(f); } rc = f; } catch (Exception e) { if (LOGGER.isErrorEnabled()) { LOGGER.error(e.getMessage(), e); } throw new FileOperationsException("failed to create directory " + dir, e); } return rc; }
From source file:org.easycloud.las.core.util.FilesTests.java
@Test public void testCopyDirectory() { File f = Files.makeDirectory("testdir999"); Files.createFile("testdir999", "testfile", "testContent", true); Files.copyDirectory("testdir999", "testdir929"); String n = FilenameUtils.normalize("testdir929"); File f2 = new File(n); org.testng.Assert.assertNotNull(f2); Files.deleteSubdirectories(f.getPath()); f.delete();/*from ww w . jav a2 s. c om*/ Files.deleteSubdirectories(f2.getPath()); f2.delete(); }
From source file:org.ebayopensource.turmeric.maven.banrefs.reports.ConsoleReport.java
public ConsoleReport(MavenProject project) { this.basedir = FilenameUtils.normalize(project.getBasedir().getAbsolutePath()); this.entryCount = 0; this.errorCount = 0; }
From source file:org.ebayopensource.turmeric.maven.config.reports.ConsoleReport.java
public ConsoleReport(Console console, MavenProject project) { super(console); this.basedir = FilenameUtils.normalize(project.getBasedir().getAbsolutePath()); }
From source file:org.ebayopensource.turmeric.maven.license.reports.ConsoleReport.java
public ConsoleReport(MavenProject project) { this.basedir = FilenameUtils.normalize(project.getBasedir().getAbsolutePath()); this.entryCount = 0; this.passCount = 0; this.violationCount = 0; this.failureCount = 0; }
From source file:org.ebayopensource.turmeric.tools.codegen.util.ClassPathUtil.java
private static void getClassPathFromClassLoader(LinkedList<File> classpath, ClassLoader classLoader) { if (classLoader == null) { return; // no classloader }/*from w w w. ja va 2s .c o m*/ if (!(classLoader instanceof URLClassLoader)) { // unable to get anything from this classloader. // Try parent instead. getClassPathFromClassLoader(classpath, classLoader.getParent()); return; } URLClassLoader ucl = (URLClassLoader) classLoader; URL[] urls = null; if (ucl instanceof CodeGenClassLoader) { CodeGenClassLoader cgcl = (CodeGenClassLoader) ucl; urls = cgcl.getAllURLs(); } else { urls = ucl.getURLs(); } // Add the urls File file; String path; for (URL url : urls) { // Normalize the path try { file = new File(url.toURI()); } catch (URISyntaxException e) { LOG.warning("Unable to identify file from invalid URI: " + url.toExternalForm()); path = url.toExternalForm(); if (path.startsWith("file:")) { path = path.substring("file:".length()); path = FilenameUtils.normalize(path); } file = new File(path); } addFilePath(classpath, file); } getClassPathFromClassLoader(classpath, classLoader.getParent()); dumpStats(); }
From source file:org.ebayopensource.turmeric.tools.codegen.util.ClassPathUtil.java
private static List<File> getJarClassPathRefs(File file) { List<File> refs = new ArrayList<File>(); JarFile jar = null;/* w ww.j a v a 2s. c om*/ try { jar = new JarFile(file); Manifest manifest = jar.getManifest(); if (manifest == null) { // No manifest, no classpath. return refs; } Attributes attrs = manifest.getMainAttributes(); if (attrs == null) { /* * No main attributes. (not sure how that's possible, but we can skip this jar) */ return refs; } String classPath = attrs.getValue(Attributes.Name.CLASS_PATH); if (CodeGenUtil.isEmptyString(classPath)) { return refs; } String parentDir = FilenameUtils.getFullPath(file.getAbsolutePath()); File possible; for (String path : StringUtils.splitStr(classPath, ' ')) { possible = new File(path); if (!possible.isAbsolute()) { // relative path? possible = new File(FilenameUtils.normalize(parentDir + path)); } if (!refs.contains(possible)) { refs.add(possible); } } } catch (IOException e) { LOG.log(Level.WARNING, "Unable to load/read/parse Jar File: " + file.getAbsolutePath(), e); } finally { CodeGenUtil.closeQuietly(jar); } return refs; }