Some code, not complete.
authorMike Taylor <mike@indexdata.com>
Mon, 8 Dec 2014 16:56:34 +0000 (16:56 +0000)
committerMike Taylor <mike@indexdata.com>
Mon, 8 Dec 2014 16:56:34 +0000 (16:56 +0000)
lib/IndexData/Utils/PersistentCounter.pm

index 5779261..95e18bc 100644 (file)
@@ -4,4 +4,38 @@ use 5.018002;
 use strict;
 use warnings;
 
 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;
 1;