Skip to content

raku-community-modules/File-Find

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Actions Status Actions Status Actions Status

NAME

File::Find - Get a lazy sequence of a directory tree

SYNOPSIS

use File::Find;

my @list := find(dir => 'foo');  # keep laziness
say @list[0..3];

my $list = find(dir => 'foo');   # keep laziness
say $list[0..3];

my @list = find(dir => 'foo');   # drop laziness
say @list[0..3];

DESCRIPTION

File::Find allows you to get the contents of the given directory, recursively, depth first. The only exported function, find(), generates a lazy list of files in given directory. Every element of the list is an IO::Path object, described below.

find() takes one (or more) named arguments. The dir argument is mandatory, and sets the directory find() will traverse. There are also few optional arguments. If more than one is passed, all of them must match for a file to be returned.

name

Specify a name of the file File::Find is ought to look for. If you pass a string here, find() will return only the files with the given name. When passing a regex, only the files with path matching the pattern will be returned. Any other type of argument passed here will just be smartmatched against the path (which is exactly what happens to regexes passed, by the way).

type

Given a type, find() will only return files being the given type. The available types are file, dir or symlink.

exclude

Exclude is meant to be used for skipping certain big and uninteresting directories, like '.git'. Neither them nor any of their contents will be returned, saving a significant amount of time.

The value of exclude will be smartmatched against each IO object found by File::Find. It's recommended that it's passed as an IO object (or a Junction of those) so we avoid silly things like slashes vs backslashes on different platforms.

Default is False, which means that no files will be excluded.

keep-going

Parameter keep-going tells find() to not stop finding files on errors such as 'Access is denied', but rather ignore the errors and keep going. Default is False

recursive

By default, find will recursively traverse a directory tree, descending into any subdirectories it finds. This behaviour can be changed by setting recursive to a false value. In this case, only the first level entries will be processed. Default is True.

follow-symlinks

Parameter follow-symlinks tells find() whether or not it should follow symlinks during recursive searches. This will still return symlinks in its results, if the type parameter allows. The default is True.

CAVEATS

List assignment is eager in Raku, so if You assign find() result to an array, the elements will be copied and the laziness will be spoiled. For a proper lazy list, use either binding (:=) or assign a result to a scalar value (see SYNOPSIS).

AUTHORS

  • Tadeusz Sośnierz

  • Dagur Valberg Johansson

  • Elizabeth Mattijsen

  • Filip Sergot

  • GlitchMr

  • Heather

  • isleofmax

  • Moritz Lenz

  • Paul Cochrane

  • Steve Mynott

  • Timo Paulssen

  • Tobias Leich"

Source can be located at: https://github.com/raku-community-modules/File-Find . Comments and Pull Requests are welcome.

COPYRIGHT AND LICENSE

Copyright 2010-2022 Tadeusz Sośnierz

Copuright 2023-2025 Raku Community

This library is free software; you can redistribute it and/or modify it under the MIT License.

About

File::Find Raku module

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 19

Languages