Package com.android.builder.files
Class RelativeFiles
java.lang.Object
com.android.builder.files.RelativeFiles
Utilities to handle
RelativeFile.-
Method Summary
Modifier and TypeMethodDescriptionstatic Set<RelativeFile>fromDirectory(File directory) Loads all files in a directory recursively.static Set<RelativeFile>fromDirectory(File directory, Predicate<RelativeFile> filter) Loads all files in a directory recursively, filtering the results with a predicate.static Predicate<RelativeFile>fromPathPredicate(Predicate<String> predicate) Constructs a predicate over relative files from a predicate over paths, applying it to the normalized relative path contained in the relative file.static Set<RelativeFile>fromZip(com.android.builder.files.ZipCentralDirectory zip) Reads a zip file and adds all files in the file in a new relative set.
-
Method Details
-
fromDirectory
Loads all files in a directory recursively.- Parameters:
directory- the directory, must exist and be a readable directory- Returns:
- all files in the directory, sub-directories included
-
fromDirectory
@NonNull public static Set<RelativeFile> fromDirectory(@NonNull File directory, @NonNull Predicate<RelativeFile> filter) Loads all files in a directory recursively, filtering the results with a predicate. Filtering is only done at the end so, even if a directory is excluded from the filter, its files will be included if they are accepted by the filter.- Parameters:
directory- the directory, must exist and be a readable directoryfilter- a predicate to filter which files should be included in the result; only files to whom the filter application results intrueare included in the result- Returns:
- all files in the directory, sub-directories included
-
fromPathPredicate
@NonNull public static Predicate<RelativeFile> fromPathPredicate(@NonNull Predicate<String> predicate) Constructs a predicate over relative files from a predicate over paths, applying it to the normalized relative path contained in the relative file.- Parameters:
predicate- the file predicate- Returns:
- the relative file predicate built upon
predicate
-
fromZip
@NonNull public static Set<RelativeFile> fromZip(@NonNull com.android.builder.files.ZipCentralDirectory zip) throws IOException Reads a zip file and adds all files in the file in a new relative set.- Parameters:
zip- the zip file to read, must be a valid, existing zip file- Returns:
- the file set
- Throws:
IOException- failed to read the zip file
-