NAME
TPath::Forester::File::Node - represents file and its metadata
VERSION
version 0.003
SYNOPSIS
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;
DESCRIPTION
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.
ATTRIBUTES
real
Whether such a file exists in the file system.
broken
True if stat
called on the file returns the empty list.
name
The file or directory's name.
parent
The file's basedir. This is also a TPath::Forester::File::Node.
user
The user name corresonding to the file owner's uid.
group
The group name corresonding to the file's gid.
is_root
Whether this file represents the file system's root directory.
encoding
Character encoding lazily set using the node's encoding_detector
.
METHODS
text
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.
If the file cannot be opened for reading, the method quietly returns, setting $@
with an appropriate error message.
octets
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.
If the file cannot be opened for reading, the method quietly returns, setting $@
with an appropriate error message.
lines
Returns the files text, if it is a text file, as a list of lines minus endline characters.
compare($other, [$swapped])
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.
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.