13 Jun 2012 01:37:45 UTC
- Distribution: File-Symlink-Atomic
- Module version: 0.002
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (400 / 7 / 42)
- KwaliteeBus factor: 0
- 92.31% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity24 month
- Download (21.08KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Take me over?The maintainer of this distribution is looking for someone to take over! If you're interested then please contact them via email.
- BUGS AND LIMITATIONS
- COPYRIGHT AND LICENSE
File::Symlink::Atomic - an atomic drop-in replacement for CORE::symlink
use File::Symlink::Atomic; # imports replacement symlink symlink "target", "name1"; # easy peasy symlink "bullseye", "name1"; # now atomic
Actually creating a symlink is not problematic, but making an existing one point at a new target may not be atomic on your system. For example, on Linux, the system does
symlink. In between, no symlink exists. If something goes wrong, you're left with nothing.
In your shell, you probably want to do something like:
mkdir old-target new target # Create your targets ln -s old-target link # Create your initial symlink # ln -sf new-target link # NOT atomic! ln -s new-target link-tmp && mv -Tf link-tmp link
Moving the symlink to the new name makes it atomic, because under the hood, the
rename, which is guaranteed to be atomic by POSIX.
File::Symlink::Atomic attempts to do the same thing in Perl what the command shown above does for your shell.
Creates a new filename symbolically linked to the old filename. Returns
0otherwise. This drop-in replacement for
CORE::symlinkcreates a symlink with a temporary name, then renames it to the name you requested - this ensures that if a symlink by the requested name already existed, then its target is updated atomically.
This module is not guaranteed to be portable. I have no idea what this will do on any platform other than Linux. Feel free to run the test suite to find out!
The project homepage is http://metacpan.org/release/File-Symlink-Atomic/.
The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see https://metacpan.org/module/File::Symlink::Atomic/.
You can make new bug reports, and view existing ones, through the web interface at https://github.com/doherty/File-Symlink-Atomic/issues.
Mike Doherty <email@example.com>
This software is copyright (c) 2012 by Mike Doherty.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install File::Symlink::Atomic, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install File::Symlink::Atomic
For more information on module installation, please visit the detailed CPAN module installation guide.