Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
atomic_relink

Links the file to a new location and unlinks the file from its present location as determined by path(true), atomically overwriting any file entry at the new location. Very useful for preparing file content elsewhere and once ready, atomically making it visible at some named location to other processes. Note that operating systems with an unstable path(true) may relink any hard link to the file to the new location.

Description

Note that not all filing systems guarantee the atomicity of the relink itself (i.e. the file may appear at two locations in the filing system for a period of time), though all supported platforms do guarantee the atomicity of the replaced location i.e. the location you are relinking to will always refer to some valid file to all readers, and will never be deleted or missing. Some filing systems may also fail to do the unlink if power is lost close to the relinking operation.

On Windows, the destination directory cannot have any handle opened to it with delete/rename privileges (file_flags::write) anywhere in the system. This is an operating system limitation.

Be aware that on Windows AFIO operates exclusively in the NT kernel namespace, NOT the Win32 namespace, and therefore paths you supply are converted by afio::path in NT kernel namespace paths. normalise_path() can convert an afio path back to a Filesystem TS path for you, but note that this may not be the path that was supplied originally. NT kernel namespace paths have a 32,767 character limit and an almost POSIX like lack of restrictions on naming or historical behaviour quirks, but as a result AFIO does not support DOS short names or any of the other historical Win32 filing system baggage.

Related types: path_req

Synopsis
virtual void handle::atomic_relink(const path_req & req)
Parameters

Type

Concept

Name

Description

const path_req &

req

The absolute or relative (in which case precondition specifies a directory) path to relink to.

Header

#include <boost/afio/v2/afio.hpp>

Race Guarantees

Operating system Race guarantees under a changing file system
FreeBSD, Linux Race free up to the containing directory for both source and target.
OS X No guarantees.
Windows Race free for source if handle open, else up to the containing directory. Race free up to the target directory.


PrevUpHomeNext