Lines Matching full:path
48 return llvm::sys::path::is_style_posix(style); in PathStyleIsPosix()
52 return llvm::sys::path::get_separator(style).data(); in GetPathSeparators()
59 void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) { in Denormalize() argument
63 std::replace(path.begin(), path.end(), '/', '\\'); in Denormalize()
70 // Default constructor that can take an optional full path to a file on disk.
71 FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) { in FileSpec() argument
72 SetFile(path, style); in FileSpec()
75 FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple) in FileSpec() argument
76 : FileSpec{path, triple.isOSWindows() ? Style::windows : Style::posix} {} in FileSpec()
81 /// \param[in] path
82 /// A full, partial, or relative path to a file.
85 /// An index into path which may or may not be valid.
90 inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) { in safeCharAtIndex() argument
91 if (i < path.size()) in safeCharAtIndex()
92 return path[i]; in safeCharAtIndex()
96 /// Check if a path needs to be normalized.
98 /// Check if a path needs to be normalized. We currently consider a
99 /// path to need normalization if any of the following are true
100 /// - path contains "/./"
101 /// - path contains "/../"
102 /// - path contains "//"
103 /// - path ends with "/"
105 /// need normalization since we aren't trying to resolve the path,
106 /// we are just trying to remove redundant things from the path.
108 /// \param[in] path
109 /// A full, partial, or relative path to a file.
112 /// Returns \b true if the path needs to be normalized.
113 bool needsNormalization(const llvm::StringRef &path) { in needsNormalization() argument
114 if (path.empty()) in needsNormalization()
117 if (path[0] == '.') in needsNormalization()
119 for (auto i = path.find_first_of("\\/"); i != llvm::StringRef::npos; in needsNormalization()
120 i = path.find_first_of("\\/", i + 1)) { in needsNormalization()
121 const auto next = safeCharAtIndex(path, i+1); in needsNormalization()
124 // path separator char at the end of the string which should be in needsNormalization()
129 // two path separator chars in the middle of a path needs to be in needsNormalization()
137 const auto next_next = safeCharAtIndex(path, i+2); in needsNormalization()
145 const auto next_next_next = safeCharAtIndex(path, i+3); in needsNormalization()
171 // Update the contents of this object with a new path. The path will be split
183 // Normalize the path by removing ".", ".." and other redundant components. in SetFile()
185 llvm::sys::path::remove_dots(resolved, true, m_style); in SetFile()
192 // If we have no path after normalization set the path to the current in SetFile()
193 // directory. This matches what python does and also a few other path in SetFile()
199 // Split path into filename and directory. We rely on the underlying char in SetFile()
201 llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style); in SetFile()
205 llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style); in SetFile()
210 void FileSpec::SetFile(llvm::StringRef path, const llvm::Triple &triple) { in SetFile() argument
211 return SetFile(path, triple.isOSWindows() ? Style::windows : Style::posix); in SetFile()
326 std::string path{GetPath(true)}; in Dump() local
327 s << path; in Dump()
329 if (!m_filename && !path.empty() && path.back() != path_separator) in Dump()
365 // Extract the directory and path into a fixed buffer. This is needed as the
366 // directory and path are stored in separate string values.
367 size_t FileSpec::GetPath(char *path, size_t path_max_len, in GetPath() argument
369 if (!path) in GetPath()
373 ::snprintf(path, path_max_len, "%s", result.c_str()); in GetPath()
387 void FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, in GetPath() argument
389 path.append(m_directory.GetStringRef().begin(), in GetPath()
391 // Since the path was normalized and all paths use '/' when stored in these in GetPath()
392 // objects, we don't need to look for the actual syntax specific path in GetPath()
396 path.insert(path.end(), '/'); in GetPath()
397 path.append(m_filename.GetStringRef().begin(), in GetPath()
399 if (denormalize && !path.empty()) in GetPath()
400 Denormalize(path, m_style); in GetPath()
404 return llvm::sys::path::extension(m_filename.GetStringRef(), m_style); in GetFileNameExtension()
408 return ConstString(llvm::sys::path::stem(m_filename.GetStringRef(), m_style)); in GetFileNameStrippingExtension()
427 if (llvm::sys::path::has_parent_path(current_path, m_style)) in CopyByRemovingLastPathComponent()
428 return FileSpec(llvm::sys::path::parent_path(current_path, m_style), in CopyByRemovingLastPathComponent()
437 llvm::sys::path::append(new_path, in PrependPathComponent()
438 llvm::sys::path::begin(current_path, m_style), in PrependPathComponent()
439 llvm::sys::path::end(current_path), m_style); in PrependPathComponent()
450 llvm::sys::path::append(current_path, m_style, component); in AppendPathComponent()
461 if (llvm::sys::path::has_parent_path(current_path, m_style)) { in RemoveLastPathComponent()
462 SetFile(llvm::sys::path::parent_path(current_path, m_style)); in RemoveLastPathComponent()
471 auto dir_begin = llvm::sys::path::begin(m_directory.GetStringRef(), m_style); in GetComponents()
472 auto dir_end = llvm::sys::path::end(m_directory.GetStringRef()); in GetComponents()
512 // Check if we have cached if this path is absolute to avoid recalculating. in IsAbsolute()
518 llvm::SmallString<64> path; in IsAbsolute() local
519 GetPath(path, false); in IsAbsolute()
521 if (!path.empty()) { in IsAbsolute()
523 if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style)) in IsAbsolute()