TPath::Forester::File::Node - represents file and its metadata
version 0.003
use feature 'say'; use TPath::Forester::File qw(tff); my $file = tff->wrap('some_file.txt'); # use wrap, not new my $text = $file->text; say $file->is_binary ? 'yes' : 'no'; # no my @lines = $file->lines;
TPath::Forester::File::Node represents files as objects that know their place in the directory tree. The class caches most file attributes -- not file contents.
Whether such a file exists in the file system.
True if stat called on the file returns the empty list.
stat
The file or directory's name.
The file's basedir. This is also a TPath::Forester::File::Node.
The user name corresonding to the file owner's uid.
The group name corresonding to the file's gid.
Whether this file represents the file system's root directory.
Character encoding lazily set using the node's encoding_detector.
encoding_detector
Retrieves the file's text. Note: this is not an accessor; the file's text is not stored but retrieved anew every time text is invoked. If it is possible to determine the file's encoding using Encode::Detect::Detector, this character set will be used for decoding.
text
If the file cannot be opened for reading, the method quietly returns, setting $@ with an appropriate error message.
$@
Retrieve's the file's bytes. Note: this is not an accessor. Every time this method is invoked the bytes are read anew from the file system.
Returns the files text, if it is a text file, as a list of lines minus endline characters.
Object comparison method. This method requires that the other be an object of type TPath::Forester::File::Node, sorting such objects before all else. Otherwise it uses <cmp> on the stringification of the two objects.
David F. Houghton <dfhoughton@gmail.com>
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.
To install TPath::Forester::File, copy and paste the appropriate command in to your terminal.
cpanm
cpanm TPath::Forester::File
CPAN shell
perl -MCPAN -e shell install TPath::Forester::File
For more information on module installation, please visit the detailed CPAN module installation guide.