Example usage for java.nio.file FileVisitResult SKIP_SUBTREE

List of usage examples for java.nio.file FileVisitResult SKIP_SUBTREE

Introduction

In this page you can find the example usage for java.nio.file FileVisitResult SKIP_SUBTREE.

Prototype

FileVisitResult SKIP_SUBTREE

To view the source code for java.nio.file FileVisitResult SKIP_SUBTREE.

Click Source Link

Document

Continue without visiting the entries in this directory.

Usage

From source file:net.mozq.picto.core.ProcessCore.java

public static void findFiles(ProcessCondition processCondition, Consumer<ProcessData> processDataSetter,
        BooleanSupplier processStopper) throws IOException {

    Set<FileVisitOption> fileVisitOptionSet;
    if (processCondition.isFollowLinks()) {
        fileVisitOptionSet = EnumSet.of(FileVisitOption.FOLLOW_LINKS);
    } else {// w  w w.j a va 2  s  .com
        fileVisitOptionSet = Collections.emptySet();
    }

    Files.walkFileTree(processCondition.getSrcRootPath(), fileVisitOptionSet, processCondition.getDept(),
            new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    if (processStopper.getAsBoolean()) {
                        return FileVisitResult.TERMINATE;
                    }

                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

                    if (attrs.isDirectory()) {
                        return FileVisitResult.SKIP_SUBTREE;
                    }

                    if (processStopper.getAsBoolean()) {
                        return FileVisitResult.TERMINATE;
                    }

                    if (!processCondition.getPathFilter().accept(file, attrs)) {
                        return FileVisitResult.SKIP_SUBTREE;
                    }

                    Path rootRelativeSubPath = processCondition.getSrcRootPath().relativize(file.getParent());

                    ImageMetadata imageMetadata = getImageMetadata(file);

                    Date baseDate;
                    if (processCondition.isChangeFileCreationDate()
                            || processCondition.isChangeFileModifiedDate()
                            || processCondition.isChangeFileAccessDate()
                            || processCondition.isChangeExifDate()) {
                        baseDate = getBaseDate(processCondition, file, attrs, imageMetadata);
                    } else {
                        baseDate = null;
                    }

                    String destSubPathname = processCondition.getDestSubPathFormat().format(varName -> {
                        try {
                            switch (varName) {
                            case "Now":
                                return new Date();
                            case "ParentSubPath":
                                return rootRelativeSubPath.toString();
                            case "FileName":
                                return file.getFileName().toString();
                            case "BaseName":
                                return FileUtilz.getBaseName(file.getFileName().toString());
                            case "Extension":
                                return FileUtilz.getExt(file.getFileName().toString());
                            case "Size":
                                return Long.valueOf(Files.size(file));
                            case "CreationDate":
                                return (processCondition.isChangeFileCreationDate()) ? baseDate
                                        : new Date(attrs.creationTime().toMillis());
                            case "ModifiedDate":
                                return (processCondition.isChangeFileModifiedDate()) ? baseDate
                                        : new Date(attrs.lastModifiedTime().toMillis());
                            case "AccessDate":
                                return (processCondition.isChangeFileAccessDate()) ? baseDate
                                        : new Date(attrs.lastAccessTime().toMillis());
                            case "PhotoTakenDate":
                                return (processCondition.isChangeExifDate()) ? baseDate
                                        : getPhotoTakenDate(file, imageMetadata);
                            case "Width":
                                return getEXIFIntValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_EXIF_IMAGE_WIDTH);
                            case "Height":
                                return getEXIFIntValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_EXIF_IMAGE_LENGTH);
                            case "FNumber":
                                return getEXIFDoubleValue(imageMetadata, ExifTagConstants.EXIF_TAG_FNUMBER);
                            case "Aperture":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_APERTURE_VALUE);
                            case "MaxAperture":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_MAX_APERTURE_VALUE);
                            case "ISO":
                                return getEXIFIntValue(imageMetadata, ExifTagConstants.EXIF_TAG_ISO);
                            case "FocalLength":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_FOCAL_LENGTH); // ?
                            case "FocalLength35mm":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_FOCAL_LENGTH_IN_35MM_FORMAT);
                            case "ShutterSpeed":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_SHUTTER_SPEED_VALUE);
                            case "Exposure":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_EXPOSURE); // 
                            case "ExposureTime":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_EXPOSURE_TIME); // 
                            case "ExposureMode":
                                return getEXIFIntValue(imageMetadata, ExifTagConstants.EXIF_TAG_EXPOSURE_MODE);
                            case "ExposureProgram":
                                return getEXIFIntValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_EXPOSURE_PROGRAM);
                            case "Brightness":
                                return getEXIFDoubleValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_BRIGHTNESS_VALUE);
                            case "WhiteBalance":
                                return getEXIFIntValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_WHITE_BALANCE_1);
                            case "LightSource":
                                return getEXIFIntValue(imageMetadata, ExifTagConstants.EXIF_TAG_LIGHT_SOURCE);
                            case "Lens":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_LENS);
                            case "LensMake":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_LENS_MAKE);
                            case "LensModel":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_LENS_MODEL);
                            case "LensSerialNumber":
                                return getEXIFStringValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_LENS_SERIAL_NUMBER);
                            case "Make":
                                return getEXIFStringValue(imageMetadata, TiffTagConstants.TIFF_TAG_MAKE);
                            case "Model":
                                return getEXIFStringValue(imageMetadata, TiffTagConstants.TIFF_TAG_MODEL);
                            case "SerialNumber":
                                return getEXIFStringValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_SERIAL_NUMBER);
                            case "Software":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_SOFTWARE);
                            case "ProcessingSoftware":
                                return getEXIFStringValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_PROCESSING_SOFTWARE);
                            case "OwnerName":
                                return getEXIFStringValue(imageMetadata, ExifTagConstants.EXIF_TAG_OWNER_NAME);
                            case "CameraOwnerName":
                                return getEXIFStringValue(imageMetadata,
                                        ExifTagConstants.EXIF_TAG_CAMERA_OWNER_NAME);
                            case "GPSLat":
                                return getEXIFGpsLat(imageMetadata);
                            case "GPSLatDeg":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE,
                                        0);
                            case "GPSLatMin":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE,
                                        1);
                            case "GPSLatSec":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LATITUDE,
                                        2);
                            case "GPSLatRef":
                                return getEXIFStringValue(imageMetadata,
                                        GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
                            case "GPSLon":
                                return getEXIFGpsLon(imageMetadata);
                            case "GPSLonDeg":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE,
                                        0);
                            case "GPSLonMin":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE,
                                        1);
                            case "GPSLonSec":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_LONGITUDE,
                                        2);
                            case "GPSLonRef":
                                return getEXIFStringValue(imageMetadata,
                                        GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
                            case "GPSAlt":
                                return getEXIFDoubleValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_ALTITUDE);
                            case "GPSAltRef":
                                return getEXIFIntValue(imageMetadata, GpsTagConstants.GPS_TAG_GPS_ALTITUDE_REF);
                            default:
                                throw new PictoInvalidDestinationPathException(Messages
                                        .getString("message.warn.invalid.destSubPath.varName", varName));
                            }
                        } catch (PictoException e) {
                            throw e;
                        } catch (Exception e) {
                            throw new PictoInvalidDestinationPathException(
                                    Messages.getString("message.warn.invalid.destSubPath.pattern"), e);
                        }
                    });

                    Path destSubPath = processCondition.getDestRootPath().resolve(destSubPathname).normalize();

                    if (!destSubPath.startsWith(processCondition.getDestRootPath())) {
                        throw new PictoInvalidDestinationPathException(
                                Messages.getString("message.warn.invalid.destination.path", destSubPath));
                    }

                    ProcessData processData = new ProcessData();
                    processData.setSrcPath(file);
                    processData.setSrcFileAttributes(attrs);
                    processData.setDestPath(destSubPath);
                    processData.setBaseDate(baseDate);

                    processDataSetter.accept(processData);

                    return FileVisitResult.CONTINUE;
                }
            });
}

