NAME

SMB::OpenFile - A state of opening local or remote file for SMB

SYNOPSIS

        use SMB::File;

        # for server, on Create request
        my $file = SMB::File->new(
                name => $create_request->file_name,
                share_root => $tree->root,
                is_ipc => $tree->is_ipc,
        );
        my $openfile = $file->supersede;  # or: create, open, overwrite etc
        $openfile->close;
        $openfile = $file->open_by_disposition(SMB::File::DISPOSITION_OPEN_IF);


        # for client, on Create response
        my $file = $create_response->openfile->file;

DESCRIPTION

This class implements an SMB open-file abstraction, mainly for a server.

This class inherits from SMB, so msg, err, mem, dump, auto-created field accessor and other methods are available as well.

METHODS

new FILE HANDLE ACTION [OPTIONS]

Class constructor. Creates an instance of SMB::OpenFile.

FILE is an SMB::File object being open, HANDLE is a unix file descriptor, and ACTION is one of ACTION_OPENED, ACTION_CREATED and so on, see SMB::File.

close

Performs the opposite operation to the constructor.

Internally this is implemented by calling SMB::File delete_openfile, and the constructor is normally called from SMB::File add_openfile.

read OPTIONS

For openfile corresponding to the local file (having the actual HANDLE) performs the read operation according to the OPTIONS hash values.

The OPTIONS keys are offset, length and minlen. Option length is mandatory (may be 0), the others are optional and default to 0.

On success, the buffer of length or less bytes being read starting from offset is returned. On error (or if lesser than minlen bytes were read from file HANDLE), undef is returned.

SEE ALSO

SMB::File, SMB::Server, SMB.

AUTHOR

Mikhael Goikhman <migo@cpan.org>