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 
28 void 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 }
File::write
virtual FileSystem::Result write(IOBuffer &buffer, Size &size, const Size offset)
Write bytes to the file.
Definition: File.cpp:55
FileSystem.h
String::length
Size length() const
Same as count().
Definition: String.cpp:105
FileSystem::WriteFile
@ WriteFile
Definition: FileSystem.h:40
IOBuffer::bufferedWrite
FileSystem::Result bufferedWrite(const void *buffer, const Size size)
Buffered write bytes to the I/O buffer.
Definition: IOBuffer.cpp:146
Device
Abstract device class interface.
Definition: Device.h:35
FileSystemMessage
FileSystem IPC message.
Definition: FileSystemMessage.h:37
IOBuffer.h
IOBuffer
Abstract Input/Output buffer.
Definition: IOBuffer.h:37
Size
unsigned int Size
Any sane size indicator cannot go negative.
Definition: Types.h:128
DeviceLog::m_device
Device & m_device
Device instance.
Definition: DeviceLog.h:61
DeviceLog.h
String.h
FileSystemMessage::action
FileSystem::Action action
Action to perform.
Definition: FileSystemMessage.h:39
FileSystemMessage::size
Size size
Size of the buffer.
Definition: FileSystemMessage.h:42
DeviceLog::DeviceLog
DeviceLog(Device &device)
Constructor.
Definition: DeviceLog.cpp:23
DeviceLog::write
virtual void write(const char *str)
Write a string to the Device one character at a time.
Definition: DeviceLog.cpp:28