30 char a_absolute[_MAX_PATH];
31 char b_absolute[_MAX_PATH];
32 GetFullPathName(a.
AsString().c_str(),
sizeof(a_absolute), a_absolute, NULL);
33 GetFullPathName(b.
AsString().c_str(),
sizeof(b_absolute), b_absolute, NULL);
34 char a_drive[_MAX_DIR];
35 char b_drive[_MAX_DIR];
36 _splitpath(a_absolute, a_drive, NULL, NULL, NULL);
37 _splitpath(b_absolute, b_drive, NULL, NULL, NULL);
38 return _stricmp(a_drive, b_drive) == 0;
45 for (
size_t i = 0; i < list.size(); ++i) {
47 if (i != list.size() - 1)
55 stringstream ss(input);
57 while (getline(ss, item, sep))
58 elems.push_back(item);
64 transform(s.begin(), s.end(), back_inserter(ret), ::tolower);
69 char result[_MAX_PATH];
70 GetFullPathName(s.
AsString().c_str(),
sizeof(result), result, NULL);
78 for (i = 0; i < static_cast<int>(min(start_list.size(), path_list.size()));
84 vector<string> rel_list;
85 for (
int j = 0; j < static_cast<int>(start_list.size() - i); ++j)
86 rel_list.push_back(
"..");
87 for (
int j = i; j < static_cast<int>(path_list.size()); ++j)
88 rel_list.push_back(path_list[j]);
89 if (rel_list.size() == 0)
91 return Join(rel_list,
'\\');
95 const char* relative_to) {
97 size_t len = input.size();
98 strncpy(copy, input.c_str(), input.size() + 1);
99 for (
size_t j = 0; j < len; ++j)
104 Warning(
"couldn't canonicalize '%s: %s\n", input.c_str(), err.c_str());
109 relative_to = curdir.c_str();
112 if (!SameDrive(partially_fixed, relative_to))
114 return Relativize(partially_fixed, relative_to);
static string Relativize(StringPiece path, const string &start)
StringPiece represents a slice of a string whose memory is managed externally.
static string Join(const vector< string > &list, char sep)
string AsString() const
Convert the slice into a full-fledged std::string, copying the data into a new string.
static vector< string > Split(const string &input, char sep)
bool CanonicalizePath(string *path, string *err)
Canonicalize a path like "foo/../bar.h" into just "bar.h".
static string Normalize(const string &input, const char *relative_to)
Normalize by fixing slashes style, fixing redundant .
static string AbsPath(StringPiece s)
static string ToLower(const string &s)
void Warning(const char *msg,...)
Log a warning message.