From c903e17c9dc5b9254c0d9464582aef247b0a92db Mon Sep 17 00:00:00 2001 From: vvelox Date: Sat, 9 Jan 2016 12:54:10 +0000 Subject: [PATCH] Bump to 0.1.0 and fix a possible race condition. git-svn-id: svn://127.0.0.1/Perl/File::Permissions::Unix/trunk@881 0c1c3402-1be1-de11-8092-0022686faf23 --- File-Permissions-Unix/Changes | 4 +++ .../lib/File/Permissions/Unix.pm | 31 +++++++++---------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/File-Permissions-Unix/Changes b/File-Permissions-Unix/Changes index 3d64d7b..a5a818f 100644 --- a/File-Permissions-Unix/Changes +++ b/File-Permissions-Unix/Changes @@ -1,4 +1,8 @@ Revision history for File-Permissions-Unix +0.1.0 2016-01-09/07:00 + -Remove the file existence check to remove a possible race condition. + This also depreciates error 3. + 0.0.0 2011-08-14/05:05 -Initial release. diff --git a/File-Permissions-Unix/lib/File/Permissions/Unix.pm b/File-Permissions-Unix/lib/File/Permissions/Unix.pm index 4b873c5..8e1b8cc 100644 --- a/File-Permissions-Unix/lib/File/Permissions/Unix.pm +++ b/File-Permissions-Unix/lib/File/Permissions/Unix.pm @@ -10,11 +10,11 @@ File::Permissions::Unix - A simple object oriented interface to handling file pe =head1 VERSION -Version 0.0.0 +Version 0.1.0 =cut -our $VERSION = '0.0.0'; +our $VERSION = '0.1.0'; =head1 SYNOPSIS @@ -110,13 +110,6 @@ sub chmod{ return undef; } - #make sure the item exists - if ( ! -e $file ){ - $self->{error}=3; - $self->{errorString}='"'.$file.'" does not exist'; - return undef; - } - #try to chmod the file if( ! chmod( oct($self->{mode}), $file )){ $self->{error}=4; @@ -171,7 +164,7 @@ sub setMode{ # make sure it is a valid mode if ( $mode !~ /^[01246][01234567][01234567][01234567]$/ ){ $self->{error}=1; - $self->{errorString}=''; + $self->{errorString}='"'.$mode.'" is not a valid mode'; return $self; } @@ -209,15 +202,13 @@ sub setModeFromFile{ return undef; } - #make sure the item exists - if ( ! -e $file ){ - $self->{error}=3; - $self->{errorString}='"'.$file.'" does not exist'; - return undef; - } - #stat the file and get it my $mode = (stat($file))[2] & 07777; + if ( !defined( $mode ) ){ + $self->{error}=5; + $self->{errorString}='Failed to stat the file "'.$file.'"'; + return $self; + } $mode=sprintf("%04o", $mode); $self->{mode}=$mode; @@ -243,10 +234,16 @@ No file specified. The file does not exist. +This has been depreciated as it introduces a possible race condition. + =head2 4 Failed to chmod the file. +=head2 5 + +Failed too stat the file. + =head1 AUTHOR Zane C. Bowers-Hadley, C<< >>