Browse Source

Replace uses of deprecated u8path

pull/7153/head
Gleb Mazovetskiy 2 years ago
parent
commit
35e93366f6
  1. 7
      Source/dvlnet/zerotier_native.cpp
  2. 12
      Source/utils/file_util.cpp

7
Source/dvlnet/zerotier_native.cpp

@ -95,7 +95,8 @@ std::string ToZTCompliantPath(std::string_view configPath)
}
std::string symlinkPath = StrCat(alternateConfigPath, "\\", alternateFolderName);
bool symlinkExists = std::filesystem::exists(std::filesystem::u8path(symlinkPath), err);
bool symlinkExists = std::filesystem::exists(
std::u8string_view(reinterpret_cast<const char8_t *>(symlinkPath.data()), symlinkPath.size()), err);
if (err) {
LogVerbose("Failed to determine if symlink for ZT-compliant config path exists");
return std::string(configPath);
@ -103,8 +104,8 @@ std::string ToZTCompliantPath(std::string_view configPath)
if (!symlinkExists) {
std::filesystem::create_directory_symlink(
std::filesystem::u8path(configPath),
std::filesystem::u8path(symlinkPath),
std::u8string_view(reinterpret_cast<const char8_t *>(configPath.data()), configPath.size()),
std::u8string_view(reinterpret_cast<const char8_t *>(symlinkPath.data()), symlinkPath.size()),
err);
if (err) {

12
Source/utils/file_util.cpp

@ -106,7 +106,7 @@ bool FileExists(const char *path)
return ::access(path, F_OK) == 0;
#elif defined(DVL_HAS_FILESYSTEM)
std::error_code ec;
return std::filesystem::exists(std::filesystem::u8path(path), ec);
return std::filesystem::exists(reinterpret_cast<const char8_t *>(path), ec);
#else
SDL_RWops *file = SDL_RWFromFile(path, "r+b");
if (file == nullptr)
@ -154,7 +154,7 @@ bool DirectoryExists(const char *path)
return attr != INVALID_FILE_ATTRIBUTES && (attr & FILE_ATTRIBUTE_DIRECTORY) != 0;
#elif defined(DVL_HAS_FILESYSTEM)
std::error_code error;
return std::filesystem::is_directory(std::filesystem::u8path(path), error);
return std::filesystem::is_directory(reinterpret_cast<const char8_t *>(path), error);
#elif (_POSIX_C_SOURCE >= 200112L || defined(_BSD_SOURCE) || defined(__APPLE__)) && !defined(__ANDROID__)
struct ::stat statResult;
return ::stat(path, &statResult) == 0 && S_ISDIR(statResult.st_mode);
@ -233,7 +233,7 @@ bool CreateDir(const char *path)
{
#ifdef DVL_HAS_FILESYSTEM
std::error_code error;
std::filesystem::create_directory(std::filesystem::u8path(path), error);
std::filesystem::create_directory(reinterpret_cast<const char8_t *>(path), error);
if (error) {
LogError("failed to create directory {}: {}", path, error.message());
return false;
@ -274,7 +274,7 @@ void RecursivelyCreateDir(const char *path)
{
#ifdef DVL_HAS_FILESYSTEM
std::error_code error;
std::filesystem::create_directories(std::filesystem::u8path(path), error);
std::filesystem::create_directories(reinterpret_cast<const char8_t *>(path), error);
if (error) {
LogError("failed to create directory {}: {}", path, error.message());
}
@ -373,7 +373,7 @@ void RenameFile(const char *from, const char *to)
#endif // _WIN32
#elif defined(DVL_HAS_FILESYSTEM)
std::error_code ec;
std::filesystem::rename(std::filesystem::u8path(from), std::filesystem::u8path(to), ec);
std::filesystem::rename(reinterpret_cast<const char8_t *>(from), reinterpret_cast<const char8_t *>(to), ec);
#else
::rename(from, to);
#endif
@ -401,7 +401,7 @@ void CopyFileOverwrite(const char *from, const char *to)
::copyfile(from, to, nullptr, COPYFILE_ALL);
#elif defined(DVL_HAS_FILESYSTEM)
std::error_code error;
std::filesystem::copy_file(std::filesystem::u8path(from), std::filesystem::u8path(to), std::filesystem::copy_options::overwrite_existing, error);
std::filesystem::copy_file(reinterpret_cast<const char8_t *>(from), reinterpret_cast<const char8_t *>(to), std::filesystem::copy_options::overwrite_existing, error);
if (error) {
LogError("Failed to copy {} to {}: {}", from, to, error.message());
}

Loading…
Cancel
Save