From: Mike Taylor Date: Mon, 8 Dec 2014 16:56:34 +0000 (+0000) Subject: Some code, not complete. X-Git-Tag: v0.02~21 X-Git-Url: http://git.indexdata.com/?p=perl-indexdata-utils.git;a=commitdiff_plain;h=814599b13f90ab9771f5e22f0eac35e2d987deee Some code, not complete. --- diff --git a/lib/IndexData/Utils/PersistentCounter.pm b/lib/IndexData/Utils/PersistentCounter.pm index 5779261..95e18bc 100644 --- a/lib/IndexData/Utils/PersistentCounter.pm +++ b/lib/IndexData/Utils/PersistentCounter.pm @@ -4,4 +4,38 @@ use 5.018002; use strict; use warnings; +use IO::File; + + +sub new { + my $class = shift(); + my($file, $create) = @_; + + if (! -f $file) { + return undef if !$create; + # ### There is a bit of a race condition here, but it's not + # something that's going to crop up in real life. + my $fh = new IO::File(">$file") || return undef; + $fh->print("1\n"); + $fh->close() or return undef; + } + + my $this = bless { + file => $file, + }, $class; + + return $this; +} + + +sub next { + my $this = shift(); +} + + +sub delete { + my $this = shift(); +} + + 1;