避免使用filemanip递归到specifc文件夹 [英] avoid recursion into specifc folder using filemanip

查看:92
本文介绍了避免使用filemanip递归到specifc文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在探索 filemanip 库,以在包含子文件夹的路径中搜索降价文件 >

I am exploring the filemanip library to search for markdown files in a path including subfolders

import System.FilePath.Find

find always (fileType ==? RegularFile &&? extension ==? ".md") "a/path/"

有什么方法可以指定不应递归的文件夹名称或模式

is there any way to specify a folder name or pattern into which it should not recurse

推荐答案

通过查看文档,我们可以看到

Looking at the documentation we can see that find takes as first argument a RecursionPredicate which in turn is just FindClause Bool.

基于此,我们可以看到我们必须将自定义RecursionPredicate传递给除always之外的find. 一个示例是忽略.git目录:

Based on this we can see that we have to pass in a custom RecursionPredicate to find other than always. One example is to ignore .git directories:

notGit :: FindClause Bool -- or via type alias also a RecursionPredicate
notGit = directory /=? ".git"

然后我们将新的递归谓词与find一起使用:

We then just use our new recursion predicate with find:

find notGit (fileType ==? RegularFile &&? extension ==? ".md") path

还要注意

Note also the special combinators for predicates to e.g. compose a notSvn predicate with our notGit predicate via (||?) to get a predicate that enters neither directories.

这篇关于避免使用filemanip递归到specifc文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