NAME

Mojo::File - File

SYNOPSIS

use Mojo::File;

my $file = Mojo::File->new('Hello!');
$file->add_chunk('World!');
print $file->slurp;

DESCRIPTION

Mojo::File is a container for files.

ATTRIBUTES

cleanup

my $cleanup = $file->cleanup;
$file       = $file->cleanup(1);

handle

my $handle = $file->handle;
$file      = $file->handle(IO::File->new);

Returns a IO::File object representing a file upload if called without arguments. Returns the invocant if called with arguments.

length

my $length = $file->length;
$file      = $file->length(9000);

path

my $path = $file->path;
$file    = $file->path('/foo/bar.txt');

METHODS

Mojo::File inherits all methods from Mojo::Base and implements the following new ones.

new

my $file = Mojo::File->new('Hello World!');

add_chunk

$file = $file->add_chunk('test 123');

contains

my $contains = $file->contains('random string');

get_chunk

my $chunk = $file->get_chunk($offset);

slurp

my $string = $file->slurp;

Returns the entire file content as a string.