7 Portable_File_Buffer::Portable_File_Buffer
10 const char *
const file_name,
14 constexpr auto in = std::ios::binary | std::ios::in;
17 filebuf.open(file_name, in);
19 filebuf.open(file_name, in | std::ios::out);
22 if (filebuf.open(file_name, in))
23 throw Exception(
"File already exists: " + std::string(file_name));
24 filebuf.open(file_name, in | std::ios::out | std::ios::trunc);
33 filebuf.open(file_name, in | std::ios::out) ||
34 filebuf.open(file_name, in | std::ios::out | std::ios::trunc);
37 filebuf.open(file_name, in | std::ios::out | std::ios::trunc);
42 std::string(file_name) +
": unsupported mode for Portable_File"
46 if (!filebuf.is_open())
47 throw Exception(
"Cannot open file: " + std::string(file_name));
@ truncate
create new file, or truncate existing file, and locks the file
@ create_new
fails if already exists, locks the file for writing
@ write_existing
fails if does not exist or locked, locks the file for writing
@ shared_write
like write_existing_or_create_new, but does not lock the file, and does not fail if locked
@ write_existing_or_create_new
either write_existing or create_new depending on whether the file exists. Racy in Posix,...
@ write_lock
like write_existing_or_create_new, but waits instead of failing if already locked
@ read_existing
fails if does not exist