mirror of
https://github.com/FEX-Emu/FEX.git
synced 2026-10-06 10:00:16 +02:00
Make sure our std::filesystem users use the std::error_code versions
Otherwise these crash out.
This commit is contained in:
1 parent
83bdbc8392
commit
b586592643
6 files changed
+28
-18
No files matched your search
+1
-1
@@ -38,7 +38,7 @@ namespace FEXCore::Paths {
|
||||
|
||||
std::error_code ec{};
|
||||
// Ensure the folder structure is created for our Data
|
||||
if (!std::filesystem::exists(*EntryCache) &&
|
||||
if (!std::filesystem::exists(*EntryCache, ec) &&
|
||||
!std::filesystem::create_directories(*EntryCache, ec)) {
|
||||
LogMan::Msg::D("Couldn't create EntryCache directory: '%s'", EntryCache->c_str());
|
||||
}
|
||||
|
||||
+9
-6
@@ -60,7 +60,7 @@ namespace FEXCore::Config {
|
||||
|
||||
// Ensure the folder structure is created for our configuration
|
||||
std::error_code ec{};
|
||||
if (!std::filesystem::exists(ConfigDir) &&
|
||||
if (!std::filesystem::exists(ConfigDir, ec) &&
|
||||
!std::filesystem::create_directories(ConfigDir, ec)) {
|
||||
// Let's go local in this case
|
||||
return "./";
|
||||
@@ -88,7 +88,7 @@ namespace FEXCore::Config {
|
||||
|
||||
std::error_code ec{};
|
||||
if (!Global &&
|
||||
!std::filesystem::exists(ConfigFile) &&
|
||||
!std::filesystem::exists(ConfigFile, ec) &&
|
||||
!std::filesystem::create_directories(ConfigFile, ec)) {
|
||||
LogMan::Msg::D("Couldn't create config directory: '%s'", ConfigFile.c_str());
|
||||
// Let's go local in this case
|
||||
@@ -99,7 +99,7 @@ namespace FEXCore::Config {
|
||||
|
||||
// Attempt to create the local folder if it doesn't exist
|
||||
if (!Global &&
|
||||
!std::filesystem::exists(ConfigFile) &&
|
||||
!std::filesystem::exists(ConfigFile, ec) &&
|
||||
!std::filesystem::create_directories(ConfigFile, ec)) {
|
||||
// Let's go local in this case
|
||||
return "./" + Filename + ".json";
|
||||
@@ -274,7 +274,8 @@ namespace FEXCore::Config {
|
||||
Path = std::filesystem::absolute(Path);
|
||||
|
||||
// Only return if it exists
|
||||
if (std::filesystem::exists(Path)) {
|
||||
std::error_code ec{};
|
||||
if (std::filesystem::exists(Path, ec)) {
|
||||
return Path;
|
||||
}
|
||||
}
|
||||
@@ -310,7 +311,8 @@ namespace FEXCore::Config {
|
||||
else if (!PathName().empty()) {
|
||||
// If the filesystem doesn't exist then let's see if it exists in the fex-emu folder
|
||||
std::string NamedRootFS = GetDataDirectory() + "RootFS/" + PathName();
|
||||
if (std::filesystem::exists(NamedRootFS)) {
|
||||
std::error_code ec{};
|
||||
if (std::filesystem::exists(NamedRootFS, ec)) {
|
||||
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_ROOTFS, NamedRootFS);
|
||||
}
|
||||
}
|
||||
@@ -333,7 +335,8 @@ namespace FEXCore::Config {
|
||||
else if (!PathName().empty()) {
|
||||
// If the filesystem doesn't exist then let's see if it exists in the fex-emu folder
|
||||
std::string NamedConfig = GetDataDirectory() + "ThunkConfigs/" + PathName();
|
||||
if (std::filesystem::exists(NamedConfig)) {
|
||||
std::error_code ec{};
|
||||
if (std::filesystem::exists(NamedConfig, ec)) {
|
||||
FEXCore::Config::EraseSet(FEXCore::Config::CONFIG_THUNKCONFIG, NamedConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,8 @@ static std::fstream SquashFSLock{};
|
||||
bool SanityCheckPath(std::string const &LDPath) {
|
||||
// Check if we have an directory inside our temp folder
|
||||
std::string PathUser = LDPath + "/usr";
|
||||
if (!std::filesystem::exists(PathUser)) {
|
||||
std::error_code ec{};
|
||||
if (!std::filesystem::exists(PathUser, ec)) {
|
||||
LogMan::Msg::D("Child couldn't mount rootfs, /usr doesn't exist");
|
||||
rmdir(LDPath.c_str());
|
||||
return false;
|
||||
@@ -33,7 +34,8 @@ bool SanityCheckPath(std::string const &LDPath) {
|
||||
bool CheckLockExists(std::string const LockPath) {
|
||||
// If the lock file for a squashfs path exists the we can try
|
||||
// to open it and ref counting will keep it alive
|
||||
if (std::filesystem::exists(LockPath)) {
|
||||
std::error_code ec{};
|
||||
if (std::filesystem::exists(LockPath, ec)) {
|
||||
SquashFSLock.open(LockPath, std::ios_base::in | std::ios_base::binary);
|
||||
if (SquashFSLock.is_open()) {
|
||||
// We managed to open the file. Which means the mount application has now refcounted our interaction with it
|
||||
|
||||
@@ -95,11 +95,12 @@ ELFContainer::ELFContainer(std::string const &Filename, std::string const &RootF
|
||||
RawString = &RawFile.at(InterpreterHeader._64->p_offset);
|
||||
}
|
||||
std::string RootFSLink = RootFS + RawString;
|
||||
while (std::filesystem::is_symlink(RootFSLink)) {
|
||||
std::error_code ec{};
|
||||
while (std::filesystem::is_symlink(RootFSLink, ec)) {
|
||||
// Do some special handling if the RootFS's linker is a symlink
|
||||
// Ubuntu's rootFS by default provides an absolute location symlink to the linker
|
||||
// Resolve this around back to the rootfs
|
||||
auto SymlinkTarget = std::filesystem::read_symlink(RootFSLink);
|
||||
auto SymlinkTarget = std::filesystem::read_symlink(RootFSLink, ec);
|
||||
if (SymlinkTarget.is_absolute()) {
|
||||
RootFSLink = RootFS + SymlinkTarget.string();
|
||||
}
|
||||
|
||||
@@ -165,9 +165,11 @@ bool RanAsInterpreter(char *Program) {
|
||||
bool IsInterpreterInstalled() {
|
||||
// The interpreter is installed if both the binfmt_misc handlers are available
|
||||
// Or if we were originally executed with FD. Which means the interpreter is installed
|
||||
|
||||
std::error_code ec{};
|
||||
return ExecutedWithFD ||
|
||||
(std::filesystem::exists("/proc/sys/fs/binfmt_misc/FEX-x86") &&
|
||||
std::filesystem::exists("/proc/sys/fs/binfmt_misc/FEX-x86_64"));
|
||||
(std::filesystem::exists("/proc/sys/fs/binfmt_misc/FEX-x86", ec) &&
|
||||
std::filesystem::exists("/proc/sys/fs/binfmt_misc/FEX-x86_64", ec));
|
||||
}
|
||||
|
||||
void AOTGenSection(FEXCore::Context::Context *CTX, ELFCodeLoader2::LoadedSection &Section) {
|
||||
@@ -409,7 +411,8 @@ int main(int argc, char **argv, char **const envp) {
|
||||
|
||||
InterpreterHandler(&Program, LDPath(), &Args);
|
||||
|
||||
if (!std::filesystem::exists(Program)) {
|
||||
std::error_code ec{};
|
||||
if (!std::filesystem::exists(Program, ec)) {
|
||||
// Early exit if the program passed in doesn't exist
|
||||
// Will prevent a crash later
|
||||
fprintf(stderr, "%s: command not found\n", Program.c_str());
|
||||
@@ -548,7 +551,6 @@ int main(int argc, char **argv, char **const envp) {
|
||||
FEXCore::Context::RunUntilExit(CTX);
|
||||
}
|
||||
|
||||
std::error_code ec{};
|
||||
if (std::filesystem::create_directories(std::filesystem::path(FEXCore::Config::GetDataDirectory()) / "aotir", ec)) {
|
||||
FEXCore::Context::WriteFilesWithCode(CTX, [](const std::string& fileid, const std::string& filename) {
|
||||
auto filepath = std::filesystem::path(FEXCore::Config::GetDataDirectory()) / "aotir" / (fileid + ".path");
|
||||
|
||||
@@ -77,7 +77,8 @@ namespace {
|
||||
}
|
||||
|
||||
bool OpenFile(std::string Filename, bool LoadDefault = false) {
|
||||
if (!std::filesystem::exists(Filename)) {
|
||||
std::error_code ec{};
|
||||
if (!std::filesystem::exists(Filename, ec)) {
|
||||
if (LoadDefault) {
|
||||
LoadDefaultSettings();
|
||||
ConfigFilename = Filename;
|
||||
@@ -98,9 +99,10 @@ namespace {
|
||||
std::scoped_lock<std::mutex> lk{NamedRootFSUpdator};
|
||||
NamedRootFS.clear();
|
||||
std::string RootFS = FEXCore::Config::GetDataDirectory() + "RootFS/";
|
||||
if (!std::filesystem::exists(RootFS)) {
|
||||
std::error_code ec{};
|
||||
if (!std::filesystem::exists(RootFS, ec)) {
|
||||
// Doesn't exist, create the the folder as a user convenience
|
||||
if (!std::filesystem::create_directories(RootFS)) {
|
||||
if (!std::filesystem::create_directories(RootFS, ec)) {
|
||||
// Well I guess we failed
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user