/** * Determines the file type of a {@link Resource}. * * @param r Resource * @return FileType */ public static FileType of(Resource r) { if (r.isDirectory()) { return FileType.DIR; } return FileType.REGULAR_FILE; } }
/** * Tells if the resource is a directory. * @return boolean flag indicating if the resource is a directory. */ @Override public boolean isDirectory() { return getResource().isDirectory(); }
/** * Return true if this Resource is selected. * @param r the Resource to check. * @return whether the Resource was selected. */ public boolean isSelected(final Resource r) { if (type == null) { throw new BuildException("The type attribute is required."); } final int i = type.getIndex(); return i == 2 || (r.isDirectory() ? i == 1 : i == 0); }
/** * The resource to pack; required. * @param src resource to expand */ public void setSrcResource(Resource src) { if (src.isDirectory()) { throw new BuildException("the source can't be a directory"); } if (src.as(FileProvider.class) != null || supportsNonFileResources()) { this.src = src; } else { throw new BuildException("Only FileSystem resources are supported."); } }
/** * Fetch all included and not excluded resources from the collections. * * <p>Included directories will precede included files.</p> * @param rcs an array of resource collections * @return the resources included * @since Ant 1.7 */ protected Resource[][] grabNonFileSetResources(final ResourceCollection[] rcs) { final Resource[][] result = new Resource[rcs.length][]; for (int i = 0; i < rcs.length; i++) { final List<Resource> dirs = new ArrayList<>(); final List<Resource> files = new ArrayList<>(); for (final Resource r : rcs[i]) { if (r.isDirectory()) { dirs.add(r); } else if (r.isExists()) { files.add(r); } } // make sure directories are in alpha-order - this also // ensures parents come before their children dirs.sort(Comparator.comparing(Resource::getName)); final List<Resource> rs = new ArrayList<>(dirs); rs.addAll(files); result[i] = rs.toArray(new Resource[rs.size()]); } return result; }
/** * Tells if the resource is a directory. * @return boolean flag indicating if the resource is a directory. */ public boolean isDirectory() { if (isReference()) { return getCheckedRef().isDirectory(); } //default false: return directory != null && directory; }
/** * The resource to pack; required. * @param src resource to expand */ public void setSrcResource(Resource src) { if (src.isDirectory()) { throw new BuildException("the source can't be a directory"); } FileProvider fp = src.as(FileProvider.class); if (fp != null) { source = fp.getFile(); } else if (!supportsNonFileResources()) { throw new BuildException("Only FileSystem resources are supported."); } this.src = src; }
/** * Tells if the resource is a directory. * @return boolean whether the resource is a directory. */ public synchronized boolean isDirectory() { return isReference() ? getCheckedRef().isDirectory() : getName().endsWith("/"); }
if (r.isDirectory() || contains.isEmpty()) { return true;
/** * Validate settings and ensure that the represented "archive entry" * has been established. */ protected final synchronized void checkEntry() throws BuildException { dieOnCircularReference(); if (haveEntry) { return; } String name = getName(); if (name == null) { throw new BuildException("entry name not set"); } Resource r = getArchive(); if (r == null) { throw new BuildException("archive attribute not set"); } if (!r.isExists()) { throw new BuildException("%s does not exist.", r); } if (r.isDirectory()) { throw new BuildException("%s denotes a directory.", r); } fetchEntry(); haveEntry = true; }
/** * Learn whether this Resource represents a directory. * @return boolean flag indicating whether the entry is a directory. */ @Override public boolean isDirectory() { if (isReference()) { return getCheckedRef().isDirectory(); } checkEntry(); return super.isDirectory(); }
return e1 ? 1 : -1; final boolean d1 = r1.isDirectory(); final boolean d2 = r2.isDirectory(); if (d1 && d2) { return 0;
/** * Drops all non-file resources from the given array. * @param orig the resources to filter * @return the filters resources * @since Ant 1.6 */ protected Resource[] selectFileResources(final Resource[] orig) { return selectResources(orig, r -> { if (!r.isDirectory()) { return true; } if (doFilesonly) { logWhenWriting("Ignoring directory " + r.getName() + " as only files will" + " be added.", Project.MSG_VERBOSE); } return false; }); }
/** * The resource to expand; required. * @param src resource to expand */ public void setSrcResource(Resource src) { if (!src.isExists()) { throw new BuildException("the archive %s doesn't exist", src.getName()); } if (src.isDirectory()) { throw new BuildException("the archive %s can't be a directory", src.getName()); } FileProvider fp = src.as(FileProvider.class); if (fp != null) { source = fp.getFile(); } else if (!supportsNonFileResources()) { throw new BuildException( "The source %s is not a FileSystem Only FileSystem resources are supported.", src.getName()); } srcResource = src; }
private void handleResources(Handler h) { for (Resource r : resources) { if (!r.isExists()) { log(r + " does not exist", Project.MSG_WARN); } if (r.isDirectory()) { log(r + " is a directory; length may not be meaningful", Project.MSG_WARN); } h.handle(r); } h.complete(); }
if (r.isDirectory()) { return true;
if (r1.isDirectory() || r2.isDirectory()) {
continue; if (resource.isDirectory() && doFilesonly) { continue; if (resource.isDirectory()) { addDirectoryResource(resource, name, "", base, zOut, ArchiveFileSet.DEFAULT_DIR_MODE,
"The archive " + src.getName() + " doesn't exist"); if (src.isDirectory()) { throw new BuildException("The archive " + src.getName() + " can't be a directory");
if (r.isDirectory() && !vPath.endsWith("/")) { vPath += "/"; if (!r.isDirectory()) { if (r.size() > TarConstants.MAXSIZE) { throw new BuildException( tOut.putNextEntry(te); if (!r.isDirectory()) { in = r.getInputStream();