-
-
19 Nov 2011 19:58:33 UTC
- Distribution: File-Sync
- Module version: 0.11
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (1)
- Testers (4173 / 7 / 0)
- Kwalitee
Bus factor: 0- 89.29% Coverage
- License: unknown
- Activity
24 month- Tools
- Download (5.71KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- unknown
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
File::Sync - Perl access to fsync() and sync() function calls
SYNOPSIS
use File::Sync qw(fsync sync); sync(); fsync(\*FILEHANDLE) or die "fsync: $!"; # and if fdatasync() is available on your system: fdatasync($fh) or die "fdatasync: $!"; use File::Sync qw(fsync); use FileHandle; $fh = new FileHandle("> /tmp/foo") or die "new FileHandle: $!"; ... $fh->fsync() or die "fsync: $!";
DESCRIPTION
The fsync() function takes a Perl file handle as its only argument, and passes its fileno() to the C function fsync(). It returns undef on failure, or true on success. fdatasync() is identical in return value, but it calls C fdatasync() instead of fsync(), synchronizing only the data in the file, not the metadata.
The fsync_fd() function is used internally by fsync(); it takes a file descriptor as its only argument.
The sync() function is identical to the C function sync().
This module does not export any methods by default, but fsync() is made available as a method of the FileHandle class. Note carefully that as of 0.11, we no longer clobber anything in IO::Handle. You can replace any calls to IO::Handle::fsync() with IO::Handle::sync(): https://rt.cpan.org/Public/Bug/Display.html?id=50418
NOTES
Doing fsync() if the stdio buffers aren't flushed (with
$|
or the autoflush method) is probably pointless.Calling sync() too often on a multi-user system is slightly antisocial.
AUTHOR
Carey Evans <c.evans@clear.net.nz>
SEE ALSO
perl(1), fsync(2), sync(2), perlvar(1)
Module Install Instructions
To install File::Sync, copy and paste the appropriate command in to your terminal.
cpanm File::Sync
perl -MCPAN -e shell install File::Sync
For more information on module installation, please visit the detailed CPAN module installation guide.