7 Portable_File_Buffer::Portable_File_Buffer
10 const char *
const file_name,
14 constexpr auto in = std::ios::binary | std::ios::in;
18 filebuf.open(file_name, in);
22 filebuf.open(file_name, in | std::ios::out);
26 if (filebuf.open(file_name, in))
27 throw Exception(
"File already exists: " + std::string(file_name));
28 filebuf.open(file_name, in | std::ios::out | std::ios::trunc);
32 filebuf.open(file_name, in | std::ios::out) ||
33 filebuf.open(file_name, in | std::ios::out | std::ios::trunc);
39 std::string(file_name) +
": unsupported mode for Portable_File"
43 if (!filebuf.is_open())
44 throw Exception(
"Cannot open file: " + std::string(file_name));
@ 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
@ write_existing_or_create_new
either write_existing or create_new depending on whether the file exists. Racy in Posix,...
@ read_existing
fails if does not exist