/** * Sets file parameter(s) for directory and filename if the attribute * 'filenameparameter' or 'filedirparameter' are set in the task. * * @param liaison to change parameters for * @param inFile to get the additional file information from * @throws Exception if an exception occurs on filename lookup * * @since Ant 1.7 */ private void setLiaisonDynamicFileParameters( final XSLTLiaison liaison, final File inFile) throws Exception { //NOSONAR if (fileNameParameter != null) { liaison.addParam(fileNameParameter, inFile.getName()); } if (fileDirParameter != null) { final String fileName = FileUtils.getRelativePath(baseDir, inFile); final File file = new File(fileName); // Give always a slash as file separator, so the stylesheet could be sure about that // Use '.' so a dir + "/" + name would not result in an absolute path liaison.addParam(fileDirParameter, file.getParent() != null ? file.getParent().replace( '\\', '/') : "."); } }
relPath = "."; } else { relPath = FileUtils.getRelativePath(dir, pathEntry);
src.getName(), FileUtils .getRelativePath(dest .getParentFile(), src), FileUtils .getRelativePath(getProject() .getBaseDir(), src),
: new File(untypedValue.toString()); File to = basedir != null ? basedir : getProject().getBaseDir(); String relPath = FileUtils.getRelativePath(to, from); relPath = relPath.replace('/', File.separatorChar); addProperty(name, relPath);
protected String getInputFileArgument(final File outputDir, final String filename, final int index) { // // if there is an embedded space, // must enclose in quotes String relative=""; String inputFile; try { relative = FileUtils.getRelativePath(workDir, new File(filename)); } catch (Exception ex) { } if (relative.isEmpty()) { inputFile = filename; } else { inputFile = relative; } if (inputFile.indexOf(' ') >= 0) { final String buf = "\"" + inputFile + "\""; return buf; } return inputFile; }
/** * Returns a relative path from 'from' to 'to' * * @param from where to calculate from * @param to where to calculate to * @return The relative path */ public static String relativePath(File from, File to) { try { return org.apache.tools.ant.util.FileUtils.getRelativePath(from, to); } catch (Exception e) { throw UncheckedException.throwAsUncheckedException(e); } } }
@Override protected String getInputFileArgument(final File outputDir, final String filename, final int index) { if (index == 0) { final String outputFileName = getOutputFileNames(filename, null)[0]; final String fullOutputName = new File(outputDir, outputFileName).toString(); return "/Fo" + fullOutputName; } String relative=""; try { relative = FileUtils.getRelativePath(workDir, new File(filename)); } catch (Exception ex) { } if (relative.isEmpty()) { return filename; } else { return relative; } }
@Override protected String getInputFileArgument(final File outputDir, final String filename, final int index) { if (index == 0) { final String outputFileName = getOutputFileNames(filename, null)[0]; final String objectName = new File(outputDir, outputFileName).toString(); return "-o" + objectName; } String relative=""; try { relative = FileUtils.getRelativePath(workDir, new File(filename)); } catch (Exception ex) { } if (relative.isEmpty()) { return filename; } else { return relative; } }
@Override protected String getInputFileArgument(final File outputDir, final String filename, final int index) { switch (index) { case 0: return "-o"; case 1: final String outputFileName = getOutputFileNames(filename, null)[0]; final String objectName = new File(outputDir, outputFileName).toString(); return objectName; } String relative=""; try { relative = FileUtils.getRelativePath(workDir, new File(filename)); } catch (Exception ex) { } if (relative.isEmpty()) { return filename; } else { return relative; } }
@Override protected String getInputFileArgument(final File outputDir, final String filename, final int index) { switch (index) { case 0: return "-o"; case 1: final String outputFileName = getOutputFileNames(filename, null)[0]; final String objectName = new File(outputDir, outputFileName).toString(); return objectName; } String relative = ""; if ( this.gccFileAbsolutePath) { return filename; } else { try { relative = FileUtils.getRelativePath(workDir, new File(filename)); } catch (Exception ex) { } } if (relative.isEmpty()) { return filename; } else { return relative; } }
public boolean hasVetoBeforeOpen(FileHandle fileHandle) { try { String relativePath = FileUtils.getRelativePath(new File(fileHandle.getOutlet().getPath()), fileHandle .getTargetFile()); boolean fileExists = new File(this.checkPath + File.separatorChar + relativePath).exists(); if (fileExists) { logger.warn("Skip generation of already existing java source '" + fileHandle.getTargetFile() + "'"); } return fileExists; } catch (Exception exception) { logger.error("Error while testing existing file", exception); } return false; }