From e9fa4c98bb5f084739d3418ade3f0c51e34a0aa1 Mon Sep 17 00:00:00 2001 From: Arne Georg Gleditsch Date: Thu, 5 Jul 2007 00:51:08 +0200 Subject: Rebase tree. --- lib/LXRng/Repo/TmpFile.pm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/LXRng/Repo/TmpFile.pm (limited to 'lib/LXRng/Repo/TmpFile.pm') diff --git a/lib/LXRng/Repo/TmpFile.pm b/lib/LXRng/Repo/TmpFile.pm new file mode 100644 index 0000000..bc9024a --- /dev/null +++ b/lib/LXRng/Repo/TmpFile.pm @@ -0,0 +1,30 @@ +package LXRng::Repo::TmpFile; + +# This package is used to hold on to a reference to a physical copy of +# a file normally only present inside a repo of some sort. When it +# leaves scopy, the destructor will remove it. (The object acts as +# string containing the path of the physical manifestation of the +# file.) + +use strict; +use overload '""' => \&filename; + +sub new { + my ($class, %args) = @_; + + return bless(\%args, $class); +} + +sub filename { + my ($self) = @_; + + return $$self{'dir'}.'/'.$$self{'node'}; +} + +sub DESTROY { + my ($self) = @_; + unlink($$self{'dir'}.'/'.$$self{'node'}); + rmdir($$self{'dir'}); +} + +1; -- cgit v1.2.3