navid/veins / 89aa02ed6b6660b6cf09e1a7700cf3b020a1b1e2bd33fd14dace8eb1a92db071 / xveins/src/pathspec.h

pathspec.h

← xveins/src · 748 bytes · raw · download

#pragma once

#include "common.h"

#include <optional>
#include <string>

namespace vn {

// Current directory relative to the repository root, or nullopt when the
// process is outside the repository.
std::optional<std::string> cwd_relative(const fs::path &root);

// Normalize one command-line operand into a repository-relative path. Relative
// operands are resolved against `cwd_rel`; absolute operands must live inside
// `root`. Glob metacharacters are preserved.
std::optional<std::string> pathspec_normalize(const fs::path &root,
                                              std::string_view cwd_rel,
                                              std::string_view arg);

bool pathspec_has_glob(std::string_view value);

} // namespace vn