Skip to content

Commit 9bd5f23

Browse files
committed
daemon: open any existing pipes when creating an endpoint
1 parent 27d01d1 commit 9bd5f23

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

daemon/daemon_endpoint.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include "hopper/daemon/daemon.hpp"
2+
#include "hopper/daemon/util.hpp"
3+
#include <filesystem>
24
#include <iostream>
35

46
namespace hopper {
@@ -19,6 +21,22 @@ uint32_t HopperDaemon::create_endpoint(const std::filesystem::path &path) {
1921

2022
std::cout << "CREATE " << *endpoint << std::endl;
2123

24+
// Open anything that may already exist in the endpoint
25+
for (const auto &dir_entry : std::filesystem::directory_iterator{path}) {
26+
const auto &p = dir_entry.path();
27+
28+
PipeType pipe_type = detect_pipe_type(p);
29+
if (pipe_type == PipeType::NONE)
30+
continue;
31+
32+
HopperPipe *pipe =
33+
(pipe_type == PipeType::IN ? endpoint->add_input_pipe(p)
34+
: endpoint->add_output_pipe(p));
35+
36+
if (pipe != nullptr)
37+
add_pipe(pipe);
38+
}
39+
2240
return endpoint_id;
2341
}
2442

0 commit comments

Comments
 (0)