Last active
August 29, 2015 13:58
-
-
Save jolle-c/9957349 to your computer and use it in GitHub Desktop.
Additions to Lasso 9 dir type that will filter out any invisible files or directories
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
/**! | |
Additions to Lasso 9 dir type that will filter out any invisible files or directories | |
The built in method dir -> eachFilePathRecursive returns all files and directories found | |
in the given path. Using dir -> eachVisibleFilePathRecursive will only return visible files | |
and directories. Very useful if you for example want to get a listing without possible | |
SVN directories in the path. | |
Example | |
local(tree = dir('/mypath/morepath/') -> jc_eachVisibleFilePathRecursive) | |
-> /_mypath/morepath/myfile.lasso, /_mypath/morepath/myimages/myimage.jpg | |
2014-04-03 JC Made into a gist | |
2012-09-13 JC First version | |
**/ | |
define dir -> jc_eachVisibleFilePath() => { | |
return with name in self->eachEntry where #name->second != io_dir_dt_dir where not(#name->first -> beginswith('.')) select .makeFullPath(#name->first) | |
} | |
define dir -> jc_eachVisibleDir() => { | |
return with name in self->eachEntry where #name->second == io_dir_dt_dir where not(#name->first -> beginswith('.')) select dir(.makeFullPath(#name->first + '/')) | |
} | |
define dir -> jc_eachVisibleFilePathRecursive(-dirFilter = void) => { | |
local(files = .jc_eachVisibleFilePath) | |
with dir in .jc_eachVisibleDir | |
where !#dirFilter or #dirFilter(#dir->realPath) | |
do { | |
#files = tie(#files, #dir->jc_eachVisibleFilePathRecursive(-dirFilter=#dirFilter)) | |
} | |
return #files | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment