Browse Source

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-0022686faf
master
vvelox 3 years ago
parent
commit
c903e17c9d
2 changed files with 18 additions and 17 deletions
  1. 4
    0
      File-Permissions-Unix/Changes
  2. 14
    17
      File-Permissions-Unix/lib/File/Permissions/Unix.pm

+ 4
- 0
File-Permissions-Unix/Changes View File

@@ -1,4 +1,8 @@
1 1
 Revision history for File-Permissions-Unix
2 2
 
3
+0.1.0	 2016-01-09/07:00
4
+		 -Remove the file existence check to remove a possible race condition.
5
+		 		 This also depreciates error 3.
6
+
3 7
 0.0.0	 2011-08-14/05:05
4 8
 		 -Initial release.

+ 14
- 17
File-Permissions-Unix/lib/File/Permissions/Unix.pm View File

@@ -10,11 +10,11 @@ File::Permissions::Unix - A simple object oriented interface to handling file pe
10 10
 
11 11
 =head1 VERSION
12 12
 
13
-Version 0.0.0
13
+Version 0.1.0
14 14
 
15 15
 =cut
16 16
 
17
-our $VERSION = '0.0.0';
17
+our $VERSION = '0.1.0';
18 18
 
19 19
 =head1 SYNOPSIS
20 20
 
@@ -110,13 +110,6 @@ sub chmod{
110 110
 		return undef;
111 111
 	}
112 112
 
113
-	#make sure the item exists
114
-	if ( ! -e $file ){
115
-		$self->{error}=3;
116
-        $self->{errorString}='"'.$file.'" does not exist';
117
-        return undef;
118
-	}
119
-
120 113
 	#try to chmod the file
121 114
 	if( ! chmod( oct($self->{mode}), $file )){
122 115
 		$self->{error}=4;
@@ -171,7 +164,7 @@ sub setMode{
171 164
 	# make sure it is a valid mode
172 165
 	if ( $mode !~  /^[01246][01234567][01234567][01234567]$/ ){
173 166
 		$self->{error}=1;
174
-		$self->{errorString}='';
167
+		$self->{errorString}='"'.$mode.'" is not a valid mode';
175 168
 		return $self;
176 169
 	}
177 170
 
@@ -209,15 +202,13 @@ sub setModeFromFile{
209 202
 		return undef;
210 203
 	}
211 204
 
212
-	#make sure the item exists
213
-	if ( ! -e $file ){
214
-		$self->{error}=3;
215
-        $self->{errorString}='"'.$file.'" does not exist';
216
-        return undef;
217
-	}
218
-
219 205
 	#stat the file and get it
220 206
 	my $mode = (stat($file))[2] & 07777;
207
+	if ( !defined( $mode ) ){
208
+		$self->{error}=5;
209
+		$self->{errorString}='Failed to stat the file "'.$file.'"';
210
+		return $self;
211
+	}
221 212
 	$mode=sprintf("%04o", $mode);
222 213
 
223 214
 	$self->{mode}=$mode;
@@ -243,10 +234,16 @@ No file specified.
243 234
 
244 235
 The file does not exist.
245 236
 
237
+This has been depreciated as it introduces a possible race condition.
238
+
246 239
 =head2 4
247 240
 
248 241
 Failed to chmod the file.
249 242
 
243
+=head2 5
244
+
245
+Failed too stat the file.
246
+
250 247
 =head1 AUTHOR
251 248
 
252 249
 Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>

Loading…
Cancel
Save