llvm/llvm/lib/Support/Path.cpp

//===-- Path.cpp - Implement OS Path Concept ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//  This file implements the operating system Path API.
//
//===----------------------------------------------------------------------===//

#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>

#if !defined(_MSC_VER) && !defined(__MINGW32__)
#include <unistd.h>
#else
#include <io.h>
#endif

usingnamespacellvm;
usingnamespacellvm::support::endian;

namespace {
  StringRef;
  is_separator;
  Style;

  inline Style real_style(Style style) {}

  inline const char *separators(Style style) {}

  inline char preferred_separator(Style style) {}

  StringRef find_first_component(StringRef path, Style style) {}

  // Returns the first character of the filename in str. For paths ending in
  // '/', it returns the position of the '/'.
  size_t filename_pos(StringRef str, Style style) {}

  // Returns the position of the root directory in str. If there is no root
  // directory in str, it returns StringRef::npos.
  size_t root_dir_start(StringRef str, Style style) {}

  // Returns the position past the end of the "parent path" of path. The parent
  // path will not end in '/', unless the parent is the root directory. If the
  // path has no parent, 0 is returned.
  size_t parent_path_end(StringRef path, Style style) {}
} // end unnamed namespace

enum FSEntity {};

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) {}

namespace llvm {
namespace sys  {
namespace path {

const_iterator begin(StringRef path, Style style) {}

const_iterator end(StringRef path) {}

const_iterator &const_iterator::operator++() {}

bool const_iterator::operator==(const const_iterator &RHS) const {}

ptrdiff_t const_iterator::operator-(const const_iterator &RHS) const {}

reverse_iterator rbegin(StringRef Path, Style style) {}

reverse_iterator rend(StringRef Path) {}

reverse_iterator &reverse_iterator::operator++() {}

bool reverse_iterator::operator==(const reverse_iterator &RHS) const {}

ptrdiff_t reverse_iterator::operator-(const reverse_iterator &RHS) const {}

StringRef root_path(StringRef path, Style style) {}

StringRef root_name(StringRef path, Style style) {}

StringRef root_directory(StringRef path, Style style) {}

StringRef relative_path(StringRef path, Style style) {}

void append(SmallVectorImpl<char> &path, Style style, const Twine &a,
            const Twine &b, const Twine &c, const Twine &d) {}

void append(SmallVectorImpl<char> &path, const Twine &a, const Twine &b,
            const Twine &c, const Twine &d) {}

void append(SmallVectorImpl<char> &path, const_iterator begin,
            const_iterator end, Style style) {}

StringRef parent_path(StringRef path, Style style) {}

void remove_filename(SmallVectorImpl<char> &path, Style style) {}

void replace_extension(SmallVectorImpl<char> &path, const Twine &extension,
                       Style style) {}

static bool starts_with(StringRef Path, StringRef Prefix,
                        Style style = Style::native) {}

bool replace_path_prefix(SmallVectorImpl<char> &Path, StringRef OldPrefix,
                         StringRef NewPrefix, Style style) {}

void native(const Twine &path, SmallVectorImpl<char> &result, Style style) {}

void native(SmallVectorImpl<char> &Path, Style style) {}

std::string convert_to_slash(StringRef path, Style style) {}

StringRef filename(StringRef path, Style style) {}

StringRef stem(StringRef path, Style style) {}

StringRef extension(StringRef path, Style style) {}

bool is_separator(char value, Style style) {}

StringRef get_separator(Style style) {}

bool has_root_name(const Twine &path, Style style) {}

bool has_root_directory(const Twine &path, Style style) {}

bool has_root_path(const Twine &path, Style style) {}

bool has_relative_path(const Twine &path, Style style) {}

bool has_filename(const Twine &path, Style style) {}

bool has_parent_path(const Twine &path, Style style) {}

bool has_stem(const Twine &path, Style style) {}

bool has_extension(const Twine &path, Style style) {}

bool is_absolute(const Twine &path, Style style) {}

bool is_absolute_gnu(const Twine &path, Style style) {}

bool is_relative(const Twine &path, Style style) {}

StringRef remove_leading_dotslash(StringRef Path, Style style) {}

// Remove path traversal components ("." and "..") when possible, and
// canonicalize slashes.
bool remove_dots(SmallVectorImpl<char> &the_path, bool remove_dot_dot,
                 Style style) {}

} // end namespace path

namespace fs {

std::error_code getUniqueID(const Twine Path, UniqueID &Result) {}

void createUniquePath(const Twine &Model, SmallVectorImpl<char> &ResultPath,
                      bool MakeAbsolute) {}

std::error_code createUniqueFile(const Twine &Model, int &ResultFd,
                                 SmallVectorImpl<char> &ResultPath,
                                 OpenFlags Flags, unsigned Mode) {}

std::error_code createUniqueFile(const Twine &Model,
                                 SmallVectorImpl<char> &ResultPath,
                                 unsigned Mode) {}

static std::error_code
createTemporaryFile(const Twine &Model, int &ResultFD,
                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type,
                    sys::fs::OpenFlags Flags = sys::fs::OF_None) {}

static std::error_code
createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD,
                    llvm::SmallVectorImpl<char> &ResultPath, FSEntity Type,
                    sys::fs::OpenFlags Flags = sys::fs::OF_None) {}

std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
                                    int &ResultFD,
                                    SmallVectorImpl<char> &ResultPath,
                                    sys::fs::OpenFlags Flags) {}

std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix,
                                    SmallVectorImpl<char> &ResultPath,
                                    sys::fs::OpenFlags Flags) {}