From source file:spdxedit.SpdxLogic.java

/**
 * Creates a new package with the specified license, name, comment, and root
 * path.//w  w  w  .j  a v a  2 s  .  c o  m
 *
 * @param pkgRootPath
 *            The path from which the files will be included into the
 *            package. If absent, creates a "remote" package, i.e. one
 *            without files, just referencing a remote dependency.
 * @param name
 * @param omitHiddenFiles
 * @param declaredLicense
 * @param downloadLocation
 * @return
 */
public static SpdxPackage createSpdxPackageForPath(Optional<Path> pkgRootPath, AnyLicenseInfo declaredLicense,
        String name, String downloadLocation, final boolean omitHiddenFiles) {
    Objects.requireNonNull(pkgRootPath);
    try {

        SpdxPackage pkg = new SpdxPackage(name, declaredLicense,
                new AnyLicenseInfo[] {} /* Licences from files */, null /* Declared licenses */,
                declaredLicense, downloadLocation, new SpdxFile[] {} /* Files */,
                new SpdxPackageVerificationCode(null, new String[] {}));
        pkg.setLicenseInfosFromFiles(new AnyLicenseInfo[] { new SpdxNoAssertionLicense() });
        pkg.setCopyrightText("NOASSERTION");

        if (pkgRootPath.isPresent()) {
            // Add files in path
            List<SpdxFile> addedFiles = new LinkedList<>();
            String baseUri = pkgRootPath.get().toUri().toString();
            FileVisitor<Path> fileVisitor = new FileVisitor<Path>() {
                @Override
                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    if (omitHiddenFiles && dir.getFileName().toString().startsWith(".")) {
                        return FileVisitResult.SKIP_SUBTREE;
                    } else
                        return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    // Skip if omitHidden is set and this file is hidden.
                    if (omitHiddenFiles
                            && (file.getFileName().toString().startsWith(".") || Files.isHidden(file)))
                        return FileVisitResult.CONTINUE;
                    try {
                        SpdxFile addedFile = newSpdxFile(file, baseUri);
                        addedFiles.add(addedFile);
                    } catch (InvalidSPDXAnalysisException e) {
                        throw new RuntimeException(e);
                    }
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                    logger.error("Unable to add file ", file.toAbsolutePath().toString());
                    return FileVisitResult.CONTINUE;
                }

                @Override
                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                    return FileVisitResult.CONTINUE;
                }
            };
            Files.walkFileTree(pkgRootPath.get(), fileVisitor);
            SpdxFile[] files = addedFiles.stream().toArray(size -> new SpdxFile[size]);
            pkg.setFiles(files);
            recomputeVerificationCode(pkg);
        } else {
            //External package
            pkg.setFilesAnalyzed(false);
            pkg.setPackageVerificationCode(null);
        }
        return pkg;
    } catch (InvalidSPDXAnalysisException | IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.nridge.connector.fs.con_fs.core.FileCrawler.java

/**
 * Invoked for a directory before entries in the directory are visited.
 * Unless overridden, this method returns {@link java.nio.file.FileVisitResult#CONTINUE}
 *
 * @param aDirectory Directory instance.
 * @param aFileAttributes File attribute instance.
 *///from   w w w . ja va2s.  c o m
@Override
public FileVisitResult preVisitDirectory(Path aDirectory, BasicFileAttributes aFileAttributes)
        throws IOException {
    Logger appLogger = mAppMgr.getLogger(this, "preVisitDirectory");

    if (mAppMgr.isAlive()) {
        String pathName = aDirectory.toAbsolutePath().toString();
        if (mCrawlFollow.isMatchedNormalized(pathName)) {
            appLogger.debug(String.format("Following Path: %s", pathName));
            return FileVisitResult.CONTINUE;
        } else {
            appLogger.debug(String.format("Skipping Path: %s", pathName));
            return FileVisitResult.SKIP_SUBTREE;
        }
    } else
        return FileVisitResult.TERMINATE;
}

From source file:com.ibm.streamsx.topology.internal.context.remote.ZippedToolkitRemoteContext.java

private static void addAllToZippedArchive(Map<Path, String> starts, Path zipFilePath) throws IOException {
    try (ZipArchiveOutputStream zos = new ZipArchiveOutputStream(zipFilePath.toFile())) {
        for (Path start : starts.keySet()) {
            final String rootEntryName = starts.get(start);
            Files.walkFileTree(start, new SimpleFileVisitor<Path>() {
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    // Skip pyc files.
                    if (file.getFileName().toString().endsWith(".pyc"))
                        return FileVisitResult.CONTINUE;

                    String entryName = rootEntryName;
                    String relativePath = start.relativize(file).toString();
                    // If empty, file is the start file.
                    if (!relativePath.isEmpty()) {
                        entryName = entryName + "/" + relativePath;
                    }//ww  w .  j a  va2 s .co m
                    // Zip uses forward slashes
                    entryName = entryName.replace(File.separatorChar, '/');

                    ZipArchiveEntry entry = new ZipArchiveEntry(file.toFile(), entryName);
                    if (Files.isExecutable(file))
                        entry.setUnixMode(0100770);
                    else
                        entry.setUnixMode(0100660);

                    zos.putArchiveEntry(entry);
                    Files.copy(file, zos);
                    zos.closeArchiveEntry();
                    return FileVisitResult.CONTINUE;
                }

                public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                        throws IOException {
                    final String dirName = dir.getFileName().toString();
                    // Don't include pyc files or .toolkit 
                    if (dirName.equals("__pycache__"))
                        return FileVisitResult.SKIP_SUBTREE;

                    ZipArchiveEntry dirEntry = new ZipArchiveEntry(dir.toFile(), rootEntryName + "/"
                            + start.relativize(dir).toString().replace(File.separatorChar, '/') + "/");
                    zos.putArchiveEntry(dirEntry);
                    zos.closeArchiveEntry();
                    return FileVisitResult.CONTINUE;
                }
            });
        }
    }
}

