MayaFlux 0.2.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_bytes()

bool MayaFlux::IO::TextFileWriter::write_bytes ( const void *  data,
size_t  size 
)
overridevirtual

Write raw bytes.

Implements MayaFlux::IO::FileWriter.

Definition at line 96 of file TextFileWriter.cpp.

97{
98 std::lock_guard lock(m_mutex);
99
100 if (!m_is_open || !m_file.is_open()) {
101 m_last_error = "File not open";
102 return false;
103 }
104
105 if (should_rotate()) {
106 if (!rotate_file()) {
107 return false;
108 }
109 }
110
111 m_file.write(static_cast<const char*>(data), size);
112
113 if (!m_file.good()) {
114 m_last_error = "Write failed";
115 return false;
116 }
117
118 m_bytes_written += size;
119
121 m_file.flush();
122 }
123
124 return true;
125}
@ SYNC
Sync after each write (slow but safe)

References m_bytes_written, m_file, m_is_open, m_last_error, m_mutex, m_options, MayaFlux::IO::NONE, rotate_file(), should_rotate(), and MayaFlux::IO::SYNC.

Referenced by write_line(), and write_string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: