Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

file_flags

Bitwise file and directory open flags.

Synopsis
enum file_flags {none = 0, read = 1, write = 2, read_write = 3, append = 4, truncate = 8, create = 16, create_only_if_not_exist = 32, create_compressed = 64, will_be_sequentially_accessed = 128, will_be_randomly_accessed = 256, no_sparse = 512, hold_parent_open = (1<<10), unique_directory_handle = (1<<11), no_race_protection = (1<<12), temporary_file = (1<<13), delete_on_close = (1<<14), os_direct = (1<<16), os_lockable = (1<<17), always_sync = (1<<24), sync_on_close = (1<<25), int_hold_parent_open_nested = (1<<27), int_file_share_delete = (1<<28), int_opening_link = (1<<29), int_opening_dir = (1<<30)};
Values

Value

Description

none

No flags set.

read

Read access.

write

Write access.

read_write

Read and write access.

append

Append only.

truncate

Truncate existing file to zero.

create

Open and create if doesn't exist. Always creates sparse files if possible.

create_only_if_not_exist

Create and open only if doesn't exist.

create_compressed

Create a compressed file, needs to be combined with one of the other create flags. Only succeeds if supported by the underlying filing system.

will_be_sequentially_accessed

Will be exclusively either read or written sequentially. If you're exclusively writing sequentially, strongly consider turning on os_direct too.

will_be_randomly_accessed

Will be randomly accessed, so don't bother with read-ahead. If you're using this, strongly consider turning on os_direct too.

no_sparse

Don't create sparse files. May be ignored by some filing systems (e.g. ext4).

hold_parent_open

Hold a file handle open to the containing directory of each open file for fast directory enumeration and fast relative path ops.

unique_directory_handle

Return a unique directory handle rather than a shared directory handle.

no_race_protection

Skip taking steps to avoid destruction of data due to filing system races. Most of the performance benefit of enabling this goes away if you enable HoldParentOpen instead, so be especially careful when considering turning this on.

temporary_file

On some systems causes dirty cache data to not be written to physical storage until file close. Useful for temporary files and lock files, especially on Windows when combined with delete_on_close as this avoids an fsync of the containing directory on file close.

delete_on_close

Only when combined with create_only_if_not_exist, deletes the file on close. This is especially useful on Windows with temporary and lock files where normally closing a file is an implicit fsync of its containing directory. Note on POSIX this unlinks the file on first close by AFIO, whereas on Windows the operating system unlinks the file on last close including sudden application exit. Note also that AFIO permits you to delete files which are currently open on Windows and the file entry disappears immediately just as on POSIX.

os_direct

Bypass the OS file buffers (only really useful for writing large files, or a lot of random reads and writes. Note you must 4Kb align everything if this is on). Be VERY careful mixing this with memory mapped files.

os_lockable

always_sync

Ask the OS to not complete until the data is on the physical storage. Some filing systems do much better with this than sync_on_close.

sync_on_close

Automatically initiate an asynchronous flush just before file close, and fuse both operations so both must complete for close to complete.

int_hold_parent_open_nested

Internal use only. Don't use.

int_file_share_delete

Internal use only. Don't use.

int_opening_link

Internal use only. Don't use.

int_opening_dir

Internal use only. Don't use.

Header

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


PrevUpHomeNext