// This is a mkdtemp with a different pattern. We use createUniqueEntity mostly
// for consistency. We should try using mkdtemp.
std::error_code createUniqueDirectory(const Twine &Prefix,
                                      SmallVectorImpl<char> &ResultPath) {}

std::error_code
getPotentiallyUniqueFileName(const Twine &Model,
                             SmallVectorImpl<char> &ResultPath) {}

std::error_code
getPotentiallyUniqueTempFileName(const Twine &Prefix, StringRef Suffix,
                                 SmallVectorImpl<char> &ResultPath) {}

void make_absolute(const Twine &current_directory,
                   SmallVectorImpl<char> &path) {}

std::error_code make_absolute(SmallVectorImpl<char> &path) {}

std::error_code create_directories(const Twine &Path, bool IgnoreExisting,
                                   perms Perms) {}

static std::error_code copy_file_internal(int ReadFD, int WriteFD) {}

#ifndef __APPLE__
std::error_code copy_file(const Twine &From, const Twine &To) {}
#endif

std::error_code copy_file(const Twine &From, int ToFD) {}

ErrorOr<MD5::MD5Result> md5_contents(int FD) {}

ErrorOr<MD5::MD5Result> md5_contents(const Twine &Path) {}

bool exists(const basic_file_status &status) {}

bool status_known(const basic_file_status &s) {}

file_type get_file_type(const Twine &Path, bool Follow) {}

bool is_directory(const basic_file_status &status) {}

std::error_code is_directory(const Twine &path, bool &result) {}

bool is_regular_file(const basic_file_status &status) {}

std::error_code is_regular_file(const Twine &path, bool &result) {}

bool is_symlink_file(const basic_file_status &status) {}

std::error_code is_symlink_file(const Twine &path, bool &result) {}

bool is_other(const basic_file_status &status) {}

std::error_code is_other(const Twine &Path, bool &Result) {}

void directory_entry::replace_filename(const Twine &Filename, file_type Type,
                                       basic_file_status Status) {}

ErrorOr<perms> getPermissions(const Twine &Path) {}

size_t mapped_file_region::size() const {}

char *mapped_file_region::data() const {}

const char *mapped_file_region::const_data() const {}

Error readNativeFileToEOF(file_t FileHandle, SmallVectorImpl<char> &Buffer,
                          ssize_t ChunkSize) {}

} // end namespace fs
} // end namespace sys
} // end namespace llvm

// Include the truly platform-specific parts.
#if defined(LLVM_ON_UNIX)
#include "Unix/Path.inc"
#endif
#if defined(_WIN32)
#include "Windows/Path.inc"
#endif

namespace llvm {
namespace sys {
namespace fs {

TempFile::TempFile(StringRef Name, int FD)
    :{}
TempFile::TempFile(TempFile &&Other) {}
TempFile &TempFile::operator=(TempFile &&Other) {}

TempFile::~TempFile() {}

Error TempFile::discard() {}

Error TempFile::keep(const Twine &Name) {}

Error TempFile::keep() {}

Expected<TempFile> TempFile::create(const Twine &Model, unsigned Mode,
                                    OpenFlags ExtraFlags) {}
} // namespace fs

} // namespace sys
} // namespace llvm