LLVM 20.0.0git
Namespaces | Enumerations | Functions
Path.cpp File Reference
#include "llvm/Support/Path.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Config/config.h"
#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Endian.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Process.h"
#include "llvm/Support/Signals.h"
#include <cctype>
#include <unistd.h>
#include "Unix/Path.inc"

Go to the source code of this file.

Namespaces

namespace  llvm
 This is an optimization pass for GlobalISel generic memory operations.
 
namespace  llvm::sys
 
namespace  llvm::sys::path
 
namespace  llvm::sys::fs
 

Enumerations

enum  FSEntity { FS_Dir , FS_File , FS_Name }
 

Functions

static std::error_code createUniqueEntity (const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, bool MakeAbsolute, FSEntity Type, sys::fs::OpenFlags Flags=sys::fs::OF_None, unsigned Mode=0)
 
static bool llvm::sys::path::starts_with (StringRef Path, StringRef Prefix, Style style=Style::native)
 
static std::error_code llvm::sys::fs::createTemporaryFile (const Twine &Model, int &ResultFD, llvm::SmallVectorImpl< char > &ResultPath, FSEntity Type, sys::fs::OpenFlags Flags=sys::fs::OF_None)
 
static std::error_code llvm::sys::fs::createTemporaryFile (const Twine &Prefix, StringRef Suffix, int &ResultFD, llvm::SmallVectorImpl< char > &ResultPath, FSEntity Type, sys::fs::OpenFlags Flags=sys::fs::OF_None)
 
static std::error_code llvm::sys::fs::copy_file_internal (int ReadFD, int WriteFD)
 
Lexical Component Iterator
const_iterator llvm::sys::path::begin (StringRef path, Style style=Style::native)
 Get begin iterator over path.
 
const_iterator llvm::sys::path::end (StringRef path)
 Get end iterator over path.
 
reverse_iterator llvm::sys::path::rbegin (StringRef path, Style style=Style::native)
 Get reverse begin iterator over path.
 
reverse_iterator llvm::sys::path::rend (StringRef path)
 Get reverse end iterator over path.
 
Lexical Observers
StringRef llvm::sys::path::root_path (StringRef path, Style style=Style::native)
 Get root path.
 
StringRef llvm::sys::path::root_name (StringRef path, Style style=Style::native)
 Get root name.
 
StringRef llvm::sys::path::root_directory (StringRef path, Style style=Style::native)
 Get root directory.
 
StringRef llvm::sys::path::relative_path (StringRef path, Style style=Style::native)
 Get relative path.
 
StringRef llvm::sys::path::parent_path (StringRef path, Style style=Style::native)
 Get parent path.
 
StringRef llvm::sys::path::filename (StringRef path, Style style=Style::native)
 Get filename.
 
StringRef llvm::sys::path::stem (StringRef path, Style style=Style::native)
 Get stem.
 
StringRef llvm::sys::path::extension (StringRef path, Style style=Style::native)
 Get extension.
 
bool llvm::sys::path::is_separator (char value, Style style=Style::native)
 Check whether the given char is a path separator on the host OS.
 
StringRef llvm::sys::path::get_separator (Style style=Style::native)
 Return the preferred separator for this platform.
 
bool llvm::sys::path::has_root_name (const Twine &path, Style style=Style::native)
 Has root name?
 
bool llvm::sys::path::has_root_directory (const Twine &path, Style style=Style::native)
 Has root directory?
 
bool llvm::sys::path::has_root_path (const Twine &path, Style style=Style::native)
 Has root path?
 
bool llvm::sys::path::has_relative_path (const Twine &path, Style style=Style::native)
 Has relative path?
 
bool llvm::sys::path::has_filename (const Twine &path, Style style=Style::native)
 Has filename?
 
bool llvm::sys::path::has_parent_path (const Twine &path, Style style=Style::native)
 Has parent path?
 
bool llvm::sys::path::has_stem (const Twine &path, Style style=Style::native)
 Has stem?
 
bool llvm::sys::path::has_extension (const Twine &path, Style style=Style::native)
 Has extension?
 
bool llvm::sys::path::is_absolute (const Twine &path, Style style=Style::native)
 Is path absolute?
 
bool llvm::sys::path::is_absolute_gnu (const Twine &path, Style style=Style::native)
 Is path absolute using GNU rules?
 
bool llvm::sys::path::is_relative (const Twine &path, Style style=Style::native)
 Is path relative?
 
