Steven Haryanto > Setup-File > Setup::File

Download:
Setup-File-0.19.tar.gz

Dependencies

Annotate this POD

Website

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.19   Source  

NAME ^

Setup::File - Setup file (existence, mode, permission, content)

VERSION ^

This document describes version 0.19 of Setup::File (from Perl distribution Setup-File), released on 2014-05-02.

FUNCTIONS ^

chmod(%args) -> [status, msg, result, meta]

Set file's permission mode.

Fixed state: path exists and mode is already correct.

Fixable state: path exists but mode is not correct.

Unfixable state: path doesn't exist.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

chown(%args) -> [status, msg, result, meta]

Set file's ownership.

Fixed state: path exists and ownership is already correct.

Fixable state: path exists but ownership is not correct.

Unfixable state: path doesn't exist.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

mkdir(%args) -> [status, msg, result, meta]

Create directory.

Fixed state: path exists and is a directory.

Fixable state: path doesn't exist.

Unfixable state: path exists and is not a directory.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

mkfile(%args) -> [status, msg, result, meta]

Create file (and/or set content).

Fixed state: path exists, is a file, and content is correct.

Fixable state: path doesn't exist. Or path exists, is a file, and content is incorrect. Or orig_path specified and exists.

Unfixable state: path exists and is not a file.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

rmdir(%args) -> [status, msg, result, meta]

Delete directory.

Fixed state: path doesn't exist.

Fixable state: path exists and is a directory (or, a symlink to a directory, if allow_symlink option is enabled).

Unfixable state: path exists but is not a directory.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

rmfile(%args) -> [status, msg, result, meta]

Delete file.

Fixed state: path doesn't exist.

Fixable state: path exists and is a file (or, a symlink to a file, if allow_symlink option is enabled).

Unfixable state: path exists but is not a file.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

setup_dir(%args) -> [status, msg, result, meta]

Setup directory (existence, mode, permission).

On do, will create directory (if it doesn't already exist) and fix its mode/permission.

On undo, will restore old mode/permission (and delete directory if it is empty and was created by this function). If directory was created by this function but is not empty, will return status 331 to ask for confirmation (-confirm). If confirmation is set to true, will delete non-empty directory.

Will not create intermediate directories like "mkdir -p". Create intermediate directories using several setup_dir() invocation.

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

setup_file(%args) -> [status, msg, result, meta]

Setup file (existence, mode, permission, content).

On do, will create file (if it doesn't already exist) and correct mode/permission as well as content.

On undo, will restore old mode/permission/content, or delete the file again if it was created by this function and its content hasn't changed since (if content/ownership/mode has changed, function will request confirmation).

This function is idempotent (repeated invocations with same arguments has the same effect as single invocation). This function supports transactions.

Arguments ('*' denotes required arguments):

Special arguments:

Return value:

Returns an enveloped result (an array).

First element (status) is an integer containing HTTP status code (200 means OK, 4xx caller error, 5xx function error). Second element (msg) is a string containing error message, or 'OK' if status is 200. Third element (result) is optional, the actual result. Fourth element (meta) is called result metadata and is optional, a hash that contains extra information.

FAQ ^

Why not allowing coderef in 'check_content_func' and 'gen_content_func' argument?

Because transactional function needs to store its argument in database (currently in JSON), coderefs are not representable in JSON.

SEE ALSO ^

Setup

Setup::File::Dir

Setup::File::Symlink

HOMEPAGE ^

Please visit the project's homepage at https://metacpan.org/release/Setup-File.

SOURCE ^

Source repository is at https://github.com/sharyanto/perl-Setup-File.

BUGS ^

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Setup-File

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR ^

Steven Haryanto <stevenharyanto@gmail.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2014 by Steven Haryanto.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: