21 return FileSystem::Instance().Exists(path);
28 if (dump_mask & eDumpOptionType)
29 strm.
Printf(
"(%s)", GetTypeAsCString());
30 if (dump_mask & eDumpOptionValue) {
31 if (dump_mask & eDumpOptionType)
32 strm.
Printf(
" =%s", (m_path_mappings.GetSize() > 0) ?
"\n" :
"");
33 m_path_mappings.Dump(&strm);
37 Status OptionValuePathMappings::SetValueFromString(llvm::StringRef value,
40 Args args(value.str());
52 if (argc >= 3 && (((argc - 1) & 1) == 0)) {
54 const uint32_t count = m_path_mappings.GetSize();
56 error.SetErrorStringWithFormat(
57 "invalid file list index %s, index must be 0 through %u",
61 for (
size_t i = 1; i < argc; idx++, i += 2) {
65 if (!m_path_mappings.Replace(orginal_path, replace_path, idx,
67 m_path_mappings.Append(orginal_path, replace_path,
73 error.SetErrorStringWithFormat(
74 "%sthe replacement path doesn't exist: \"%s\"",
75 previousError.c_str(), replace_path);
82 error.SetErrorString(
"replace operation takes an array index followed by "
83 "one or more path pairs");
88 if (argc < 2 || (argc & 1)) {
89 error.SetErrorString(
"assign operation takes one or more path pairs");
92 m_path_mappings.Clear(m_notify_changes);
96 if (argc < 2 || (argc & 1)) {
97 error.SetErrorString(
"append operation takes one or more path pairs");
100 bool changed =
false;
101 for (
size_t i = 0; i < argc; i += 2) {
105 m_path_mappings.Append(orginal_path, replace_path, m_notify_changes);
106 m_value_was_set =
true;
111 error.SetErrorStringWithFormat(
112 "%sthe replacement path doesn't exist: \"%s\"",
113 previousError.c_str(), replace_path);
117 NotifyValueChanged();
125 if (argc >= 3 && (((argc - 1) & 1) == 0)) {
127 const uint32_t count = m_path_mappings.GetSize();
129 error.SetErrorStringWithFormat(
130 "invalid file list index %s, index must be 0 through %u",
133 bool changed =
false;
136 for (
size_t i = 1; i < argc; i += 2) {
140 m_path_mappings.Insert(orginal_path, replace_path, idx,
147 error.SetErrorStringWithFormat(
148 "%sthe replacement path doesn't exist: \"%s\"",
149 previousError.c_str(), replace_path);
153 NotifyValueChanged();
156 error.SetErrorString(
"insert operation takes an array index followed by "
157 "one or more path pairs");
163 std::vector<int> remove_indexes;
164 for (
size_t i = 0; i < argc; ++i) {
167 idx >= (
int)m_path_mappings.GetSize()) {
168 error.SetErrorStringWithFormat(
169 "invalid array index '%s', aborting remove operation",
173 remove_indexes.push_back(idx);
177 llvm::sort(remove_indexes.begin(), remove_indexes.end());
178 for (
auto index : llvm::reverse(remove_indexes))
179 m_path_mappings.Remove(index, m_notify_changes);
180 NotifyValueChanged();
182 error.SetErrorString(
"remove operation takes one or more array index");
187 error = OptionValue::SetValueFromString(value, op);