4:60
      ˆ¿‘äÇò 8àH2Ë(e}ù?ŸËƒh¹Ê¾Ç      4:51
     ˆÆÅÊ492Ä¾Ç ì    ‹      ½”QoÓ0…ß÷+.~à­¹mÖMbsŒFRi][uA€Nì4IlwÝøõ¸MË
j<ÀSœë/÷žs,‡¾Hfqúq>‚Ûônówo&ãHñýyŒ˜¤I·1úÄÑ” )�k¯×ëu°>´YbºÀÒÕÕ­3*w�p‚°3º©±3 ¥äÂ?�:å*ÉÆ��� @½rV	é;·«¬Rù¾€B×­lD¡*Yë ´A®uë	�ÛžµÕžâÊ´%7[iª¼MÓ9.ä×•´Žb7ÕëÀ�šiñ´Ñ7øïZüÈm<ÛJÚ,£®„^©e§[Â¨ª—`MT¹n,fo¾KUà•‹È§q<ûì9tåækF9”FyGÓëY”6åµ¤È�3wž¹!lÂ­ƒZU()NÂ÷|¯¾�n˜tL"mnTë”nžQô­æº²-÷^/¼ƒÒR"~—Ï
c~³MÓd¼è"›ÏêþíÉ6÷•ÆA¢ŒÌ�6O;ã�Š—MfÛëý+ìlµ,a =8JþEN>ºÃ,ÒéÑb]×º	Úš°ËC¥¿HûaØô{á%„áÕðÀ)ƒË·§=üá©ãî>PÜÞLŠÝŸã;±V~œ    7   ˆl–äY>””†»Ú�vàœ¸ÔÅ£�þBÈˆ³ai¶]n@?üÿÌƒið=ËÊ¿È ,    package IO::AtomicFile;

### DOCUMENTATION AT BOTTOM OF FILE

# Be strict:
use strict;

# External modules:
use IO::File;


#------------------------------
#
# GLOBALS...
#
#------------------------------
use vars qw($VERSION @ISA);

# The package version, both in 1.23 style *and* usable by MakeMaker:
$VERSION = "2.111";

# Inheritance:
@ISA = qw(IO::File);


#------------------------------
# new ARGS...
#------------------------------
# Class method, constructor.
# Any arguments are sent to open().
#
sub new {
    my $class = shift;
    my $self = $class->SUPER::new();
    ${*$self}{'io_atomicfile_suffix'} = '';
    $self->open(@_) if @_;
    $self;
}

#------------------------------
# DESTROY 
#------------------------------
# Destructor.
#
sub DESTROY {
    shift->close(1);   ### like close, but raises fatal exception on failure
}

#------------------------------
# open PATH, MODE
#------------------------------
# Class/instance method.
#
sub open {
    my ($self, $path, $mode) = @_;
    ref($self) or $self = $self->new;    ### now we have an instance! 

    ### Create tmp path, and remember this info: 
    my $temp = "${path}..TMP" . ${*$self}{'io_atomicfile_suffix'};
    ${*$self}{'io_atomicfile_temp'} = $temp;
    ${*$self}{'io_atomicfile_path'} = $path;

    ### Open the file!  Returns filehandle on success, for use as a constructor: 
    $self->SUPER::open($temp, $mode) ? $self : undef;
}

#------------------------------
# _closed [YESNO]
#------------------------------
# Instance method, private.
# Are we already closed?  Argument sets new value, returns previous one.
#
sub _closed {
    my $self = shift;
    my $oldval = ${*$self}{'io_atomicfile_closed'};
    ${*$self}{'io_atomicfile_closed'} = shift if @_;
    $oldval;
}

#------------------------------
# close
#------------------------------
# Instance method.
# Close the handle, and rename the temp file to its final name.
#
sub close {
    my ($self, $die) = @_;
    unless ($self->_closed(1)) {             ### sentinel...
	    if ($self->SUPER::close()) {
		    rename(${*$self}{'io_atomicfile_temp'},
			   ${*$self}{'io_atomicfile_path'})
			or ($die ? die "close (rename) atomic file: $!\n" : return undef);
	    } else {
		    ($die ? die "close atomic file: $!\n" : return undef);
	    }
    }
    1;
}

#------------------------------
# delete
#------------------------------
# Instance method.
# Close the handle, and delete the temp file.
#
sub delete {
    my $self = shift;
    unless ($self->_closed(1)) {             ### sentinel...
        $self->SUPER::close();    
        return unlink(${*$self}{'io_atomicfile_temp'});
    }
    1;
}

#------------------------------
# detach
#------------------------------
# Instance method.
# Close the handle, but DO NOT delete the temp file.
#
sub detach {
    my $self = shift;
    $self->SUPER::close() unless ($self->_closed(1));
    1;
}

#------------------------------
1;
__END__


=head1 NAME

IO::AtomicFile - write a file which is updated atomically


=head1 SYNOPSIS

    use IO::AtomicFile;

    ### Write a temp file, and have it install itself when closed:
    my $FH = IO::AtomicFile->open("bar.dat", "w");
    print $FH "Hello!\n";
    $FH->close || die "couldn't install atomic file: $!";    

    ### Write a temp file, but delete it before it gets installed:
    my $FH = IO::AtomicFile->open("bar.dat", "w");
    print $FH "Hello!\n";
    $FH->delete; 

    ### Write 