/*
  ISC License

  Copyright (c) 2026, Antonio SJ Musumeci <trapexit@spawn.link>

  Permission to use, copy, modify, and/or distribute this software for any
  purpose with or without fee is hereby granted, provided that the above
  copyright notice and this permission notice appear in all copies.

  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/

#pragma once

#include "to_neg_errno.hpp"

#include <string>

#include <unistd.h>


namespace fs
{
  static
  inline
  int
  symlink(const char *target_,
          const char *linkpath_)
  {
    int rv;

    rv = ::symlink(target_,linkpath_);

    return ::to_neg_errno(rv);
  }

  static
  inline
  int
  symlink(const std::string &target_,
          const std::string &linkpath_)
  {
    return fs::symlink(target_.c_str(),
                       linkpath_.c_str());
  }

  static
  inline
  int
  symlink(const char        *target_,
          const std::string &linkpath_)
  {
    return fs::symlink(target_,
                       linkpath_.c_str());
  }
}
