Files
revng-revng/include/revng/Support/PathList.h
Alessandro Di Federico 4c0f809626 Introduce PathList::list
2023-05-10 09:17:35 +02:00

36 lines
897 B
C++

#pragma once
//
// This file is distributed under the MIT License. See LICENSE.md for details.
//
#include <optional>
#include <string>
#include <vector>
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Path.h"
std::string getCurrentExecutableFullPath();
std::string getCurrentRoot();
template<typename... T>
requires(std::is_convertible_v<T, llvm::StringRef> && ...)
std::string joinPath(const llvm::StringRef First, const T... Parts) {
llvm::SmallString<128> ResultPath(First);
(llvm::sys::path::append(ResultPath, Parts), ...);
return ResultPath.str().str();
}
class PathList {
public:
PathList(const std::vector<std::string> &Paths) : SearchPaths(Paths) {}
std::optional<std::string> findFile(llvm::StringRef FileName) const;
std::vector<std::string>
list(llvm::StringRef Path, llvm::StringRef Suffix) const;
private:
std::vector<std::string> SearchPaths;
};