13 #include <ecl/config/ecl.hpp> 14 #if defined(ECL_IS_POSIX) 20 #include "../../include/ecl/devices/ofile_pos.hpp" 21 #include "../../include/ecl/devices/detail/error_handler.hpp" 45 open(file_name,write_mode);
54 if ( fclose(file) != 0 ) {
69 file_descriptor = ::open(name.c_str(), O_WRONLY|O_CREAT, S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
70 if ( file_descriptor == -1 ) {
75 file = fdopen(file_descriptor,
"w");
79 file_descriptor = ::open(name.c_str(),O_WRONLY|O_APPEND|O_CREAT, S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
80 if ( file_descriptor == -1 ) {
85 file = fdopen(file_descriptor,
"a");
99 bool OFile::close() ecl_throw_decl(StandardException) {
102 if ( fclose(file) != 0 ) {
119 ecl_debug_throw(StandardException(LOC,
OpenError, std::string(
"File ") + name + std::string(
" is not open for writing.")));
123 size_t written = fwrite(&c,1,1,file);
124 if ( written <= 0 ) {
137 ecl_debug_throw(StandardException(LOC,
OpenError, std::string(
"File ") + name + std::string(
" is not open for writing.")));
141 size_t written = fwrite(s,n,1,file);
142 if ( written <= 0 ) {
152 bool OFile::flush() ecl_debug_throw_decl(StandardException) {
156 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).