13 #include <ecl/config/ecl.hpp> 14 #if defined(ECL_IS_WIN32) 20 #include "../../include/ecl/devices/ofile_w32.hpp" 21 #include "../../include/ecl/devices/detail/error_handler.hpp" 46 open(file_name,write_mode);
55 if ( fclose(file) != 0 ) {
70 if (_sopen_s(&file_descriptor, name.c_str(), _O_WRONLY | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE)) {
75 file = _fdopen(file_descriptor,
"w");
79 if (_sopen_s(&file_descriptor, name.c_str(), _O_WRONLY | _O_APPEND | _O_CREAT, _SH_DENYNO, _S_IREAD | _S_IWRITE)) {
84 file = _fdopen(file_descriptor,
"a");
98 bool OFile::close() ecl_throw_decl(StandardException) {
101 if ( fclose(file) != 0 ) {
118 ecl_debug_throw(StandardException(LOC,
OpenError, std::string(
"File ") + name + std::string(
" is not open for writing.")));
122 size_t written = fwrite(&c,1,1,file);
123 if ( written <= 0 ) {
136 ecl_debug_throw(StandardException(LOC,
OpenError, std::string(
"File ") + name + std::string(
" is not open for writing.")));
140 size_t written = fwrite(s,n,1,file);
141 if ( written <= 0 ) {
151 bool OFile::flush() ecl_debug_throw_decl(StandardException) {
155 int result = fflush(file);
Embedded control libraries.
WriteMode
Write mode for devices.
#define ecl_throw(exception)
#define ecl_throw_decl(exception)
StandardException open_exception(const char *loc, const std::string &file_name)
StandardException close_exception(const char *loc, const std::string &file_name)
#define ecl_debug_throw_decl(exception)
#define ecl_debug_throw(exception)
#define ecl_catch(exception)
Opens a new object (deletes existing objects).
Appends to an existing object (opens if not existing).