OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/nix/mime_util_xdg.h" | 5 #include "base/nix/mime_util_xdg.h" |
6 | 6 |
7 #include <cstdlib> | 7 #include <cstdlib> |
8 #include <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 if (!fp) | 260 if (!fp) |
261 return false; | 261 return false; |
262 | 262 |
263 // Read entries. | 263 // Read entries. |
264 while (!feof(fp) && !ferror(fp)) { | 264 while (!feof(fp) && !ferror(fp)) { |
265 std::string buf = ReadLine(fp); | 265 std::string buf = ReadLine(fp); |
266 if (buf == "") | 266 if (buf == "") |
267 break; | 267 break; |
268 | 268 |
269 std::string entry; | 269 std::string entry; |
270 TrimWhitespaceASCII(buf, TRIM_ALL, &entry); | 270 base::TrimWhitespaceASCII(buf, base::TRIM_ALL, &entry); |
271 if (entry.length() == 0 || entry[0] == '#') { | 271 if (entry.length() == 0 || entry[0] == '#') { |
272 // Blank line or Comment. | 272 // Blank line or Comment. |
273 continue; | 273 continue; |
274 } else if (entry[0] == '[' && info_array_.get()) { | 274 } else if (entry[0] == '[' && info_array_.get()) { |
275 current_info = NULL; | 275 current_info = NULL; |
276 std::string subdir = entry.substr(1, entry.length() - 2); | 276 std::string subdir = entry.substr(1, entry.length() - 2); |
277 if (subdirs_.find(subdir) != subdirs_.end()) | 277 if (subdirs_.find(subdir) != subdirs_.end()) |
278 current_info = &info_array_[subdirs_[subdir]]; | 278 current_info = &info_array_[subdirs_[subdir]]; |
279 } | 279 } |
280 | 280 |
281 std::string key, value; | 281 std::string key, value; |
282 std::vector<std::string> r; | 282 std::vector<std::string> r; |
283 SplitStringDontTrim(entry, '=', &r); | 283 SplitStringDontTrim(entry, '=', &r); |
284 if (r.size() < 2) | 284 if (r.size() < 2) |
285 continue; | 285 continue; |
286 | 286 |
287 TrimWhitespaceASCII(r[0], TRIM_ALL, &key); | 287 base::TrimWhitespaceASCII(r[0], base::TRIM_ALL, &key); |
288 for (size_t i = 1; i < r.size(); i++) | 288 for (size_t i = 1; i < r.size(); i++) |
289 value.append(r[i]); | 289 value.append(r[i]); |
290 TrimWhitespaceASCII(value, TRIM_ALL, &value); | 290 base::TrimWhitespaceASCII(value, base::TRIM_ALL, &value); |
291 | 291 |
292 if (current_info) { | 292 if (current_info) { |
293 if (key == "Size") { | 293 if (key == "Size") { |
294 current_info->size = atoi(value.c_str()); | 294 current_info->size = atoi(value.c_str()); |
295 } else if (key == "Type") { | 295 } else if (key == "Type") { |
296 if (value == "Fixed") | 296 if (value == "Fixed") |
297 current_info->type = SubDirInfo::Fixed; | 297 current_info->type = SubDirInfo::Fixed; |
298 else if (value == "Scalable") | 298 else if (value == "Scalable") |
299 current_info->type = SubDirInfo::Scalable; | 299 current_info->type = SubDirInfo::Scalable; |
300 else if (value == "Threshold") | 300 else if (value == "Threshold") |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 } | 359 } |
360 | 360 |
361 return result; | 361 return result; |
362 } | 362 } |
363 | 363 |
364 bool IconTheme::SetDirectories(const std::string& dirs) { | 364 bool IconTheme::SetDirectories(const std::string& dirs) { |
365 int num = 0; | 365 int num = 0; |
366 std::string::size_type pos = 0, epos; | 366 std::string::size_type pos = 0, epos; |
367 std::string dir; | 367 std::string dir; |
368 while ((epos = dirs.find(',', pos)) != std::string::npos) { | 368 while ((epos = dirs.find(',', pos)) != std::string::npos) { |
369 TrimWhitespaceASCII(dirs.substr(pos, epos - pos), TRIM_ALL, &dir); | 369 base::TrimWhitespaceASCII(dirs.substr(pos, epos - pos), base::TRIM_ALL, |
| 370 &dir); |
370 if (dir.length() == 0) { | 371 if (dir.length() == 0) { |
371 DLOG(WARNING) << "Invalid index.theme: blank subdir"; | 372 DLOG(WARNING) << "Invalid index.theme: blank subdir"; |
372 return false; | 373 return false; |
373 } | 374 } |
374 subdirs_[dir] = num++; | 375 subdirs_[dir] = num++; |
375 pos = epos + 1; | 376 pos = epos + 1; |
376 } | 377 } |
377 TrimWhitespaceASCII(dirs.substr(pos), TRIM_ALL, &dir); | 378 base::TrimWhitespaceASCII(dirs.substr(pos), base::TRIM_ALL, &dir); |
378 if (dir.length() == 0) { | 379 if (dir.length() == 0) { |
379 DLOG(WARNING) << "Invalid index.theme: blank subdir"; | 380 DLOG(WARNING) << "Invalid index.theme: blank subdir"; |
380 return false; | 381 return false; |
381 } | 382 } |
382 subdirs_[dir] = num++; | 383 subdirs_[dir] = num++; |
383 info_array_.reset(new SubDirInfo[num]); | 384 info_array_.reset(new SubDirInfo[num]); |
384 return true; | 385 return true; |
385 } | 386 } |
386 | 387 |
387 bool CheckDirExistsAndGetMtime(const FilePath& dir, Time* last_modified) { | 388 bool CheckDirExistsAndGetMtime(const FilePath& dir, Time* last_modified) { |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
644 icon_file = LookupIconInDefaultTheme(icon_names[i], size); | 645 icon_file = LookupIconInDefaultTheme(icon_names[i], size); |
645 if (!icon_file.empty()) | 646 if (!icon_file.empty()) |
646 return icon_file; | 647 return icon_file; |
647 } | 648 } |
648 } | 649 } |
649 return FilePath(); | 650 return FilePath(); |
650 } | 651 } |
651 | 652 |
652 } // namespace nix | 653 } // namespace nix |
653 } // namespace base | 654 } // namespace base |
OLD | NEW |