@@ -0,0 +1,3115 @@
+/*%0A * Copyright 2014 Lukas Tenbrink%0A *%0A *    Licensed under the Apache License, Version 2.0 (the %22License%22);%0A *    you may not use this file except in compliance with the License.%0A *    You may obtain a copy of the License at%0A *%0A *        http://www.apache.org/licenses/LICENSE-2.0%0A *%0A *    Unless required by applicable law or agreed to in writing, software%0A *    distributed under the License is distributed on an %22AS IS%22 BASIS,%0A *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A *    See the License for the specific language governing permissions and%0A *    limitations under the License.%0A */%0A%0Apackage ivorius.ivtoolkit.tools;%0A%0Aimport net.minecraft.util.ResourceLocation;%0A%0Aimport java.io.IOException;%0Aimport java.net.URI;%0Aimport java.net.URISyntaxException;%0Aimport java.net.URL;%0Aimport java.nio.file.*;%0Aimport java.nio.file.attribute.BasicFileAttributes;%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.List;%0Aimport java.util.Objects;%0A%0A/**%0A * Created by lukas on 14.10.14.%0A */%0Apublic class IvPathHelper%0A%7B%0A    public static Path resourceToPath(URL resource) throws IOException, URISyntaxException%0A    %7B%0A        Objects.requireNonNull(resource, %22Resource URL cannot be null%22);%0A        URI uri = resource.toURI();%0A%0A        String scheme = uri.getScheme();%0A        if (scheme.equals(%22file%22))%0A        %7B%0A            return Paths.get(uri);%0A        %7D%0A%0A        if (!scheme.equals(%22jar%22))%0A        %7B%0A            throw new IllegalArgumentException(%22Cannot convert to Path: %22 + uri);%0A        %7D%0A%0A        String s = uri.toString();%0A        int separator = s.indexOf(%22!/%22);%0A        String entryName = s.substring(separator + 2);%0A        URI fileURI = URI.create(s.substring(0, separator));%0A%0A        try%0A        %7B%0A            FileSystem fs = FileSystems.getFileSystem(fileURI);%0A            if (fs.isOpen())%0A                return fs.getPath(entryName);%0A        %7D%0A        catch (FileSystemNotFoundException ignored) %7B%7D%0A%0A        FileSystem fs = FileSystems.newFileSystem(fileURI, Collections.%3CString, Object%3EemptyMap());%0A        return fs.getPath(entryName);%0A    %7D%0A%0A    public static Path pathFromResourceLocation(ResourceLocation resourceLocation) throws URISyntaxException, IOException%0A    %7B%0A        URL resource = IvPathHelper.class.getResource(%22/assets/%22 + resourceLocation.getResourceDomain() + %22/%22 + resourceLocation.getResourcePath());%0A        return resource != null ? resourceToPath(resource.toURI().toURL()) : null;%0A    %7D%0A%0A    public static List%3CPath%3E listFilesRecursively(Path dir, final DirectoryStream.Filter%3CPath%3E filter, final boolean recursive) throws IOException%0A    %7B%0A        final List%3CPath%3E files = new ArrayList%3C%3E();%0A        Files.walkFileTree(dir, new SimpleFileVisitor%3CPath%3E()%0A        %7B%0A            @Override%0A            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException%0A            %7B%0A                if (filter.accept(file))%0A                    files.add(file);%0A%0A                return recursive ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;%0A            %7D%0A        %7D);%0A        return files;%0A    %7D%0A%7D%0A

Add IvPathHelper for Java 1.7's Paths