summaryrefslogtreecommitdiff
path: root/fml/lib/IO
diff options
context:
space:
mode:
authorfukachan <fukachan>2001-08-26 05:52:08 +0000
committerfukachan <fukachan>2001-08-26 05:52:08 +0000
commit7b5715dcff778b1aa3886889a788539fbe0daa7d (patch)
tree2dd676f11269c6d3325aed26e54a5603f303a3ba /fml/lib/IO
parent56e590f604349f574237d3024fb017358fe963fb (diff)
downloadfml8-7b5715dcff778b1aa3886889a788539fbe0daa7d.tar.gz
fml8-7b5715dcff778b1aa3886889a788539fbe0daa7d.tar.bz2
fml8-7b5715dcff778b1aa3886889a788539fbe0daa7d.zip
add touch() method only for file type. It creates a file if the file
not exists.
Diffstat (limited to 'fml/lib/IO')
-rw-r--r--fml/lib/IO/Adapter.pm19
-rw-r--r--fml/lib/IO/Adapter/File.pm22
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}";}