Lexical Modifiers
void llvm::sys::path::append (SmallVectorImpl< char > &path, Style style, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
 
void llvm::sys::path::append (SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
 Append to path.
 
void llvm::sys::path::append (SmallVectorImpl< char > &path, const_iterator begin, const_iterator end, Style style=Style::native)
 Append to path.
 
void llvm::sys::path::remove_filename (SmallVectorImpl< char > &path, Style style=Style::native)
 Remove the last component from path unless it is the root dir.
 
void llvm::sys::path::replace_extension (SmallVectorImpl< char > &path, const Twine &extension, Style style=Style::native)
 Replace the file extension of path with extension.
 
bool llvm::sys::path::replace_path_prefix (SmallVectorImpl< char > &Path, StringRef OldPrefix, StringRef NewPrefix, Style style=Style::native)
 Replace matching path prefix with another path.
 
StringRef llvm::sys::path::remove_leading_dotslash (StringRef path, Style style=Style::native)
 Remove redundant leading "./" pieces and consecutive separators.
 
bool llvm::sys::path::remove_dots (SmallVectorImpl< char > &path, bool remove_dot_dot=false, Style style=Style::native)
 In-place remove any '.
 
Transforms (or some other better name)
void llvm::sys::path::native (const Twine &path, SmallVectorImpl< char > &result, Style style=Style::native)
 Convert path to the native form.
 
void llvm::sys::path::native (SmallVectorImpl< char > &path, Style style=Style::native)
 Convert path to the native form in place.
 
std::string llvm::sys::path::convert_to_slash (StringRef path, Style style=Style::native)
 Replaces backslashes with slashes if Windows.
 
Physical Observers
std::error_code llvm::sys::fs::getUniqueID (const Twine Path, UniqueID &Result)
 
void llvm::sys::fs::createUniquePath (const Twine &Model, SmallVectorImpl< char > &ResultPath, bool MakeAbsolute)
 Create a potentially unique file name but does not create it.
 
std::error_code llvm::sys::fs::createUniqueFile (const Twine &Model, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None, unsigned Mode=all_read|all_write)
 Create a uniquely named file.
 
std::error_code llvm::sys::fs::createUniqueFile (const Twine &Model, SmallVectorImpl< char > &ResultPath, unsigned Mode=all_read|all_write)
 Simpler version for clients that don't want an open file.
 
std::error_code llvm::sys::fs::createTemporaryFile (const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
 Create a file in the system temporary directory.
 
std::error_code llvm::sys::fs::createTemporaryFile (const Twine &Prefix, StringRef Suffix, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
 Simpler version for clients that don't want an open file.
 
std::error_code llvm::sys::fs::createUniqueDirectory (const Twine &Prefix, SmallVectorImpl< char > &ResultPath)
 
std::error_code llvm::sys::fs::getPotentiallyUniqueFileName (const Twine &Model, SmallVectorImpl< char > &ResultPath)
 Get a unique name, not currently exisiting in the filesystem.
 
std::error_code llvm::sys::fs::getPotentiallyUniqueTempFileName (const Twine &Prefix, StringRef Suffix, SmallVectorImpl< char > &ResultPath)
 Get a unique temporary file name, not currently exisiting in the filesystem.
 
bool llvm::sys::fs::exists (const basic_file_status &status)
 Does file exist?
 
bool llvm::sys::fs::status_known (const basic_file_status &s)
 Is status available?
 
file_type llvm::sys::fs::get_file_type (const Twine &Path, bool Follow=true)
 Does status represent a directory?
 
bool llvm::sys::fs::is_directory (const basic_file_status &status)
 Does status represent a directory?
 
std::error_code llvm::sys::fs::is_directory (const Twine &path, bool &result)
 Is path a directory?
 
bool llvm::sys::fs::is_regular_file (const basic_file_status &status)
 Does status represent a regular file?
 
std::error_code llvm::sys::fs::is_regular_file (const Twine &path, bool &result)
 Is path a regular file?
 
bool llvm::sys::fs::is_symlink_file (const basic_file_status &status)
 Does status represent a symlink file?
 
std::error_code llvm::sys::fs::is_symlink_file (const Twine &path, bool &result)
 Is path a symlink file?
 
bool llvm::sys::fs::is_other (const basic_file_status &status)
 Does this status represent something that exists but is not a directory or regular file?
 
std::error_code llvm::sys::fs::is_other (const Twine &path, bool &result)
 Is path something that exists but is not a directory, regular file, or symlink?
 
ErrorOr< perms > llvm::sys::fs::getPermissions (const Twine &Path)
 Get file permissions.
 
Error llvm::sys::fs::readNativeFileToEOF (file_t FileHandle, SmallVectorImpl< char > &Buffer, ssize_t ChunkSize=DefaultReadChunkSize)
 Reads from FileHandle until EOF, appending to Buffer in chunks of size ChunkSize.
 
Physical Operators
void llvm::sys::fs::make_absolute (const Twine &current_directory, SmallVectorImpl< char > &path)
 Make path an absolute path.
 
std::error_code llvm::sys::fs::make_absolute (SmallVectorImpl< char > &path)
 Make path an absolute path.
 
std::error_code llvm::sys::fs::create_directories (const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
 Create all the non-existent directories in path.
 
std::error_code llvm::sys::fs::copy_file (const Twine &From, const Twine &To)
 Copy the contents of From to To.
 
std::error_code llvm::sys::fs::copy_file (const Twine &From, int ToFD)
 Copy the contents of From to To.
 
ErrorOr< MD5::MD5Resultllvm::sys::fs::md5_contents (int FD)
 Compute an MD5 hash of a file's contents.
 
ErrorOr< MD5::MD5Resultllvm::sys::fs::md5_contents (const Twine &Path)
 Version of compute_md5 that doesn't require an open file descriptor.
 

Enumeration Type Documentation

◆ FSEntity

enum FSEntity
Enumerator
FS_Dir 
FS_File 
FS_Name 

Definition at line 164 of file Path.cpp.

Function Documentation

◆ createUniqueEntity()

static std::error_code createUniqueEntity ( const Twine Model,
int &  ResultFD,
SmallVectorImpl< char > &  ResultPath,
bool  MakeAbsolute,
FSEntity  Type,
sys::fs::OpenFlags  Flags = sys::fs::OF_None,
unsigned  Mode = 0 
)
static