line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Umask::Local - Class for localizing the umask |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Umask::Local; |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
my $umask_local = Umask::Local->new(0077); |
10
|
|
|
|
|
|
|
open(FILE,">only_me"); |
11
|
|
|
|
|
|
|
close(FILE); |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
open(FILE,">default"); |
14
|
|
|
|
|
|
|
close(FILE); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
Umask::Local is use to set and reset the umask for the life of the object |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Umask::Local; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '1.0'; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
1
|
|
18885
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
27
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
28
|
1
|
|
|
1
|
|
4
|
use base qw(Exporter); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
243
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our @EXPORTS = qw(umask_localize); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 Methods |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Set the umask saving the previous umask |
37
|
|
|
|
|
|
|
Accepts only one parameter the umask |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Umask::Local->new(0077) |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
0
|
|
|
0
|
1
|
|
my $proto = shift; |
45
|
0
|
|
|
|
|
|
my $mask = shift; |
46
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
47
|
0
|
|
|
|
|
|
my $old_umask = umask($mask); |
48
|
0
|
|
|
|
|
|
return bless \$old_umask,$class; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 val |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
return the the previous umask |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=cut |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
0
|
1
|
|
sub val { ${$_[0]} } |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head2 umask_localize |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Convenience function |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
0
|
1
|
|
sub umask_localize { Umask::Local->new($_[0]) } |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 DESTROY |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Will reset the umask to the previous umask |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
|
|
sub DESTROY { umask ${$_[0]}; } |
|
0
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
__END__ |