dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
FileSink.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <fstream>
13
14// Project includes
15#include "Sink.hpp"
16#include <dfx-utilities/FileSystem.hpp>
17
18namespace dfx::Pcapng
19{
41class FileSink : public Sink
42{
43public:
55 FileSink(fs::path const & path, bool truncate = true);
56
63 void init(std::vector<uint8_t> initialHeader) override;
64
70 void write(std::vector<uint8_t> data) override;
71
72private:
73 std::ofstream _ofs;
74};
75} // !namespace dfx::Pcapng
FileSink(fs::path const &path, bool truncate=true)
Create a file sink targeting path.
void init(std::vector< uint8_t > initialHeader) override
Initialize the sink by writing the initial PCAPNG header.
void write(std::vector< uint8_t > data) override
Append serialized PCAPNG bytes to the output file.
Sink() noexcept=default
Construct a sink.
Definition Capture.hpp:27