chromium/third_party/libc++/src/src/filesystem/path.cpp

//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//

#include <__config>
#include <filesystem>
#include <vector>

#include "error.h"
#include "path_parser.h"

_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM

ErrorHandler;
createView;
PathParser;
string_view_t;

///////////////////////////////////////////////////////////////////////////////
//                            path definitions
///////////////////////////////////////////////////////////////////////////////

constexpr path::value_type path::preferred_separator;

path& path::replace_extension(path const& replacement) {}

///////////////////////////////////////////////////////////////////////////////
// path.decompose

string_view_t path::__root_name() const {}

string_view_t path::__root_directory() const {}

string_view_t path::__root_path_raw() const {}

static bool ConsumeRootName(PathParser* PP) {}

static bool ConsumeRootDir(PathParser* PP) {}

string_view_t path::__relative_path() const {}

string_view_t path::__parent_path() const {}

string_view_t path::__filename() const {}

string_view_t path::__stem() const {}

string_view_t path::__extension() const {}

////////////////////////////////////////////////////////////////////////////
// path.gen

enum PathPartKind : unsigned char {};

static PathPartKind ClassifyPathPart(string_view_t Part) {}

path path::lexically_normal() const {}

static int DetermineLexicalElementCount(PathParser PP) {}

path path::lexically_relative(const path& base) const {}

////////////////////////////////////////////////////////////////////////////
// path.comparisons
static int CompareRootName(PathParser* LHS, PathParser* RHS) {}

static int CompareRootDir(PathParser* LHS, PathParser* RHS) {}

static int CompareRelative(PathParser* LHSPtr, PathParser* RHSPtr) {}

static int CompareEndState(PathParser* LHS, PathParser* RHS) {}

int path::__compare(string_view_t __s) const {}

////////////////////////////////////////////////////////////////////////////
// path.nonmembers
size_t hash_value(const path& __p) noexcept {}

////////////////////////////////////////////////////////////////////////////
// path.itr
path::iterator path::begin() const {}

path::iterator path::end() const {}

path::iterator& path::iterator::__increment() {}

path::iterator& path::iterator::__decrement() {}

#if defined(_LIBCPP_WIN32API)
////////////////////////////////////////////////////////////////////////////
// Windows path conversions
size_t __wide_to_char(const wstring& str, char* out, size_t outlen) {
  if (str.empty())
    return 0;
  ErrorHandler<size_t> err("__wide_to_char", nullptr);
  UINT codepage     = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
  BOOL used_default = FALSE;
  int ret           = WideCharToMultiByte(codepage, 0, str.data(), str.size(), out, outlen, nullptr, &used_default);
  if (ret <= 0 || used_default)
    return err.report(errc::illegal_byte_sequence);
  return ret;
}

size_t __char_to_wide(const string& str, wchar_t* out, size_t outlen) {
  if (str.empty())
    return 0;
  ErrorHandler<size_t> err("__char_to_wide", nullptr);
  UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
  int ret       = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, str.data(), str.size(), out, outlen);
  if (ret <= 0)
    return err.report(errc::illegal_byte_sequence);
  return ret;
}
#endif

_LIBCPP_END_NAMESPACE_FILESYSTEM