Debian Codegraph @

modules/lsp-runtime-lib/include/lsp-plug.in/io/OutFileStream.h

raw
1 /*
2 * Copyright (C) 2023 Linux Studio Plugins Project <https://lsp-plug.in/>
3 * (C) 2023 Vladimir Sadovnikov <[email protected]>
4 *
5 * This file is part of lsp-runtime-lib
6 * Created on: 13 мар. 2019 г.
7 *
8 * lsp-runtime-lib is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * any later version.
12 *
13 * lsp-runtime-lib is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22 #ifndef LSP_PLUG_IN_IO_OUTFILESTREAM_H_
23 #define LSP_PLUG_IN_IO_OUTFILESTREAM_H_
24
25 #include <lsp-plug.in/runtime/version.h>
26 #include <lsp-plug.in/runtime/LSPString.h>
27 #include <lsp-plug.in/io/Path.h>
28 #include <lsp-plug.in/io/File.h>
29 #include <lsp-plug.in/io/IOutStream.h>
30 #include <lsp-plug.in/stdlib/stdio.h>
31
32 namespace lsp
33 {
34 namespace io
35 {
36 class OutFileStream: public IOutStream
37 {
38 private:
39 File *pFD;
40 size_t nWrapFlags;
41
42 public:
43 explicit OutFileStream();
44 OutFileStream(const OutFileStream &) = delete;
45 OutFileStream(OutFileStream &&) = delete;
46 virtual ~OutFileStream() override;
47
48 OutFileStream & operator = (const OutFileStream &) = delete;
49 OutFileStream & operator = (OutFileStream &&) = delete;
50
51 public:
52 status_t wrap(FILE *fd, bool close);
53 status_t wrap_native(fhandle_t fd, bool close);
54 status_t wrap(File *fd, size_t flags);
55
56 status_t open(const char *path, size_t mode);
57 status_t open(const LSPString *path, size_t mode);
58 status_t open(const Path *path, size_t mode);
59
60 status_t open_temp(io::Path *path, const char *prefix = NULL);
61 status_t open_temp(io::Path *path, const LSPString *prefix);
62 status_t open_temp(LSPString *path, const char *prefix = NULL);
63 status_t open_temp(LSPString *path, const LSPString *prefix);
64
65 public:
66 virtual wssize_t position() override;
67 virtual ssize_t write(const void *buf, size_t count) override;
68 virtual wssize_t seek(wsize_t position) override;
69 virtual status_t flush() override;
70 virtual status_t close() override;
71 };
72
73 } /* namespace io */
74 } /* namespace lsp */
75
76 #endif /* LSP_PLUG_IN_IO_OUTFILESTREAM_H_ */