#[non_exhaustive]pub enum FileFlag {
Read,
Write,
Create,
CreateNew,
Append,
}Expand description
A file-open mode flag, mirroring duckdb_file_flag.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Read
Open for reading.
Write
Open for writing.
Create
Create the file if it does not exist. Requires Write.
CreateNew
Create the file, failing if it already exists. Requires
Write.
Setting it also sets Create: DuckDB maps it to
FILE_FLAGS_EXCLUSIVE_CREATE, which only means “fail if it exists” in
combination with FILE_FLAGS_FILE_CREATE (O_EXCL without O_CREAT
is ignored by open(2)), and on its own neither created a missing file
nor refused an existing one.
§Windows: an existing file is not refused
DuckDB’s local file system on Windows ignores the exclusive flag: it
opens with OPEN_ALWAYS whenever Create is set
(LocalFileSystem::OpenFile in src/common/local_file_system.cpp,
checked in DuckDB 1.5.5), so an existing file is opened, not
truncated, and no error is returned. A missing file is still created.
Do not rely on CreateNew for mutual exclusion on Windows.
Append
Open in append mode.