Lines Matching defs:path

35   using llvm::sys::path::is_separator;
45 StringRef find_first_component(StringRef path) {
52 if (path.empty())
53 return path;
57 if (path.size() >= 2 && std::isalpha(static_cast<unsigned char>(path[0])) &&
58 path[1] == ':')
59 return path.substr(0, 2);
63 if ((path.size() > 2) &&
64 is_separator(path[0]) &&
65 path[0] == path[1] &&
66 !is_separator(path[2])) {
68 size_t end = path.find_first_of(separators, 2);
69 return path.substr(0, end);
73 if (is_separator(path[0]))
74 return path.substr(0, 1);
77 size_t end = path.find_first_of(separators);
78 return path.substr(0, end);
134 size_t parent_path_end(StringRef path) {
135 size_t end_pos = filename_pos(path);
137 bool filename_was_sep = path.size() > 0 && is_separator(path[end_pos]);
140 size_t root_dir_pos = root_dir_start(path.substr(0, end_pos));
144 is_separator(path[end_pos - 1]))
169 if (!sys::path::is_absolute(Twine(ModelStorage))) {
171 sys::path::system_temp_directory(true, TDir);
172 sys::path::append(TDir, Twine(ModelStorage));
178 // path already exists.
230 namespace path {
232 const_iterator begin(StringRef path) {
234 i.Path = path;
235 i.Component = find_first_component(path);
240 const_iterator end(StringRef path) {
242 i.Path = path;
243 i.Position = path.size();
325 // we are the root path.
355 StringRef root_path(StringRef path) {
356 const_iterator b = begin(path),
358 e = end(path);
371 return path.substr(0, b->size() + pos->size());
387 StringRef root_name(StringRef path) {
388 const_iterator b = begin(path),
389 e = end(path);
405 // No path or no name.
409 StringRef root_directory(StringRef path) {
410 const_iterator b = begin(path),
412 e = end(path);
434 // No path or no root.
438 StringRef relative_path(StringRef path) {
439 StringRef root = root_path(path);
440 return path.substr(root.size());
443 void append(SmallVectorImpl<char> &path, const Twine &a,
459 bool path_has_sep = !path.empty() && is_separator(path[path.size() - 1]);
469 path.append(c.begin(), c.end());
473 if (!component_has_sep && !(path.empty() || is_root_name)) {
475 path.push_back(preferred_separator);
478 path.append(component.begin(), component.end());
482 void append(SmallVectorImpl<char> &path,
485 path::append(path, *begin);
488 StringRef parent_path(StringRef path) {
489 size_t end_pos = parent_path_end(path);
493 return path.substr(0, end_pos);
496 void remove_filename(SmallVectorImpl<char> &path) {
497 size_t end_pos = parent_path_end(StringRef(path.begin(), path.size()));
499 path.set_size(end_pos);
502 void replace_extension(SmallVectorImpl<char> &path, const Twine &extension) {
503 StringRef p(path.begin(), path.size());
510 path.set_size(pos);
514 path.push_back('.');
517 path.append(ext.begin(), ext.end());
520 void native(const Twine &path, SmallVectorImpl<char> &result) {
521 assert((!path.isSingleStringRef() ||
522 path.getSingleStringRef().data() != result.data()) &&
523 "path and result are not allowed to overlap!");
526 path.toVector(result);
546 StringRef filename(StringRef path) {
547 return *rbegin(path);
550 StringRef stem(StringRef path) {
551 StringRef fname = filename(path);
563 StringRef extension(StringRef path) {
564 StringRef fname = filename(path);
592 bool has_root_name(const Twine &path) {
594 StringRef p = path.toStringRef(path_storage);
599 bool has_root_directory(const Twine &path) {
601 StringRef p = path.toStringRef(path_storage);
606 bool has_root_path(const Twine &path) {
608 StringRef p = path.toStringRef(path_storage);
613 bool has_relative_path(const Twine &path) {
615 StringRef p = path.toStringRef(path_storage);
620 bool has_filename(const Twine &path) {
622 StringRef p = path.toStringRef(path_storage);
627 bool has_parent_path(const Twine &path) {
629 StringRef p = path.toStringRef(path_storage);
634 bool has_stem(const Twine &path) {
636 StringRef p = path.toStringRef(path_storage);
641 bool has_extension(const Twine &path) {
643 StringRef p = path.toStringRef(path_storage);
648 bool is_absolute(const Twine &path) {
650 StringRef p = path.toStringRef(path_storage);
662 bool is_relative(const Twine &path) { return !is_absolute(path); }
674 static SmallString<256> remove_dots(StringRef path, bool remove_dot_dot) {
677 // Skip the root path, then look for traversal in the components.
678 StringRef rel = path::relative_path(path);
679 for (StringRef C : llvm::make_range(path::begin(rel), path::end(rel))) {
692 SmallString<256> buffer = path::root_path(path);
694 path::append(buffer, C);
698 bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot) {
699 StringRef p(path.data(), path.size());
702 if (result == path)
705 path.swap(result);
709 } // end namespace path
777 SmallVectorImpl<char> &path,
779 StringRef p(path.data(), path.size());
781 bool rootDirectory = path::has_root_directory(p),
783 rootName = path::has_root_name(p);
799 // Relative path. Prepend the current directory.
801 // Append path to the current directory.
802 path::append(current_dir, p);
803 // Set path to the result.
804 path.swap(current_dir);
809 StringRef cdrn = path::root_name(current_dir);
811 path::append(curDirRootName, p);
812 // Set path to the result.
813 path.swap(curDirRootName);
818 StringRef pRootName = path::root_name(p);
819 StringRef bRootDirectory = path::root_directory(current_dir);
820 StringRef bRelativePath = path::relative_path(current_dir);
821 StringRef pRelativePath = path::relative_path(p);
824 path::append(res, pRootName, bRootDirectory, bRelativePath, pRelativePath);
825 path.swap(res);
834 SmallVectorImpl<char> &path) {
835 return make_absolute(current_directory, path, true);
838 std::error_code make_absolute(SmallVectorImpl<char> &path) {
839 return make_absolute(Twine(), path, false);
856 StringRef Parent = path::parent_path(P);
912 std::error_code is_directory(const Twine &path, bool &result) {
914 if (std::error_code ec = status(path, st))
924 std::error_code is_regular_file(const Twine &path, bool &result) {
926 if (std::error_code ec = status(path, st))
947 SmallString<128> path = path::parent_path(Path);
948 path::append(path, filename);
949 Path = path.str();
1135 namespace path {
1146 } // end namespace path