• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/llvmCore-3425.0.33/lib/Support/

Lines Matching refs:path

24   using llvm::sys::path::is_separator;
34 StringRef find_first_component(StringRef path) {
42 if (path.empty())
43 return path;
47 if (path.size() >= 2 && std::isalpha(path[0]) && path[1] == ':')
48 return path.substr(0, 2);
52 if ((path.size() > 2) &&
53 is_separator(path[0]) &&
54 path[0] == path[1] &&
55 !is_separator(path[2])) {
57 size_t end = path.find_first_of(separators, 2);
58 return path.substr(0, end);
62 if (is_separator(path[0]))
63 return path.substr(0, 1);
65 if (path.startswith(".."))
66 return path.substr(0, 2);
68 if (path[0] == '.')
69 return path.substr(0, 1);
72 size_t end = path.find_first_of(separators, 2);
73 return path.substr(0, end);
129 size_t parent_path_end(StringRef path) {
130 size_t end_pos = filename_pos(path);
132 bool filename_was_sep = path.size() > 0 && is_separator(path[end_pos]);
135 size_t root_dir_pos = root_dir_start(path.substr(0, end_pos));
139 is_separator(path[end_pos - 1]))
151 namespace path {
153 const_iterator begin(StringRef path) {
155 i.Path = path;
156 i.Component = find_first_component(path);
161 const_iterator end(StringRef path) {
163 i.Path = path;
164 i.Position = path.size();
264 const StringRef root_path(StringRef path) {
265 const_iterator b = begin(path),
267 e = end(path);
280 return path.substr(0, b->size() + pos->size());
296 const StringRef root_name(StringRef path) {
297 const_iterator b = begin(path),
298 e = end(path);
314 // No path or no name.
318 const StringRef root_directory(StringRef path) {
319 const_iterator b = begin(path),
321 e = end(path);
343 // No path or no root.
347 const StringRef relative_path(StringRef path) {
348 StringRef root = root_path(path);
349 return path.substr(root.size());
352 void append(SmallVectorImpl<char> &path, const Twine &a,
370 bool path_has_sep = !path.empty() && is_separator(path[path.size() - 1]);
380 path.append(c.begin(), c.end());
384 if (!component_has_sep && !(path.empty() || is_root_name)) {
386 path.push_back(prefered_separator);
389 path.append(i->begin(), i->end());
393 void append(SmallVectorImpl<char> &path,
396 path::append(path, *begin);
399 const StringRef parent_path(StringRef path) {
400 size_t end_pos = parent_path_end(path);
404 return path.substr(0, end_pos);
407 void remove_filename(SmallVectorImpl<char> &path) {
408 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()));
410 path.set_size(end_pos);
413 void replace_extension(SmallVectorImpl<char> &path, const Twine &extension) {
414 StringRef p(path.begin(), path.size());
421 path.set_size(pos);
425 path.push_back('.');
428 path.append(ext.begin(), ext.end());
431 void native(const Twine &path, SmallVectorImpl<char> &result) {
436 StringRef p = path.toStringRef(path_storage);
448 path.toVector(result);
452 const StringRef filename(StringRef path) {
453 return *(--end(path));
456 const StringRef stem(StringRef path) {
457 StringRef fname = filename(path);
469 const StringRef extension(StringRef path) {
470 StringRef fname = filename(path);
522 bool has_root_name(const Twine &path) {
524 StringRef p = path.toStringRef(path_storage);
529 bool has_root_directory(const Twine &path) {
531 StringRef p = path.toStringRef(path_storage);
536 bool has_root_path(const Twine &path) {
538 StringRef p = path.toStringRef(path_storage);
543 bool has_relative_path(const Twine &path) {
545 StringRef p = path.toStringRef(path_storage);
550 bool has_filename(const Twine &path) {
552 StringRef p = path.toStringRef(path_storage);
557 bool has_parent_path(const Twine &path) {
559 StringRef p = path.toStringRef(path_storage);
564 bool has_stem(const Twine &path) {
566 StringRef p = path.toStringRef(path_storage);
571 bool has_extension(const Twine &path) {
573 StringRef p = path.toStringRef(path_storage);
578 bool is_absolute(const Twine &path) {
580 StringRef p = path.toStringRef(path_storage);
592 bool is_relative(const Twine &path) {
593 return !is_absolute(path);
596 } // end namespace path
600 error_code make_absolute(SmallVectorImpl<char> &path) {
601 StringRef p(path.data(), path.size());
603 bool rootDirectory = path::has_root_directory(p),
605 rootName = path::has_root_name(p);
618 // Relative path. Prepend the current directory.
620 // Append path to the current directory.
621 path::append(current_dir, p);
622 // Set path to the result.
623 path.swap(current_dir);
628 StringRef cdrn = path::root_name(current_dir);
630 path::append(curDirRootName, p);
631 // Set path to the result.
632 path.swap(curDirRootName);
637 StringRef pRootName = path::root_name(p);
638 StringRef bRootDirectory = path::root_directory(current_dir);
639 StringRef bRelativePath = path::relative_path(current_dir);
640 StringRef pRelativePath = path::relative_path(p);
643 path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath);
644 path.swap(res);
652 error_code create_directories(const Twine &path, bool &existed) {
654 StringRef p = path.toStringRef(path_storage);
656 StringRef parent = path::parent_path(p);
680 error_code is_directory(const Twine &path, bool &result) {
682 if (error_code ec = status(path, st))
692 error_code is_regular_file(const Twine &path, bool &result) {
694 if (error_code ec = status(path, st))
704 error_code is_symlink(const Twine &path, bool &result) {
706 if (error_code ec = status(path, st))
720 SmallString<128> path(Path.begin(), Path.end());
721 path::remove_filename(path);
722 path::append(path, filename);
723 Path = path.str();
727 error_code has_magic(const Twine &path, const Twine &magic, bool &result) {
732 if (error_code ec = get_magic(path, Magic.size(), Buffer)) {
858 error_code identify_magic(const Twine &path, file_magic &result) {
860 error_code ec = get_magic(path, Magic.capacity(), Magic);
869 error_code remove_all_r(StringRef path, file_type ft, uint32_t &count) {
873 directory_iterator i(path, ec);
879 if (error_code ec = remove_all_r(i->path(), st.type(), count)) return ec;
882 if (error_code ec = remove(path, obviously_this_exists)) return ec;
887 if (error_code ec = remove(path, obviously_this_exists)) return ec;
896 error_code remove_all(const Twine &path, uint32_t &num_removed) {
898 StringRef p = path.toStringRef(path_storage);
901 if (error_code ec = status(path, fs))