mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-04 04:33:23 +00:00
keep-prefix keeps relative pathing (#7394)
This commit is contained in:
12
src/util.cpp
12
src/util.cpp
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user