++ed by:
PERLANCAR SHARYANTO

2 PAUSE user(s)

David F. Houghton

NAME

TPath::Forester::File - TPath::Forester that understands file systems

VERSION

version 0.003

ATTRIBUTES

encoding_detector

A code reference that when given a TPath::Forester::File::Node will return a guess as to its encoding, or some false value if it cannot hazard a guess. If no value is set for this attribute, the forester will attempt to construct one using Encode::Detect::Detector. If this proves impossible, it will provide a detector that never guesses. If you wish the latter -- just go with the system's default encoding -- set encoding_detector to undef.

Note, if you have a non-trivial encoding detector and you wish to access a file's text, you will end up reading the file's contents twice. If you want to save this expense and take your chances with the encoding, explicity set encoding_detector to undef.

METHODS

children

A file's children are the files it contains, if any. Links are regarded as having no children even if they are directory links.

tag

A file's "tag" is its name.

clean

clean purges all cached information about the file system. Because nodes only know their parents through weak references, if you clean the cache, all ancestor nodes which are not themselves descendants of some other node whose reference is still retained will be garbage collected.

This method is useful because to reduce file system thrash file meta-data is cached aggressively. To facilitate wrapping, this caching is done in the forester itself rather than the index. But this means that as the file system changes its cached representation can grow out of sync. So if you know or fear files have changed, you will want to clean the forester.

FUNCTIONS

tfr

Returns singleton TPath::Forester::File. This function has an empty prototype, so it may be used like a scalar.

  # collect all the text files under the first argument
  my @files = tff->path('//@txt')->select(shift);

AUTHOR

David F. Houghton <dfhoughton@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by David F. Houghton.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.