Lines Matching refs:style
39 inline Style real_style(Style style) { in real_style() argument
41 return (style == Style::posix) ? Style::posix : Style::windows; in real_style()
43 return (style == Style::windows) ? Style::windows : Style::posix; in real_style()
47 inline const char *separators(Style style) { in separators() argument
48 if (real_style(style) == Style::windows) in separators()
53 inline char preferred_separator(Style style) { in preferred_separator() argument
54 if (real_style(style) == Style::windows) in preferred_separator()
59 StringRef find_first_component(StringRef path, Style style) { in find_first_component() argument
69 if (real_style(style) == Style::windows) { in find_first_component()
77 if ((path.size() > 2) && is_separator(path[0], style) && in find_first_component()
78 path[0] == path[1] && !is_separator(path[2], style)) { in find_first_component()
80 size_t end = path.find_first_of(separators(style), 2); in find_first_component()
85 if (is_separator(path[0], style)) in find_first_component()
89 size_t end = path.find_first_of(separators(style)); in find_first_component()
95 size_t filename_pos(StringRef str, Style style) { in filename_pos() argument
96 if (str.size() > 0 && is_separator(str[str.size() - 1], style)) in filename_pos()
99 size_t pos = str.find_last_of(separators(style), str.size() - 1); in filename_pos()
101 if (real_style(style) == Style::windows) { in filename_pos()
106 if (pos == StringRef::npos || (pos == 1 && is_separator(str[0], style))) in filename_pos()
114 size_t root_dir_start(StringRef str, Style style) { in root_dir_start() argument
116 if (real_style(style) == Style::windows) { in root_dir_start()
117 if (str.size() > 2 && str[1] == ':' && is_separator(str[2], style)) in root_dir_start()
122 if (str.size() > 3 && is_separator(str[0], style) && str[0] == str[1] && in root_dir_start()
123 !is_separator(str[2], style)) { in root_dir_start()
124 return str.find_first_of(separators(style), 2); in root_dir_start()
128 if (str.size() > 0 && is_separator(str[0], style)) in root_dir_start()
137 size_t parent_path_end(StringRef path, Style style) { in parent_path_end() argument
138 size_t end_pos = filename_pos(path, style); in parent_path_end()
141 path.size() > 0 && is_separator(path[end_pos], style); in parent_path_end()
144 size_t root_dir_pos = root_dir_start(path, style); in parent_path_end()
147 is_separator(path[end_pos - 1], style)) in parent_path_end()
224 const_iterator begin(StringRef path, Style style) { in begin() argument
227 i.Component = find_first_component(path, style); in begin()
229 i.S = style; in begin()
295 reverse_iterator rbegin(StringRef Path, Style style) { in rbegin() argument
299 I.S = style; in rbegin()
346 StringRef root_path(StringRef path, Style style) { in root_path() argument
347 const_iterator b = begin(path, style), pos = b, e = end(path); in root_path()
350 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0]; in root_path()
351 bool has_drive = (real_style(style) == Style::windows) && b->endswith(":"); in root_path()
354 if ((++pos != e) && is_separator((*pos)[0], style)) { in root_path()
364 if (is_separator((*b)[0], style)) { in root_path()
372 StringRef root_name(StringRef path, Style style) { in root_name() argument
373 const_iterator b = begin(path, style), e = end(path); in root_name()
376 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0]; in root_name()
377 bool has_drive = (real_style(style) == Style::windows) && b->endswith(":"); in root_name()
389 StringRef root_directory(StringRef path, Style style) { in root_directory() argument
390 const_iterator b = begin(path, style), pos = b, e = end(path); in root_directory()
393 b->size() > 2 && is_separator((*b)[0], style) && (*b)[1] == (*b)[0]; in root_directory()
394 bool has_drive = (real_style(style) == Style::windows) && b->endswith(":"); in root_directory()
398 (++pos != e) && is_separator((*pos)[0], style)) { in root_directory()
403 if (!has_net && is_separator((*b)[0], style)) { in root_directory()
412 StringRef relative_path(StringRef path, Style style) { in relative_path() argument
413 StringRef root = root_path(path, style); in relative_path()
417 void append(SmallVectorImpl<char> &path, Style style, const Twine &a, in append() argument
432 !path.empty() && is_separator(path[path.size() - 1], style); in append()
435 size_t loc = component.find_first_not_of(separators(style)); in append()
444 !component.empty() && is_separator(component[0], style); in append()
446 !(path.empty() || has_root_name(component, style))) { in append()
448 path.push_back(preferred_separator(style)); in append()
461 const_iterator end, Style style) { in append() argument
463 path::append(path, style, *begin); in append()
466 StringRef parent_path(StringRef path, Style style) { in parent_path() argument
467 size_t end_pos = parent_path_end(path, style); in parent_path()
474 void remove_filename(SmallVectorImpl<char> &path, Style style) { in remove_filename() argument
475 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()), style); in remove_filename()
481 Style style) { in replace_extension() argument
488 if (pos != StringRef::npos && pos >= filename_pos(p, style)) in replace_extension()
501 Style style, bool strict) { in replace_path_prefix() argument
513 OldPrefixDir = parent_path(OldPrefix, style); in replace_path_prefix()
521 if (!is_separator(OrigPath[OldPrefixDir.size()], style) && strict) in replace_path_prefix()
532 path::append(NewPath, style, NewPrefix); in replace_path_prefix()
534 if (!is_separator(RelPath[0], style) || !strict) in replace_path_prefix()
535 path::append(NewPath, style, RelPath); in replace_path_prefix()
537 path::append(NewPath, style, relative_path(RelPath, style)); in replace_path_prefix()
545 void native(const Twine &path, SmallVectorImpl<char> &result, Style style) { in native() argument
552 native(result, style); in native()
555 void native(SmallVectorImpl<char> &Path, Style style) { in native() argument
558 if (real_style(style) == Style::windows) { in native()
560 if (Path[0] == '~' && (Path.size() == 1 || is_separator(Path[1], style))) { in native()
579 std::string convert_to_slash(StringRef path, Style style) { in convert_to_slash() argument
580 if (real_style(style) != Style::windows) in convert_to_slash()
588 StringRef filename(StringRef path, Style style) { return *rbegin(path, style); } in filename() argument
590 StringRef stem(StringRef path, Style style) { in stem() argument
591 StringRef fname = filename(path, style); in stem()
603 StringRef extension(StringRef path, Style style) { in extension() argument
604 StringRef fname = filename(path, style); in extension()
616 bool is_separator(char value, Style style) { in is_separator() argument
619 if (real_style(style) == Style::windows) in is_separator()
624 StringRef get_separator(Style style) { in get_separator() argument
625 if (real_style(style) == Style::windows) in get_separator()
630 bool has_root_name(const Twine &path, Style style) { in has_root_name() argument
634 return !root_name(p, style).empty(); in has_root_name()
637 bool has_root_directory(const Twine &path, Style style) { in has_root_directory() argument
641 return !root_directory(p, style).empty(); in has_root_directory()
644 bool has_root_path(const Twine &path, Style style) { in has_root_path() argument
648 return !root_path(p, style).empty(); in has_root_path()
651 bool has_relative_path(const Twine &path, Style style) { in has_relative_path() argument
655 return !relative_path(p, style).empty(); in has_relative_path()
658 bool has_filename(const Twine &path, Style style) { in has_filename() argument
662 return !filename(p, style).empty(); in has_filename()
665 bool has_parent_path(const Twine &path, Style style) { in has_parent_path() argument
669 return !parent_path(p, style).empty(); in has_parent_path()
672 bool has_stem(const Twine &path, Style style) { in has_stem() argument
676 return !stem(p, style).empty(); in has_stem()
679 bool has_extension(const Twine &path, Style style) { in has_extension() argument
683 return !extension(p, style).empty(); in has_extension()
686 bool is_absolute(const Twine &path, Style style) { in is_absolute() argument
690 bool rootDir = has_root_directory(p, style); in is_absolute()
692 (real_style(style) != Style::windows) || has_root_name(p, style); in is_absolute()
697 bool is_relative(const Twine &path, Style style) { in is_relative() argument
698 return !is_absolute(path, style); in is_relative()
701 StringRef remove_leading_dotslash(StringRef Path, Style style) { in remove_leading_dotslash() argument
703 while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1], style)) { in remove_leading_dotslash()
705 while (Path.size() > 0 && is_separator(Path[0], style)) in remove_leading_dotslash()
712 Style style) { in remove_dots() argument
716 StringRef rel = path::relative_path(path, style); in remove_dots()
718 llvm::make_range(path::begin(rel, style), path::end(rel))) { in remove_dots()
727 if (path::is_absolute(path, style)) in remove_dots()
733 SmallString<256> buffer = path::root_path(path, style); in remove_dots()
735 path::append(buffer, style, C); in remove_dots()
740 Style style) { in remove_dots() argument
743 SmallString<256> result = remove_dots(p, remove_dot_dot, style); in remove_dots()