PIDUINO
Loading...
Searching...
No Matches
filedevice.h
1/* Copyright © 2018-2025 Pascal JEAN, All rights reserved.
2 * This file is part of the Piduino Library.
3 *
4 * The Piduino Library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 3 of the License, or (at your option) any later version.
8 *
9 * The Piduino Library 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 GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with the Piduino Library; if not, see <http://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <string>
20#include <piduino/iodevice.h>
21
27namespace Piduino {
28
45 class FileDevice : public IoDevice {
46
47 public:
48
53
58
62 FileDevice (const std::string & path);
63
67 virtual ~FileDevice();
68
74 virtual bool open (OpenMode mode = ReadWrite);
75
79 virtual void close();
80
96 virtual void setPath (const std::string & path);
97
104 virtual std::string path() const;
105
106 bool setFd (int fd);
107
113 int fd() const;
114
115 bool isOurFile() const;
116
124 virtual ssize_t write (const char * data, size_t maxSize);
125
135 ssize_t write (const char * str);
136
145 ssize_t write (const std::string & str);
146
160 virtual ssize_t read (char * data, size_t maxSize);
161
162 protected:
163 class Private;
165
166 private:
168 };
169}
174/* ========================================================================== */
Provides an interface for reading from and writing to files.
Definition filedevice.h:45
virtual ssize_t write(const char *data, size_t maxSize)
virtual ssize_t read(char *data, size_t maxSize)
ssize_t write(const std::string &str)
virtual void close()
virtual std::string path() const
virtual bool open(OpenMode mode=ReadWrite)
FileDevice(Private &dd)
FileDevice(const std::string &path)
bool setFd(int fd)
ssize_t write(const char *str)
virtual void setPath(const std::string &path)
bool isOurFile() const
A type-safe flags class for bitwise operations on enum values.
Definition flags.h:34
Abstract base class for input/output devices.
Definition iodevice.h:37
@ ReadWrite
Open the device for both input and output operations.
Definition iodevice.h:60
Internal implementation class for GpioDevice.
#define PIMP_DECLARE_PRIVATE(Class)
PIMP_DECLARE_PRIVATE.
Definition global.h:82
Global namespace for Piduino.
Definition board.h:28