/** * Construct a new FileResource using the specified basedir and relative name. * @param b the basedir as File. * @param name the relative filename. */ public FileResource(File b, String name) { this.baseDir = b; this.file = FILE_UTILS.resolveFile(b, name); }
/** * Return the canonical form of a filename. * <p> * If the specified file name is relative it is resolved * with respect to the project's base directory. * * @param fileName The name of the file to resolve. * Must not be <code>null</code>. * * @return the resolved File. * */ public File resolveFile(final String fileName) { return FILE_UTILS.resolveFile(baseDir, fileName); }
/** * Return the canonical form of a filename. * <p> * If the specified file name is relative it is resolved * with respect to the given root directory. * * @param fileName The name of the file to resolve. * Must not be <code>null</code>. * * @param rootDir The directory respective to which relative file names * are resolved. May be <code>null</code>, in which case * the current directory is used. * * @return the resolved File. * * @deprecated since 1.4.x */ @Deprecated public File resolveFile(final String fileName, final File rootDir) { return FILE_UTILS.resolveFile(rootDir, fileName); }
/** * Check to see if the target is up to date with respect to input files. * @param files the list of files to check. * @return true if the cab file is newer than its dependents. */ protected boolean isUpToDate(Vector<String> files) { final long cabModified = cabFile.lastModified(); return files.stream().map(f -> FILE_UTILS.resolveFile(baseDir, f)) .mapToLong(File::lastModified).allMatch(t -> t < cabModified); }
/** * Finds modules in the expanded modulesourcepath entry. * @param root the project root * @param pathToModule the path to modules folder * @param pathInModule the path in module to source folder * @param collector the map to put modules into * @since 1.9.7 */ private static void findModules( final File root, final String pathToModule, final String pathInModule, final Map<String,Collection<File>> collector) { final File f = FileUtils.getFileUtils().resolveFile(root, pathToModule); if (!f.isDirectory()) { return; } for (File module : f.listFiles(File::isDirectory)) { final String moduleName = module.getName(); final File moduleSourceRoot = pathInModule == null ? module : new File(module, pathInModule); Collection<File> moduleRoots = collector.computeIfAbsent(moduleName, k -> new ArrayList<>()); moduleRoots.add(moduleSourceRoot); } }
/** * Let project resolve the file - or do it ourselves if * rootDirectory has been set. */ private File resolveFile(String fileName) { return FILE_UTILS.resolveFile(rootDirectory == null ? getProject().getBaseDir() : rootDirectory, fileName); }
/** * Resolve a filename with Project's help - if we know one that is. */ private static File resolveFile(Project project, String relativeName) { return FileUtils.getFileUtils().resolveFile( (project == null) ? null : project.getBaseDir(), relativeName); }
/** * Validate that the task parameters are valid. * * @throws BuildException if parameters are invalid */ private void validate() throws BuildException { if (null == myFile) { myFile = FILE_UTILS.resolveFile(getProject().getBaseDir(), DEFAULT_FILENAME); } if (!myFile.exists()) { try { FILE_UTILS.createNewFile(myFile); } catch (final IOException ioe) { throw new BuildException( myFile + " doesn't exist and new file can't be created.", ioe); } } if (!myFile.canRead()) { throw new BuildException("Unable to read from " + myFile + "."); } if (!myFile.canWrite()) { throw new BuildException("Unable to write to " + myFile + "."); } } }
File f = FILE_UTILS.resolveFile(parent, dirName); final String target = f.getCanonicalPath(); files.add(target); relPath.append("../"); if (dirName.equals(dir)) { f = FILE_UTILS.resolveFile(parent, relPath + dir); files.add(f.getCanonicalPath()); if (files.size() > maxLevelsOfSymlinks
file = FILE_UTILS.resolveFile(helperImpl.buildFileParent, path); helperImpl.project.log("Warning: '" + systemId + "' in " + helperImpl.buildFile + " should be expressed simply as '" + path.replace('\\', '/')
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a java.io.File object the selector can use * @return whether the file should be selected or not */ @Override public boolean isSelected(File basedir, String filename, File file) { // throw BuildException on error validate(); // Determine file whose out-of-dateness is to be checked String[] destfiles = map.mapFileName(filename); // If filename does not match the To attribute of the mapper // then filter it out of the files we are considering if (destfiles == null) { return false; } // Sanity check if (destfiles.length != 1 || destfiles[0] == null) { throw new BuildException("Invalid destination file results for " + targetdir.getName() + " with filename " + filename); } String destname = destfiles[0]; File destfile = FILE_UTILS.resolveFile(targetdir, destname); return selectionTest(file, destfile); }
/** * The heart of the matter. This is where the selector gets to decide * on the inclusion of a file in a particular fileset. * * @param basedir the base directory the scan is being done from * @param filename is the name of the file to check * @param file is a java.io.File object the selector can use * @return whether the file should be selected or not */ @Override public boolean isSelected(final File basedir, final String filename, final File file) { // throw BuildException on error validate(); // Determine file whose existence is to be checked final String[] destfiles = map.mapFileName(filename); // If filename does not match the To attribute of the mapper // then filter it out of the files we are considering if (destfiles == null) { return false; } // Sanity check if (destfiles.length != 1 || destfiles[0] == null) { throw new BuildException("Invalid destination file results for " + targetdir + " with filename " + filename); } final String destname = destfiles[0]; final File destfile = FileUtils.getFileUtils().resolveFile(targetdir, destname); return destfile.exists() == destmustexist; }
private void collectFileListFromModulePath() { final FileUtils fu = FileUtils.getFileUtils(); for (String pathElement : moduleSourcepath.list()) { boolean valid = false; for (Map.Entry<String, Collection<File>> modules : resolveModuleSourcePathElement( getProject().getBaseDir(), pathElement).entrySet()) { final String moduleName = modules.getKey(); for (File srcDir : modules.getValue()) { if (srcDir.exists()) { valid = true; final DirectoryScanner ds = getDirectoryScanner(srcDir); final String[] files = ds.getIncludedFiles(); scanDir(srcDir, fu.resolveFile(destDir, moduleName), files); } } } if (!valid) { throw new BuildException("modulesourcepath \"" + pathElement + "\" does not exist!", getLocation()); } } }
+ MagicNames.ANT_HOME + "' not found"); String antRun = FILE_UTILS.resolveFile(project.getBaseDir(), antHome + File.separator + myScript).toString();
private Resource getFileAttributeResource() { // Paths are relative to the build file they're imported from, // *not* the current directory (same as entity includes). if (file != null) { if (isExistingAbsoluteFile(file)) { return new FileResource(FILE_UTILS.normalize(file)); } File buildFile = new File(getLocation().getFileName()).getAbsoluteFile(); if (buildFile.exists()) { File buildFileParent = new File(buildFile.getParent()); File importedFile = FILE_UTILS.resolveFile(buildFileParent, file); return new FileResource(importedFile); } // maybe this import tasks is inside an imported URL? try { URL buildFileURL = new URL(getLocation().getFileName()); URL importedFile = new URL(buildFileURL, file); return new URLResource(importedFile); } catch (MalformedURLException ex) { log(ex.toString(), Project.MSG_VERBOSE); } throw new BuildException("failed to resolve %s relative to %s", file, getLocation().getFileName()); } return null; }
file = FILE_UTILS.resolveFile(context.getBuildFileParent(), path); context.getProject().log( "Warning: '" + systemId + "' in " + context.getBuildFile()
executableFile = FILE_UTILS.resolveFile(dir, exec); if (executableFile.exists()) { return executableFile.getAbsolutePath(); for (String pathname : p.list()) { executableFile = FILE_UTILS.resolveFile(new File(pathname), exec); if (executableFile.exists()) { return executableFile.getAbsolutePath();
/** * Create a new resource that matches a relative or absolute path. * If the current instance has a compatible baseDir attribute, it is copied. * @param path relative/absolute path to a resource * @return a new resource of type FileResource * @throws BuildException if desired * @since Ant1.8 */ @Override public Resource getResource(String path) { File newfile = FILE_UTILS.resolveFile(getFile(), path); FileResource fileResource = new FileResource(newfile); if (FILE_UTILS.isLeadingPath(getBaseDir(), newfile)) { fileResource.setBaseDir(getBaseDir()); } return fileResource; }
/** * Get the file represented by this FileResource. * @return the File. */ @Override public File getFile() { if (isReference()) { return getCheckedRef().getFile(); } dieOnCircularReference(); synchronized (this) { if (file == null) { //try to resolve file set via basedir/name property setters: File d = getBaseDir(); String n = super.getName(); if (n != null) { setFile(FILE_UTILS.resolveFile(d, n)); } } } return file; }
File outfile; if (dir != null) { outfile = FILE_UTILS.resolveFile(dir, output); } else { outfile = getProject().resolveFile(output);