[File] Fix File::Exists(file_name) to be resilient to Chinese characters (#4058)

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Update file.cpp

* Final fix
This commit is contained in:
Chris Miles 2024-02-11 02:42:25 -06:00 committed by GitHub
parent 78aa527bc7
commit 13994fb3e4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -38,21 +38,21 @@
#include <fmt/format.h>
#include <filesystem>
#include <iostream>
#include <sys/stat.h>
namespace fs = std::filesystem;
/**
* @param name
* @return
*/
bool File::Exists(const std::string &name)
{
return fs::exists(fs::path{name});
struct stat sb{};
if (stat(name.c_str(), &sb) == 0) {
return true;
}
return false;
}
/**
* @param directory_name
*/
void File::Makedir(const std::string &directory_name)
{
try {