List of usage examples for org.apache.commons.io FilenameUtils getFullPathNoEndSeparator
public static String getFullPathNoEndSeparator(String filename)
From source file:com.xse.eclipseui.widgets.validators.PathValidator.java
@Override public IStatus validate(final String value) { final IStatus validationStatus = super.validate(value); if (validationStatus.isOK()) { if (!this.isMandatory() && StringUtils.isEmpty(value)) { return Status.OK_STATUS; }// w w w .ja va 2s . c o m final File file = new File(value); if (this.isDirectory) { if (file.exists() && file.isDirectory() && file.canWrite()) { return Status.OK_STATUS; } } else { if (this.exists) { if (file.exists() && file.isFile() && file.canRead()) { return Status.OK_STATUS; } } else { final String fullPathNoEndSeparator = FilenameUtils.getFullPathNoEndSeparator(value); if (fullPathNoEndSeparator != null) { final File parentPath = new File(fullPathNoEndSeparator); if (parentPath.exists() && parentPath.isDirectory() && parentPath.canExecute() && parentPath.canWrite()) { return Status.OK_STATUS; } } } } return new Status(this.errorLevel, this.pluginId, this.getMessage()); } return validationStatus; }
From source file:de.uzk.hki.da.grid.CTIrodsCommandLineConnector.java
@Before public void before() throws IOException, RuntimeException { new File(testCollPhysicalPathOnLTA + "/urn.tar").delete(); iclc = new IrodsCommandLineConnector(); dao = "/" + zone + "/" + dao; dao2 = "/" + zone + "/" + dao2; dao3 = "/" + zone + "/" + dao3; daolong = "/" + zone + "/" + daolong; file = createTestFile();//from ww w . j av a 2s .co m String destColl = FilenameUtils.getFullPathNoEndSeparator(dao); iclc.mkCollection(destColl); md5sum = MD5Checksum.getMD5checksumForLocalFile(file); assertTrue(iclc.put(file, dao, archiveStorage)); }
From source file:com.logsniffer.model.file.RollingLogsSource.java
protected Log[] getPastLogs(final String liveLog) throws IOException { final File dir = new File(FilenameUtils.getFullPathNoEndSeparator(liveLog)); final String pastPattern = FilenameUtils.getName(liveLog) + getPastLogsSuffixPattern(); final FileFilter fileFilter = new WildcardFileFilter(pastPattern); final File[] files = dir.listFiles(fileFilter); final FileLog[] logs = new FileLog[files.length]; Arrays.sort(files, getPastLogsType().getPastComparator()); int i = 0;//from w ww. j a v a 2s . co m for (final File file : files) { // TODO Decouple direct file log association logs[i++] = new FileLog(file); } logger.debug("Found {} past logs for {} with pattern {}", logs.length, liveLog, pastPattern); return logs; }
From source file:com.ariht.maven.plugins.config.DirectoryReader.java
/** * Read directory creating FileInfo for each file found, include sub-directories. *///w w w . j a va 2s . com public List<FileInfo> readFiles(final String path) throws IOException, InstantiationException, IllegalAccessException { log.debug("Scanning directory: " + path); final File directory = new File(path); final Collection<File> allFiles = getAllFiles(directory); if (allFiles.isEmpty()) { log.warn("No files found in directory: " + path); } final List<FileInfo> allFilesInfo = new ArrayList<FileInfo>(allFiles.size()); final String canonicalBaseDirectory = directory.getCanonicalPath(); for (final File file : allFiles) { final FileInfo fileInfo = new FileInfo(file); // Remove base directory to derive sub-directory final String canonicalFilePath = FilenameUtils.getFullPathNoEndSeparator(file.getCanonicalPath()); final String subDirectory = FilenameUtils.normalize( StringUtils.replaceOnce(canonicalFilePath, canonicalBaseDirectory, "") + pathSeparator); fileInfo.setRelativeSubDirectory(subDirectory); allFilesInfo.add(fileInfo); } return allFilesInfo; }
From source file:com.github.ipaas.ideploy.agent.CrsWebSvnUtil.java
/** * /*from www . j a v a 2 s. com*/ * * @param targetPath * @throws SVNException */ public void delete(String targetPath) throws Exception { if (!isPathExist(targetPath)) { return; } long headVerNum = SVNRevision.HEAD.getNumber(); String parentPath = FilenameUtils.getFullPathNoEndSeparator(targetPath); ISVNEditor editor = getEditor(); try { editor.openRoot(headVerNum); editor.openDir(parentPath, headVerNum); editor.deleteEntry(targetPath, headVerNum); editor.closeDir(); } catch (Exception e) { editor.abortEdit(); throw e; } finally { editor.closeEdit(); } }
From source file:com.docd.purefm.utils.PFMFileUtils.java
@Nullable public static String resolveFileSystem(@NonNull final GenericFile file) { final String path = PFMFileUtils.fullPath(file); return resolveFileSystem(FilenameUtils.getFullPathNoEndSeparator(path)); }
From source file:net.sf.firemox.tools.MToolKit.java
/** * Return the root directory.// w w w . j a va 2 s . c om * * @return the root directory. */ public static String getRootDir() { if (rootDir == null) { String requiredFile = RESOURCE_DEV; URL url = Thread.currentThread().getContextClassLoader().getResource(requiredFile); if (url == null) { requiredFile = RESOURCE_TEST; url = Thread.currentThread().getContextClassLoader().getResource(requiredFile); } if (url == null) { rootDir = new File("").getAbsolutePath(); } else { try { return StringUtils.removeEnd(new File(url.toURI()).getAbsolutePath(), requiredFile); } catch (URISyntaxException e) { rootDir = StringUtils.removeEnd(url.getPath(), requiredFile); } } if (rootDir.startsWith("/")) { rootDir = rootDir.substring(1); } rootDir = FilenameUtils.getFullPathNoEndSeparator(rootDir + "/") + "/"; } return rootDir; }
From source file:com.abiquo.nodecollector.aim.impl.AimCollectorImpl.java
@Override public List<ResourceType> getDatastores() throws AimException { List<Datastore> datastores; try {/*from w ww . java 2 s. co m*/ datastores = aimclient.getDatastores(); } catch (RimpException e) { final String cause = String.format("Can not obtain the datastores on [%s]", host); LOG.error(cause, e); throw new AimException(cause, e); } catch (TException e) { LOG.error(MessageValues.AIM_NO_COMM, e); throw new AimException(MessageValues.AIM_NO_COMM, e); } if (datastores == null || datastores.size() == 0) { final String cause = String.format(MessageValues.AIM_ANY_DATASTORE, host); LOG.error(cause); throw new AimException(cause); } List<ResourceType> resources = new LinkedList<ResourceType>(); for (Datastore ds : datastores) { // removing final slash '/' ds.setPath(FilenameUtils.getFullPathNoEndSeparator(ds.getPath())); resources.add(datastoreToResource(ds)); } return resources; }
From source file:context.ui.control.workflow.WorkflowController.java
/** * * @param textOutput/*from w w w. j av a 2 s .c o m*/ */ public void setTextOutputDirectory(DataElement textOutput) { if (textOutput == null || textOutput.getPath() == null) { return; } String dirPath = FilenameUtils.getFullPathNoEndSeparator(textOutput.getPath().get()); basicOutputViewController.getOutputDirTextField().textProperty().set(dirPath); }
From source file:ddf.content.plugin.video.VideoThumbnailPlugin.java
/** * Deletes the directory that holds the FFmpeg binary. * <p>//w w w. ja va2s . c o m * Called by Blueprint. */ public void destroy() { if (ffmpegPath != null) { final File ffmpegDirectory = new File(FilenameUtils.getFullPathNoEndSeparator(ffmpegPath)); if (!FileUtils.deleteQuietly(ffmpegDirectory)) { ffmpegDirectory.deleteOnExit(); } } }