NAME

File::Permissions::Unix - A simple object oriented interface to handling file permissions.

VERSION

Version 0.1.0

SYNOPSIS

use File::Permissions::Unix;

my $foo=File::Permissions::Unix->new('0640');

#chmods a /tmp/foo with 0640
$foo->chmod('/tmp/foo');

#do the same thing as above, but check if it worked
$foo->chmod('/tmp/foo');
if( $foo->error ){
    warn('error:'.$foo->error.': '.$foo->errorString);
}

#copies the mode from /tmp/foo to /tmp/bar
$foo->setModeFromFile('/tmp/foo');
$foo->chmod('/tmp/bar');

#prints the current mode
print $foo->getMode."\n";

METHODS

new

This initiates the object.

One arguement is accepted. It is the mode to intialize the object with. If not specified it defaults to '0644'.

my $foo=File::Permissions::Unix->new($mode);
if( $foo->error ){
    warn('error:'.$foo->error.': '.$foo->errorString);	
}

chmod

This chmods a file with the current mode.

One argument is required and it the file/directory/etc in question.

    $foo->chmod($file);
    if( $foo->error ){
        warn('error:'.$foo->error.': '.$foo->errorString);
	}

getMode

This returns the current mode.

my $mode=$foo->getMode;

setMode

This changes the currently set mode.

One argument is accepted and it is the current mode.

	$foo->setMode('0640')';
    if($foo->error){
	    warn('error:'.$foo->error.': '.$foo->errorString);
    }

setModeFromFile

This sets the current mode from a file.

One argument is required and it the file/directory/etc in question.

$foo->setModeFromFile($file);
if( $foo->error ){
    warn('error:'.$foo->error.': '.$foo->errorString);
}

ERROR CODES

1

Invalid mode.

This means it did not match the regexp below.

/^[01246][01234567][01234567][01234567]$/

2

No file specified.

3

The file does not exist.

This has been depreciated as it introduces a possible race condition.

4

Failed to chmod the file.

5

Failed too stat the file.

AUTHOR

Zane C. Bowers-Hadley, <vvelox at vvelox.net>

BUGS

Please report any bugs or feature requests to bug-file-permissions-unix at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Permissions-Unix. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

perldoc File::Permissions::Unix

You can also look for information at:

ACKNOWLEDGEMENTS

LICENSE AND COPYRIGHT

Copyright 2011 Zane C. Bowers-Hadley.

This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.

See http://dev.perl.org/licenses/ for more information.