Lines Matching full:path

47   return llvm::sys::path::is_style_posix(style);  in PathStyleIsPosix()
51 return llvm::sys::path::get_separator(style).data(); in GetPathSeparators()
58 void Denormalize(llvm::SmallVectorImpl<char> &path, FileSpec::Style style) { in Denormalize() argument
62 std::replace(path.begin(), path.end(), '/', '\\'); in Denormalize()
69 // Default constructor that can take an optional full path to a file on disk.
70 FileSpec::FileSpec(llvm::StringRef path, Style style) : m_style(style) { in FileSpec() argument
71 SetFile(path, style); in FileSpec()
74 FileSpec::FileSpec(llvm::StringRef path, const llvm::Triple &triple) in FileSpec() argument
75 : FileSpec{path, triple.isOSWindows() ? Style::windows : Style::posix} {} in FileSpec()
80 /// \param[in] path
81 /// A full, partial, or relative path to a file.
84 /// An index into path which may or may not be valid.
89 inline char safeCharAtIndex(const llvm::StringRef &path, size_t i) { in safeCharAtIndex() argument
90 if (i < path.size()) in safeCharAtIndex()
91 return path[i]; in safeCharAtIndex()
95 /// Check if a path needs to be normalized.
97 /// Check if a path needs to be normalized. We currently consider a
98 /// path to need normalization if any of the following are true
99 /// - path contains "/./"
100 /// - path contains "/../"
101 /// - path contains "//"
102 /// - path ends with "/"
104 /// need normalization since we aren't trying to resolve the path,
105 /// we are just trying to remove redundant things from the path.
107 /// \param[in] path
108 /// A full, partial, or relative path to a file.
111 /// Returns \b true if the path needs to be normalized.
112 bool needsNormalization(const llvm::StringRef &path) { in needsNormalization() argument
113 if (path.empty()) in needsNormalization()
116 if (path[0] == '.') in needsNormalization()
118 for (auto i = path.find_first_of("\\/"); i != llvm::StringRef::npos; in needsNormalization()
119 i = path.find_first_of("\\/", i + 1)) { in needsNormalization()
120 const auto next = safeCharAtIndex(path, i+1); in needsNormalization()
123 // path separator char at the end of the string which should be in needsNormalization()
128 // two path separator chars in the middle of a path needs to be in needsNormalization()
136 const auto next_next = safeCharAtIndex(path, i+2); in needsNormalization()
144 const auto next_next_next = safeCharAtIndex(path, i+3); in needsNormalization()
170 // Update the contents of this object with a new path. The path will be split
182 // Normalize the path by removing ".", ".." and other redundant components. in SetFile()
184 llvm::sys::path::remove_dots(resolved, true, m_style); in SetFile()
191 // If we have no path after normalization set the path to the current in SetFile()
192 // directory. This matches what python does and also a few other path in SetFile()
198 // Split path into filename and directory. We rely on the underlying char in SetFile()
200 llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style); in SetFile()
204 llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style); in SetFile()
209 void FileSpec::SetFile(llvm::StringRef path, const llvm::Triple &triple) { in SetFile() argument
210 return SetFile(path, triple.isOSWindows() ? Style::windows : Style::posix); in SetFile()
325 std::string path{GetPath(true)}; in Dump() local
326 s << path; in Dump()
328 if (!m_filename && !path.empty() && path.back() != path_separator) in Dump()
364 // Extract the directory and path into a fixed buffer. This is needed as the
365 // directory and path are stored in separate string values.
366 size_t FileSpec::GetPath(char *path, size_t path_max_len, in GetPath() argument
368 if (!path) in GetPath()
372 ::snprintf(path, path_max_len, "%s", result.c_str()); in GetPath()
386 void FileSpec::GetPath(llvm::SmallVectorImpl<char> &path, in GetPath() argument
388 path.append(m_directory.GetStringRef().begin(), in GetPath()
390 // Since the path was normalized and all paths use '/' when stored in these in GetPath()
391 // objects, we don't need to look for the actual syntax specific path in GetPath()
395 path.insert(path.end(), '/'); in GetPath()
396 path.append(m_filename.GetStringRef().begin(), in GetPath()
398 if (denormalize && !path.empty()) in GetPath()
399 Denormalize(path, m_style); in GetPath()
404 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()
436 return ConstString(llvm::sys::path::filename(current_path, m_style)); in GetLastPathComponent()
443 llvm::sys::path::append(new_path, in PrependPathComponent()
444 llvm::sys::path::begin(current_path, m_style), in PrependPathComponent()
445 llvm::sys::path::end(current_path), m_style); in PrependPathComponent()
456 llvm::sys::path::append(current_path, m_style, component); in AppendPathComponent()
467 if (llvm::sys::path::has_parent_path(current_path, m_style)) { in RemoveLastPathComponent()
468 SetFile(llvm::sys::path::parent_path(current_path, m_style)); in RemoveLastPathComponent()
498 // Check if we have cached if this path is absolute to avoid recalculating. in IsAbsolute()
504 llvm::SmallString<64> path; in IsAbsolute() local
505 GetPath(path, false); in IsAbsolute()
507 if (!path.empty()) { in IsAbsolute()
509 if (path[0] == '~' || llvm::sys::path::is_absolute(path, m_style)) in IsAbsolute()