From source file:org.schedulesdirect.grabber.Auditor.java

private Map<String, JSONObject> getStationMap() throws IOException, JSONException {
    final Map<String, JSONObject> map = new HashMap<>();
    final Path maps = vfs.getPath("maps");
    if (Files.isDirectory(maps)) {
        Files.walkFileTree(maps, new FileVisitor<Path>() {

            @Override/*from w  ww.ja  v a 2s. co m*/
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                return dir.equals(maps) ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                String input;
                try (InputStream ins = Files.newInputStream(file)) {
                    input = IOUtils.toString(ins, ZipEpgClient.ZIP_CHARSET.toString());
                }
                ObjectMapper mapper = Config.get().getObjectMapper();
                JSONArray jarr = mapper.readValue(
                        mapper.readValue(input, JSONObject.class).getJSONArray("stations").toString(),
                        JSONArray.class);
                for (int i = 0; i < jarr.length(); ++i) {
                    JSONObject jobj = jarr.getJSONObject(i);
                    String id = jobj.getString("stationID");
                    if (!map.containsKey(id))
                        map.put(id, jobj);
                }
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
                LOG.error(String.format("Unable to process map file '%s'", file), exc);
                Auditor.this.failed = true;
                return FileVisitResult.CONTINUE;
            }

            @Override
            public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
                return FileVisitResult.CONTINUE;
            }

        });
    }
    return map;
}

