FreeNOS
DeviceLog.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Niek Linnenbank
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include <String.h>
19#include "IOBuffer.h"
20#include "FileSystem.h"
21#include "DeviceLog.h"
22
24 : m_device(device)
25{
26}
27
28void DeviceLog::write(const char *str)
29{
30 Size len = String::length(str);
31
34 msg.size = len;
35
36 IOBuffer buffer(&msg);
37 buffer.bufferedWrite(str, len);
38 m_device.write(buffer, len, 0);
39}
Device & m_device
Device instance.
Definition DeviceLog.h:61
DeviceLog(Device &device)
Constructor.
Definition DeviceLog.cpp:23
virtual void write(const char *str)
Write a string to the Device one character at a time.
Definition DeviceLog.cpp:28
Abstract device class interface.
Definition Device.h:36
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the file.
Definition File.cpp:55
Abstract Input/Output buffer.
Definition IOBuffer.h:38
FileSystem::Result bufferedWrite(const void *buffer, const Size size)
Buffered write bytes to the I/O buffer.
Definition IOBuffer.cpp:146
Size length() const
Same as count().
Definition String.cpp:105
unsigned int Size
Any sane size indicator cannot go negative.
Definition Types.h:128
FileSystem IPC message.
FileSystem::Action action
Action to perform.
Size size
Size of the buffer.