Lines Matching refs:path
23 using llvm::sys::path::is_separator;
35 StringRef find_first_component(StringRef path) { in find_first_component() argument
43 if (path.empty()) in find_first_component()
44 return path; in find_first_component()
48 if (path.size() >= 2 && std::isalpha(path[0]) && path[1] == ':') in find_first_component()
49 return path.substr(0, 2); in find_first_component()
53 if ((path.size() > 2) && in find_first_component()
54 is_separator(path[0]) && in find_first_component()
55 path[0] == path[1] && in find_first_component()
56 !is_separator(path[2])) { in find_first_component()
58 size_t end = path.find_first_of(separators, 2); in find_first_component()
59 return path.substr(0, end); in find_first_component()
63 if (is_separator(path[0])) in find_first_component()
64 return path.substr(0, 1); in find_first_component()
66 if (path.startswith("..")) in find_first_component()
67 return path.substr(0, 2); in find_first_component()
69 if (path[0] == '.') in find_first_component()
70 return path.substr(0, 1); in find_first_component()
73 size_t end = path.find_first_of(separators, 2); in find_first_component()
74 return path.substr(0, end); in find_first_component()
130 size_t parent_path_end(StringRef path) { in parent_path_end() argument
131 size_t end_pos = filename_pos(path); in parent_path_end()
133 bool filename_was_sep = path.size() > 0 && is_separator(path[end_pos]); in parent_path_end()
136 size_t root_dir_pos = root_dir_start(path.substr(0, end_pos)); in parent_path_end()
140 is_separator(path[end_pos - 1])) in parent_path_end()
152 namespace path { namespace
154 const_iterator begin(StringRef path) { in begin() argument
156 i.Path = path; in begin()
157 i.Component = find_first_component(path); in begin()
162 const_iterator end(StringRef path) { in end() argument
164 i.Path = path; in end()
165 i.Position = path.size(); in end()
265 const StringRef root_path(StringRef path) { in root_path() argument
266 const_iterator b = begin(path), in root_path()
268 e = end(path); in root_path()
281 return path.substr(0, b->size() + pos->size()); in root_path()
297 const StringRef root_name(StringRef path) { in root_name() argument
298 const_iterator b = begin(path), in root_name()
299 e = end(path); in root_name()
319 const StringRef root_directory(StringRef path) { in root_directory() argument
320 const_iterator b = begin(path), in root_directory()
322 e = end(path); in root_directory()
348 const StringRef relative_path(StringRef path) { in relative_path() argument
349 StringRef root = root_path(path); in relative_path()
353 void append(SmallVectorImpl<char> &path, const Twine &a, in append() argument
371 bool path_has_sep = !path.empty() && is_separator(path[path.size() - 1]); in append()
381 path.append(c.begin(), c.end()); in append()
385 if (!component_has_sep && !(path.empty() || is_root_name)) { in append()
387 path.push_back(prefered_separator); in append()
390 path.append(i->begin(), i->end()); in append()
394 void append(SmallVectorImpl<char> &path, in append() argument
397 path::append(path, *begin); in append()
400 const StringRef parent_path(StringRef path) { in parent_path() argument
401 size_t end_pos = parent_path_end(path); in parent_path()
405 return path.substr(0, end_pos); in parent_path()
408 void remove_filename(SmallVectorImpl<char> &path) { in remove_filename() argument
409 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size())); in remove_filename()
411 path.set_size(end_pos); in remove_filename()
414 void replace_extension(SmallVectorImpl<char> &path, const Twine &extension) { in replace_extension() argument
415 StringRef p(path.begin(), path.size()); in replace_extension()
422 path.set_size(pos); in replace_extension()
426 path.push_back('.'); in replace_extension()
429 path.append(ext.begin(), ext.end()); in replace_extension()
432 void native(const Twine &path, SmallVectorImpl<char> &result) { in native() argument
437 StringRef p = path.toStringRef(path_storage); in native()
449 path.toVector(result); in native()
453 const StringRef filename(StringRef path) { in filename() argument
454 return *(--end(path)); in filename()
457 const StringRef stem(StringRef path) { in stem() argument
458 StringRef fname = filename(path); in stem()
470 const StringRef extension(StringRef path) { in extension() argument
471 StringRef fname = filename(path); in extension()
493 bool has_root_name(const Twine &path) { in has_root_name() argument
495 StringRef p = path.toStringRef(path_storage); in has_root_name()
500 bool has_root_directory(const Twine &path) { in has_root_directory() argument
502 StringRef p = path.toStringRef(path_storage); in has_root_directory()
507 bool has_root_path(const Twine &path) { in has_root_path() argument
509 StringRef p = path.toStringRef(path_storage); in has_root_path()
514 bool has_relative_path(const Twine &path) { in has_relative_path() argument
516 StringRef p = path.toStringRef(path_storage); in has_relative_path()
521 bool has_filename(const Twine &path) { in has_filename() argument
523 StringRef p = path.toStringRef(path_storage); in has_filename()
528 bool has_parent_path(const Twine &path) { in has_parent_path() argument
530 StringRef p = path.toStringRef(path_storage); in has_parent_path()
535 bool has_stem(const Twine &path) { in has_stem() argument
537 StringRef p = path.toStringRef(path_storage); in has_stem()
542 bool has_extension(const Twine &path) { in has_extension() argument
544 StringRef p = path.toStringRef(path_storage); in has_extension()
549 bool is_absolute(const Twine &path) { in is_absolute() argument
551 StringRef p = path.toStringRef(path_storage); in is_absolute()
563 bool is_relative(const Twine &path) { in is_relative() argument
564 return !is_absolute(path); in is_relative()
571 error_code make_absolute(SmallVectorImpl<char> &path) { in make_absolute() argument
572 StringRef p(path.data(), path.size()); in make_absolute()
574 bool rootName = path::has_root_name(p), in make_absolute()
575 rootDirectory = path::has_root_directory(p); in make_absolute()
588 path::append(current_dir, p); in make_absolute()
590 path.swap(current_dir); in make_absolute()
595 StringRef cdrn = path::root_name(current_dir); in make_absolute()
597 path::append(curDirRootName, p); in make_absolute()
599 path.swap(curDirRootName); in make_absolute()
604 StringRef pRootName = path::root_name(p); in make_absolute()
605 StringRef bRootDirectory = path::root_directory(current_dir); in make_absolute()
606 StringRef bRelativePath = path::relative_path(current_dir); in make_absolute()
607 StringRef pRelativePath = path::relative_path(p); in make_absolute()
610 path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath); in make_absolute()
611 path.swap(res); in make_absolute()
619 error_code create_directories(const Twine &path, bool &existed) { in create_directories() argument
621 StringRef p = path.toStringRef(path_storage); in create_directories()
623 StringRef parent = path::parent_path(p); in create_directories()
646 error_code is_directory(const Twine &path, bool &result) { in is_directory() argument
648 if (error_code ec = status(path, st)) in is_directory()
658 error_code is_regular_file(const Twine &path, bool &result) { in is_regular_file() argument
660 if (error_code ec = status(path, st)) in is_regular_file()
670 error_code is_symlink(const Twine &path, bool &result) { in is_symlink() argument
672 if (error_code ec = status(path, st)) in is_symlink()
687 SmallString<128> path(Path.begin(), Path.end()); in replace_filename() local
688 path::remove_filename(path); in replace_filename()
689 path::append(path, filename); in replace_filename()
690 Path = path.str(); in replace_filename()
695 error_code has_magic(const Twine &path, const Twine &magic, bool &result) { in has_magic() argument
700 if (error_code ec = get_magic(path, Magic.size(), Buffer)) { in has_magic()
713 error_code identify_magic(const Twine &path, LLVMFileType &result) { in identify_magic() argument
715 error_code ec = get_magic(path, Magic.capacity(), Magic); in identify_magic()
724 error_code remove_all_r(StringRef path, file_type ft, uint32_t &count) { in remove_all_r() argument
728 for (directory_iterator i(path, ec), e; i != e; i.increment(ec)) { in remove_all_r()
732 if (error_code ec = remove_all_r(i->path(), st.type(), count)) return ec; in remove_all_r()
735 if (error_code ec = remove(path, obviously_this_exists)) return ec; in remove_all_r()
740 if (error_code ec = remove(path, obviously_this_exists)) return ec; in remove_all_r()
749 error_code remove_all(const Twine &path, uint32_t &num_removed) { in remove_all() argument
751 StringRef p = path.toStringRef(path_storage); in remove_all()
754 if (error_code ec = status(path, fs)) in remove_all()