public static List<Path> searchFiles(Path path, String globPattern) throws IOException {

    if (Files.isDirectory(path)) {
      Finder finder = new Finder(globPattern);
      Files.walkFileTree(path, finder);
      return finder.getPaths();
    } else {
      PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:" + globPattern);

      if (matcher.matches(path.getFileName())) {
        return Arrays.asList(path);
      } else {
        return Collections.emptyList();
      }
    }
  }