diff options
| -rw-r--r-- | fml/lib/IO/Adapter.pm | 19 | ||||
| -rw-r--r-- | fml/lib/IO/Adapter/File.pm | 22 |
2 files changed, 38 insertions, 3 deletions
diff --git a/fml/lib/IO/Adapter.pm b/fml/lib/IO/Adapter.pm index 49388358..fbf365d8 100644 --- a/fml/lib/IO/Adapter.pm +++ b/fml/lib/IO/Adapter.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: Adapter.pm,v 1.5 2001/06/29 05:57:33 fukachan Exp $ +# $FML: Adapter.pm,v 1.6 2001/08/05 11:56:01 fukachan Exp $ # package IO::Adapter; @@ -235,6 +235,23 @@ sub open } +=head2 C<touch()> + +create a file if not exists. +This method is avaialble for file: type. + +=cut + +sub touch +{ + my ($self) = @_; + + if ($self->{'_type'} eq 'file') { + $self->SUPER::touch( { file => $self->{_file} } ); + } +} + + =head2 =item C<getline()> diff --git a/fml/lib/IO/Adapter/File.pm b/fml/lib/IO/Adapter/File.pm index b59bff29..72ad8131 100644 --- a/fml/lib/IO/Adapter/File.pm +++ b/fml/lib/IO/Adapter/File.pm @@ -4,7 +4,7 @@ # All rights reserved. This program is free software; you can # redistribute it and/or modify it under the same terms as Perl itself. # -# $FML: File.pm,v 1.22 2001/05/04 14:32:33 fukachan Exp $ +# $FML: File.pm,v 1.23 2001/05/30 14:35:10 fukachan Exp $ # package IO::Adapter::File; @@ -126,8 +126,26 @@ sub _rw_open } +=head2 C<touch()> + +create a file if not exists. + +=cut + +sub touch +{ + my ($self, $flag) = @_; + my $file = $self->{_file}; + + use IO::File; + my $fh = new IO::File; + $fh->open($file, "a"); + $fh->close; +} + + # debug tools -my $c = 0; +my $c = 0; my $ec = 0; sub line_count { my ($self) = @_; return "${ec}/${c}";} |
