List of usage examples for org.apache.commons.io FilenameUtils separatorsToUnix
public static String separatorsToUnix(String path)
From source file:org.ebayopensource.turmeric.plugins.maven.utils.AddMatchingFilesFilter.java
@Override public boolean accept(File pathname) { String relativePath = pathname.getAbsolutePath().substring(basedirnamelength); relativePath = FilenameUtils.separatorsToUnix(relativePath); String dbg = "miss"; if (pattern.matcher(relativePath).matches()) { dbg = "HIT "; hits.add(pathname);/*from w w w . j a va 2 s .c o m*/ } log.debug(dbg + " on pattern [" + pattern.pattern() + "]: " + relativePath); return true; }
From source file:org.ebayopensource.turmeric.runtime.config.validation.PathRegex.java
public String getRelativePath(File path) { String fullfilename = path.getAbsolutePath(); if (!fullfilename.startsWith(basedirname)) { throw new IllegalArgumentException("File " + path + " is not part of the basedir " + basedir); }/* ww w . j av a 2 s . c o m*/ String relpath = fullfilename.substring(basedirnamelength); return FilenameUtils.separatorsToUnix(relpath); }
From source file:org.eclipse.dirigible.runtime.scripting.AbstractScriptExecutor.java
private String getModuleName(String path) { path = FilenameUtils.separatorsToUnix(path); String workspace = ICommonConstants.WORKSPACE + ICommonConstants.SEPARATOR; String scriptingServices = getModuleType(path) // ICommonConstants.ARTIFACT_TYPE.SCRIPTING_SERVICES + ICommonConstants.SEPARATOR; int indexOfSandbox = path.indexOf(ICommonConstants.SANDBOX); int indexOfRegistry = path.indexOf(ICommonConstants.REGISTRY); String result = null;//from w w w . j av a 2 s . com if ((indexOfSandbox > 0) || (indexOfRegistry > 0)) { int indexOfScriptingServices = path.indexOf(scriptingServices); result = path.substring(indexOfScriptingServices + scriptingServices.length()); } else { int indexOfWorkspace = path.indexOf(workspace); result = path.substring(indexOfWorkspace + workspace.length()); result = result.replace(scriptingServices, ""); } return result; }
From source file:org.eclipse.skalli.model.ext.maven.internal.MavenResolver.java
/** * Concats <code>pathPrefix</code> and <code>path</code>, normalizes the result by * removing double and single dot path segments, converts all file separators to forward slashes * and removes a leading slash, if any./*from w w w . ja va 2s.c o m*/ * * @param pathPrefix the path prefix. * @param path the path relative to the path prefix. * @return the bnormalized path, or <code>null</code> of removing double and single dot path * segments yielded an invalid path, e.g. a path like <tt>"foo/../../bar"</tt> would be treated * as invalid. */ private String getNormalizedPath(String pathPrefix, String path) { String normalizedPath = FilenameUtils.normalize(pathPrefix + "/" + path); //$NON-NLS-1$ if (normalizedPath == null) { return null; } normalizedPath = FilenameUtils.separatorsToUnix(normalizedPath); if (normalizedPath.charAt(0) == '/') { normalizedPath = normalizedPath.substring(1); } return normalizedPath; }
From source file:org.eclipse.wb.internal.core.utils.IOUtils2.java
/** * Converts all separators to the Unix separator of forward slash. *//* w w w . j a v a 2 s .c om*/ public static String toPortablePath(String path) { return FilenameUtils.separatorsToUnix(path); }
From source file:org.eclipse.wb.tests.designer.swt.model.property.ImageDescriptorPropertyEditorTestNoManager.java
/** * Test for {@link ImageDescriptor#createFromFile(Class, String)} with <code>null</code> as * location./*w ww . j a v a 2 s.com*/ */ public void test_textSource_absolutePath() throws Exception { File file = createTempImage(); try { String path = FilenameUtils.separatorsToUnix(file.getCanonicalPath()); assert_getText_getClipboardSource_forSource("ImageDescriptor.createFromFile(null, \"" + path + "\")", "File: " + path, "org.eclipse.jface.resource.ImageDescriptor.createFromFile(null, \"" + path + "\")"); } finally { file.delete(); } }
From source file:org.eclipse.wb.tests.designer.swt.model.property.ImageDescriptorPropertyEditorTestWithManager.java
/** * Test for {@link ImageDescriptor#createFromFile(Class, String)} with <code>null</code> as * location, so absolute path.//from ww w. ja v a 2 s .c o m */ public void test_textSource_absolutePath() throws Exception { File file = createTempImage(); try { String path = FilenameUtils.separatorsToUnix(file.getCanonicalPath()); String source = "ImageDescriptor.createFromFile(null, \"" + path + "\")"; assert_getText_getClipboardSource_forSource(source, "File: " + path, "org.eclipse.wb.swt.ResourceManager.getImageDescriptor(\"" + path + "\")"); } finally { file.delete(); } }
From source file:org.eclipse.wb.tests.designer.swt.model.property.ImageDescriptorPropertyEditorTestWithManager.java
/** * Test for <code>ResourceManager.getImageDescriptor(absolutePath)</code>. *//*from w w w . j a v a 2s . c o m*/ public void test_textSource_absolutePath2() throws Exception { File file = createTempImage(); try { String path = FilenameUtils.separatorsToUnix(file.getCanonicalPath()); assert_getText_getClipboardSource_forSource( "org.eclipse.wb.swt.ResourceManager.getImageDescriptor(\"" + path + "\")", "File: " + path, "org.eclipse.wb.swt.ResourceManager.getImageDescriptor(\"" + path + "\")"); } finally { file.delete(); } }
From source file:org.eclipse.wb.tests.designer.swt.model.property.ImagePropertyEditorTestNoManager.java
/** * Image creation using constructor with absolute file path. *///from w ww . j av a2 s . c o m public void test_textSource_absolutePath() throws Exception { File file = createTempImage(); try { String path = FilenameUtils.separatorsToUnix(file.getCanonicalPath()); assert_getText_getClipboardSource_forSource("new Image(null, \"" + path + "\")", "File: " + path, "new org.eclipse.swt.graphics.Image(null, \"" + path + "\")"); } finally { file.delete(); } }
From source file:org.eclipse.wb.tests.designer.swt.model.property.ImagePropertyEditorTestWithManager.java
/** * Image creation using constructor with absolute file path. *//*from www.j ava 2 s. co m*/ public void test_textSource_absolutePath() throws Exception { File file = createTempImage(); try { String path = FilenameUtils.separatorsToUnix(file.getCanonicalPath()); assert_getText_getClipboardSource_forSource("new Image(null, \"" + path + "\")", "File: " + path, "org.eclipse.wb.swt.SWTResourceManager.getImage(\"" + path + "\")"); } finally { file.delete(); } }