From source file:de.alexkamp.sandbox.ChrootSandbox.java

@Override
public void walkDirectoryTree(String basePath, final DirectoryWalker walker) throws IOException {
    final int baseNameCount = data.getBaseDir().toPath().getNameCount();

    File base = new File(data.getBaseDir(), basePath);

    Files.walkFileTree(base.toPath(), new FileVisitor<Path>() {
        @Override/*from ww  w  . j av a 2s .c om*/
        public FileVisitResult preVisitDirectory(Path path, BasicFileAttributes basicFileAttributes)
                throws IOException {
            if (walker.visitDirectory(calcSubpath(path))) {
                return FileVisitResult.CONTINUE;
            }
            return FileVisitResult.SKIP_SUBTREE;
        }

        private String calcSubpath(Path path) {
            if (path.getNameCount() == baseNameCount) {
                return "/";
            }
            return "/" + path.subpath(baseNameCount, path.getNameCount()).toString();
        }

        @Override
        public FileVisitResult visitFile(Path path, BasicFileAttributes basicFileAttributes)
                throws IOException {
            String subpath = calcSubpath(path);
            if (walker.visitFile(subpath)) {
                try (InputStream is = Files.newInputStream(path)) {
                    walker.visitFileContent(subpath, is);
                }
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path path, IOException e) throws IOException {
            if (walker.failed(e)) {
                return FileVisitResult.CONTINUE;
            } else {
                return FileVisitResult.TERMINATE;
            }
        }

        @Override
        public FileVisitResult postVisitDirectory(Path path, IOException e) throws IOException {
            return FileVisitResult.CONTINUE;
        }
    });
}

From source file:gov.noaa.pfel.coastwatch.util.FileVisitorDNLS.java

/** Invoked before entering a directory. */
public FileVisitResult preVisitDirectory(Path tDir, BasicFileAttributes attrs) throws IOException {

    String ttDir = String2.replaceAll(tDir.toString(), fromSlash, toSlash) + toSlash;
    if (ttDir.equals(dir)) {
        if (debugMode)
            String2.log(">> initial dir");
        return FileVisitResult.CONTINUE;
    }//from  ww  w  . j a va2s .co  m

    //skip because it doesn't match pathRegex?
    if (pathPattern != null && !pathPattern.matcher(ttDir).matches()) {
        if (debugMode)
            String2.log(">> doesn't match pathRegex: " + ttDir + " regex=" + pathRegex);
        return FileVisitResult.SKIP_SUBTREE;
    }

    if (directoriesToo) {
        directoryPA.add(ttDir);
        namePA.add("");
        lastModifiedPA.add(attrs.lastModifiedTime().toMillis());
        sizePA.add(0);
    }

    if (debugMode)
        String2.log(">> recursive=" + recursive + " dir=" + ttDir);
    return recursive ? FileVisitResult.CONTINUE : FileVisitResult.SKIP_SUBTREE;
}

From source file:io.anserini.index.IndexWebCollection.java

static Deque<Path> discoverWarcFiles(Path p, final String suffix) {

    final Deque<Path> stack = new ArrayDeque<>();

    FileVisitor<Path> fv = new SimpleFileVisitor<Path>() {

        @Override/*from w w w .ja va 2  s .  c o m*/
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {

            Path name = file.getFileName();
            if (name != null && name.toString().endsWith(suffix))
                stack.add(file);
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
            if ("OtherData".equals(dir.getFileName().toString())) {
                LOG.info("Skipping: " + dir);
                return FileVisitResult.SKIP_SUBTREE;
            }
            return FileVisitResult.CONTINUE;
        }

        @Override
        public FileVisitResult visitFileFailed(Path file, IOException ioe) {
            LOG.error("Visiting failed for " + file.toString(), ioe);
            return FileVisitResult.SKIP_SUBTREE;
        }
    };

    try {
        Files.walkFileTree(p, fv);
    } catch (IOException e) {
        LOG.error("IOException during file visiting", e);
    }
    return stack;
}

From source file:ch.bender.evacuate.Runner.java

/**
 * visit//from w w w .  j av  a 2 s  .  com
 * <p>
 * @param aPath
 * @return
 */
private FileVisitResult visit(Path aPath) {
    if (isExcluded(aPath)) {
        myLog.debug("Skip because on exclude list: " + aPath.toString());

        if (Files.isDirectory(aPath)) {
            myExclusionDirCount++;
        } else {
            myExclusionFileCount++;
        }

        return FileVisitResult.SKIP_SUBTREE;
    }

    Path subDirToBackupRoot = myBackupDir.relativize(aPath);
    Path origPendant = myOrigDir.resolve(subDirToBackupRoot);

    if (Files.notExists(origPendant)) {
        evacuate(aPath);

        if (Files.isDirectory(aPath)) {
            myEvacuationDirCount++;
            return FileVisitResult.SKIP_SUBTREE;
        }

        // else is file:
        myEvacuationFileCount++;
        return FileVisitResult.CONTINUE;
    }

    return FileVisitResult.CONTINUE;
}

From source file:org.springframework.cloud.config.monitor.FileMonitorConfiguration.java

private Set<File> walkDirectory(Path directory) {
    final Set<File> walkedFiles = new LinkedHashSet<File>();
    try {/*ww w .  jav  a 2 s.c om*/
        registerWatch(directory);
        Files.walkFileTree(directory, new SimpleFileVisitor<Path>() {

            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
                FileVisitResult fileVisitResult = super.preVisitDirectory(dir, attrs);
                // No need to monitor the git metadata
                if (dir.toFile().getPath().contains(".git")) {
                    return FileVisitResult.SKIP_SUBTREE;
                }
                registerWatch(dir);
                return fileVisitResult;
            }

            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                FileVisitResult fileVisitResult = super.visitFile(file, attrs);
                walkedFiles.add(file.toFile());
                return fileVisitResult;
            }

        });
    } catch (IOException e) {
        log.error("Failed to walk directory: " + directory.toString(), e);
    }
    return walkedFiles;
}