keep-prefix keeps relative pathing (#7394)

This commit is contained in:
Derek Bailey
2022-07-26 15:11:54 -07:00
committed by GitHub
parent 52fce5e532
commit 6e2791640e
7 changed files with 30 additions and 10 deletions

View File

@@ -17,6 +17,7 @@
// clang-format off
// Dont't remove `format off`, it prevent reordering of win-includes.
#include <cstring>
#if defined(__MINGW32__) || defined(__MINGW64__) || defined(__CYGWIN__) || \
defined(__QNXNTO__)
# define _POSIX_C_SOURCE 200809L
@@ -46,8 +47,8 @@
#include <clocale>
#include <cstdlib>
#include <functional>
#include <fstream>
#include <functional>
#include "flatbuffers/base.h"
@@ -155,6 +156,15 @@ std::string StripFileName(const std::string &filepath) {
return i != std::string::npos ? filepath.substr(0, i) : "";
}
std::string StripPrefix(const std::string &filepath,
const std::string &prefix_to_remove) {
if (!strncmp(filepath.c_str(), prefix_to_remove.c_str(),
prefix_to_remove.size())) {
return filepath.substr(prefix_to_remove.size());
}
return filepath;
}
std::string ConCatPathFileName(const std::string &path,
const std::string &filename) {
std::string filepath = path;