Mini Shell

Direktori : /usr/local/share/man/man3/
Upload File :
Current File : //usr/local/share/man/man3/IO::AtomicFile.3pm

.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "IO::AtomicFile 3"
.TH IO::AtomicFile 3 "2020-01-17" "perl v5.32.1" "User Contributed Perl Documentation"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
IO::AtomicFile \- write a file which is updated atomically
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 4
\&    use strict;
\&    use warnings;
\&    use feature \*(Aqsay\*(Aq;
\&    use IO::AtomicFile;
\&
\&    # Write a temp file, and have it install itself when closed:
\&    my $fh = IO::AtomicFile\->open("bar.dat", "w");
\&    $fh\->say("Hello!");
\&    $fh\->close || die "couldn\*(Aqt install atomic file: $!";
\&
\&    # Write a temp file, but delete it before it gets installed:
\&    my $fh = IO::AtomicFile\->open("bar.dat", "w");
\&    $fh\->say("Hello!");
\&    $fh\->delete;
\&
\&    # Write a temp file, but neither install it nor delete it:
\&    my $fh = IO::AtomicFile\->open("bar.dat", "w");
\&    $fh\->say("Hello!");
\&    $fh\->detach;
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This module is intended for people who need to update files
reliably in the face of unexpected program termination.
.PP
For example, you generally don't want to be halfway in the middle of
writing \fI/etc/passwd\fR and have your program terminate!  Even
the act of writing a single scalar to a filehandle is \fInot\fR atomic.
.PP
But this module gives you true atomic updates, via \f(CW\*(C`rename\*(C'\fR.
When you open a file \fI/foo/bar.dat\fR via this module, you are \fIactually\fR
opening a temporary file \fI/foo/bar.dat..TMP\fR, and writing your
output there. The act of closing this file (either explicitly
via \f(CW\*(C`close\*(C'\fR, or implicitly via the destruction of the object)
will cause \f(CW\*(C`rename\*(C'\fR to be called... therefore, from the point
of view of the outside world, the file's contents are updated
in a single time quantum.
.PP
To ensure that problems do not go undetected, the \f(CW\*(C`close\*(C'\fR method
done by the destructor will raise a fatal exception if the \f(CW\*(C`rename\*(C'\fR
fails.  The explicit \f(CW\*(C`close\*(C'\fR just returns \f(CW\*(C`undef\*(C'\fR.
.PP
You can also decide at any point to trash the file you've been
building.
.SH "METHODS"
.IX Header "METHODS"
IO::AtomicFile inherits all methods from IO::File and
implements the following new ones.
.SS "close"
.IX Subsection "close"
.Vb 1
\&    $fh\->close();
.Ve
.PP
This method calls its parent \*(L"close\*(R" in IO::File and then renames its temporary file
as the original file name.
.SS "delete"
.IX Subsection "delete"
.Vb 1
\&    $fh\->delete();
.Ve
.PP
This method calls its parent \*(L"close\*(R" in IO::File and then deletes the temporary file.
.SS "detach"
.IX Subsection "detach"
.Vb 1
\&    $fh\->detach();
.Ve
.PP
This method calls its parent \*(L"close\*(R" in IO::File. Unlike \*(L"delete\*(R" in IO::AtomicFile it
does not then delete the temporary file.
.SH "AUTHOR"
.IX Header "AUTHOR"
Eryq (\fIeryq@zeegee.com\fR).
President, ZeeGee Software Inc (\fIhttp://www.zeegee.com\fR).
.SH "CONTRIBUTORS"
.IX Header "CONTRIBUTORS"
Dianne Skoll (\fIdfs@roaringpenguin.com\fR).
.SH "COPYRIGHT & LICENSE"
.IX Header "COPYRIGHT & LICENSE"
Copyright (c) 1997 Erik (Eryq) Dorfman, ZeeGee Software, Inc. All rights reserved.
.PP
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

Zerion Mini Shell 1.0