NAME

App::Ack::File

DESCRIPTION

Abstracts a file from the filesystem.

METHODS

new( $filename )

Opens the file specified by $filename and returns a filehandle and a flag that says whether it could be binary.

If there's a failure, it throws a warning and returns an empty list.

$file->name()

Returns the name of the file.

$file->basename()

Returns the basename (the last component the path) of the file.

$file->open()

Opens a filehandle for reading this file and returns it, or returns undef if the operation fails (the error is in $!). Instead of calling close $fh, $file->close should be called.

$file->needs_line_scan( \%opts )

Tells if the file needs a line-by-line scan. This is a big optimization because if you can tell from the outset that the pattern is not found in the file at all, then there's no need to do the line-by-line iteration.

Slurp up an entire file up to 100K, see if there are any matches in it, and if so, let us know so we can iterate over it directly. If it's bigger than 100K or the match is inverted, we have to do the line-by-line, too.

$file->reset()

Resets the file back to the beginning. This is only called if needs_line_scan() is true, but not always if needs_line_scan() is true.

$file->close()

Close the file.

$file->clone()

Clones this file.

$file->firstliney()

Returns the first line of a file (or first 250 characters, whichever comes first).