void locate_path_root(const wstring& path, size_t& path_root_len, bool& is_unc_path) { unsigned prefix_len = 0; is_unc_path = false; if (substr_match(path, 0, L"\\\\")) { if (substr_match(path, 2, L"?\\UNC\\")) { prefix_len = 8; is_unc_path = true; } else if (substr_match(path, 2, L"?\\") || substr_match(path, 2, L".\\")) { prefix_len = 4; } else { prefix_len = 2; is_unc_path = true; } } if ((prefix_len == 0) && !substr_match(path, 1, L":")) { path_root_len = 0; } else { wstring::size_type p = path.find(L'\\', prefix_len); if (p == wstring::npos) { p = path.size(); } if (is_unc_path) { p = path.find(L'\\', p + 1); if (p == wstring::npos) { p = path.size(); } } path_root_len = p; } }
wstring long_path(const wstring& path) { if (substr_match(path, 0, L"\\\\")) { if (substr_match(path, 2, L"?\\") || substr_match(path, 2, L".\\")) { return path; } else { return wstring(path).replace(0, 1, L"\\\\?\\UNC"); } } else { return wstring(path).insert(0, L"\\\\?\\"); } }
void parse_cmd_line(const deque<wstring>& params, list<wstring>& source_dirs, list<wstring>& include_dirs) { source_dirs.assign(1, wstring()); for (auto param = params.cbegin(); param != params.cend(); ++param) { if (substr_match(*param, 0, L"-I")) { wstring inc_dir = param->substr(2); CHECK_CMD(!inc_dir.empty()); fix_slashes(inc_dir); include_dirs.push_back(inc_dir); } else { wstring src_dir = *param; fix_slashes(src_dir); source_dirs.push_back(src_dir); } } }