1#include "symlink.hpp"
2
3#include <unistd.h>
4
5bool Symlink::do_start()
6{
7 if (symlink(target.c_str(), linkfile.c_str()) != 0)
8 {
9 m_error = strerror(errno);
10 return false;
11 }
12 return true;
13}
14
15bool Symlink::do_stop()
16{
17 if (unlink(linkfile.c_str()) != 0)
18 return false;
19 return true;
20}
21
22bool Symlink::do_load(const toml::table &data)
23{
24 const auto link = data["link"], target = data["target"];
25
26 if (!link || !target || !link.is_string() || !target.is_string())
27 return false;
28
29 this->linkfile = link.as_string()->get();
30 this->target = target.as_string()->get();
31 return true;
32}
33