9#ifndef LLDB_UTILITY_FILESPEC_H
10#define LLDB_UTILITY_FILESPEC_H
18#include "llvm/ADT/StringRef.h"
19#include "llvm/Support/FileSystem.h"
20#include "llvm/Support/FormatVariadic.h"
21#include "llvm/Support/Path.h"
36template <
typename T>
class SmallVectorImpl;
58 using Style = llvm::sys::path::Style;
75 explicit FileSpec(llvm::StringRef path,
Style style = Style::native);
77 explicit FileSpec(llvm::StringRef path,
const llvm::Triple &triple);
136 explicit operator bool()
const;
198 static std::optional<Style>
GuessPathStyle(llvm::StringRef absolute_path);
215 void Dump(llvm::raw_ostream &s)
const;
299 size_t GetPath(
char *path,
size_t max_path_length,
300 bool denormalize =
true)
const;
309 std::string
GetPath(
bool denormalize =
true)
const;
323 bool denormalize =
true)
const;
378 void SetFile(llvm::StringRef path,
const llvm::Triple &triple);
410 void SetFile(llvm::StringRef path);
A uniqued constant string class.
void SetFile(llvm::StringRef path, Style style)
Change the file specified with a new path.
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
void AppendPathComponent(llvm::StringRef component)
void SetDirectory(ConstString directory)
Directory string set accessor.
static bool Equal(const FileSpec &a, const FileSpec &b, bool full)
static std::optional< Style > GuessPathStyle(llvm::StringRef absolute_path)
Attempt to guess path style for a given path string.
static bool Match(const FileSpec &pattern, const FileSpec &file)
Match FileSpec pattern against FileSpec file.
bool IsRelative() const
Returns true if the filespec represents a relative path.
bool FileEquals(const FileSpec &other) const
bool operator<(const FileSpec &rhs) const
Less than to operator.
const ConstString & GetFilename() const
Filename string const get accessor.
bool RemoveLastPathComponent()
Removes the last path component by replacing the current path with its parent.
void MakeAbsolute(const FileSpec &dir)
Make the FileSpec absolute by treating it relative to dir.
bool operator!() const
Logical NOT operator.
ConstString m_filename
The unique'd filename path.
std::vector< llvm::StringRef > GetComponents() const
Gets the components of the FileSpec's path.
void ClearDirectory()
Clear the directory in this object.
const ConstString & GetDirectory() const
Directory string const get accessor.
bool IsCaseSensitive() const
Case sensitivity of path.
void SetPath(llvm::StringRef p)
Temporary helper for FileSystem change.
bool DirectoryEquals(const FileSpec &other) const
bool IsAbsolute() const
Returns true if the filespec represents an absolute path.
Style GetPathStyle() const
void PathWasModified()
Called anytime m_directory or m_filename is changed to clear any cached state in this object.
size_t MemorySize() const
Get the memory cost of this object.
static int Compare(const FileSpec &lhs, const FileSpec &rhs, bool full)
Compare two FileSpec objects.
Style m_style
The syntax that this path uses. (e.g. Windows / Posix)
ConstString GetFileNameStrippingExtension() const
Return the filename without the extension part.
void PrependPathComponent(llvm::StringRef component)
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void Clear()
Clears the object state.
Absolute m_absolute
Cache whether this path is absolute.
bool operator!=(const FileSpec &rhs) const
Not equal to operator.
void Dump(llvm::raw_ostream &s) const
Dump this object to a Stream.
ConstString GetPathAsConstString(bool denormalize=true) const
Get the full path as a ConstString.
bool IsSourceImplementationFile() const
Returns true if the filespec represents an implementation source file (files with a "....
ConstString m_directory
The unique'd directory path.
bool operator==(const FileSpec &rhs) const
Equal to operator.
FileSpec CopyByRemovingLastPathComponent() const
llvm::StringRef GetFileNameExtension() const
Extract the extension of the file.
llvm::sys::path::Style Style
void SetFilename(ConstString filename)
Filename string set accessor.
void ClearFilename()
Clear the filename in this object.
A stream class that can stream formatted output to a file.
A class that represents a running process on the host machine.
Stream & operator<<(Stream &s, const Mangled &obj)