Revision ab9162ac
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/SessionFile.pm | ||
---|---|---|
16 | 16 |
); |
17 | 17 |
|
18 | 18 |
sub new { |
19 |
my ($class, $file_name, $mode) = @_;
|
|
19 |
my ($class, $file_name, %params) = @_;
|
|
20 | 20 |
|
21 | 21 |
my $self = $class->SUPER::new; |
22 | 22 |
|
... | ... | |
24 | 24 |
$file_name =~ s:.*/::g; |
25 | 25 |
$file_name = "${path}/${file_name}"; |
26 | 26 |
|
27 |
$self->fh(IO::File->new($file_name, $mode)) if $mode; |
|
27 |
if ($params{mode}) { |
|
28 |
my $mode = $params{mode}; |
|
29 |
|
|
30 |
if ($params{encoding}) { |
|
31 |
$params{encoding} =~ s/[^a-z0-9\-]//gi; |
|
32 |
$mode .= ':encoding(' . $params{encoding} . ')'; |
|
33 |
} |
|
34 |
|
|
35 |
$self->fh(IO::File->new($file_name, $mode)); |
|
36 |
} |
|
37 |
|
|
28 | 38 |
$self->file_name($file_name); |
29 | 39 |
|
30 | 40 |
return $self; |
... | ... | |
108 | 118 |
|
109 | 119 |
=over 4 |
110 | 120 |
|
111 |
=item C<new $file_name, [$mode]>
|
|
121 |
=item C<new $file_name, [%params]>
|
|
112 | 122 |
|
113 | 123 |
Create a new instance. C<$file_name> is a relative file name (path |
114 | 124 |
components are stripped) to the session-specific temporary directory. |
115 | 125 |
|
116 |
If C<$mode> is given then try to open the file as an instance of |
|
117 |
C<IO::File>. C<$mode> is passed through to C<IO::File::new>. |
|
126 |
If C<$params{mode}> is given then try to open the file as an instance |
|
127 |
of C<IO::File>. C<${mode}> is passed through to C<IO::File::new>. |
|
128 |
|
|
129 |
If C<$params{encoding}> is given then the file is opened with the |
|
130 |
appropriate encoding layer. |
|
118 | 131 |
|
119 | 132 |
=item C<fh> |
120 | 133 |
|
Auch abrufbar als: Unified diff
Möglichkeit, das Encoding anzugeben; 'mode'-Paramter ist nun ">" oder "<"
Conflicts: