DEV9: Use fs namespace instead of ghc

This commit is contained in:
TheLastRar 2022-02-06 16:00:23 +00:00 committed by lightningterror
parent 30bc9b04c5
commit dcc183179a
6 changed files with 34 additions and 41 deletions

View File

@ -20,7 +20,6 @@
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <ghc/filesystem.h>
#include <fstream>
#include "DEV9/SimpleQueue.h"
@ -154,7 +153,7 @@ private:
public:
ATA();
int Open(ghc::filesystem::path hddPath);
int Open(fs::path hddPath);
void Close();
void ATA_HardReset();

View File

@ -26,7 +26,7 @@ ATA::ATA()
ResetEnd(true);
}
int ATA::Open(ghc::filesystem::path hddPath)
int ATA::Open(fs::path hddPath)
{
readBufferLen = 256 * 512;
readBuffer = new u8[readBufferLen];
@ -34,7 +34,7 @@ int ATA::Open(ghc::filesystem::path hddPath)
CreateHDDinfo(config.HddSize);
//Open File
if (!ghc::filesystem::exists(hddPath))
if (!fs::exists(hddPath))
{
HddCreate hddCreator;
hddCreator.filePath = hddPath;
@ -44,7 +44,7 @@ int ATA::Open(ghc::filesystem::path hddPath)
if (hddCreator.errored)
return -1;
}
hddImage = ghc::filesystem::fstream(hddPath, std::ios::in | std::ios::out | std::ios::binary);
hddImage = fs::fstream(hddPath, std::ios::in | std::ios::out | std::ios::binary);
//Store HddImage size for later check
hddImage.seekg(0, std::ios::end);

View File

@ -78,18 +78,18 @@ void HddCreate::Start()
completedCV.notify_all();
}
void HddCreate::WriteImage(ghc::filesystem::path hddPath, int reqSizeMiB)
void HddCreate::WriteImage(fs::path hddPath, int reqSizeMiB)
{
constexpr int buffsize = 4 * 1024;
u8 buff[buffsize] = {0}; //4kb
if (ghc::filesystem::exists(hddPath))
if (fs::exists(hddPath))
{
SetError();
return;
}
std::fstream newImage = ghc::filesystem::fstream(hddPath, std::ios::out | std::ios::binary);
std::fstream newImage = fs::fstream(hddPath, std::ios::out | std::ios::binary);
if (newImage.fail())
{
@ -105,7 +105,7 @@ void HddCreate::WriteImage(ghc::filesystem::path hddPath, int reqSizeMiB)
if (newImage.fail())
{
newImage.close();
ghc::filesystem::remove(filePath);
fs::remove(filePath);
SetError();
return;
}
@ -122,7 +122,7 @@ void HddCreate::WriteImage(ghc::filesystem::path hddPath, int reqSizeMiB)
if (newImage.fail())
{
newImage.close();
ghc::filesystem::remove(filePath);
fs::remove(filePath);
SetError();
return;
}
@ -137,7 +137,7 @@ void HddCreate::WriteImage(ghc::filesystem::path hddPath, int reqSizeMiB)
if (canceled.load())
{
newImage.close();
ghc::filesystem::remove(filePath);
fs::remove(filePath);
SetError();
return;
}

View File

@ -24,12 +24,11 @@
#include <atomic>
#include <condition_variable>
#include <chrono>
#include "ghc/filesystem.h"
class HddCreate
{
public:
ghc::filesystem::path filePath;
fs::path filePath;
int neededSize;
std::atomic_bool errored{false};
@ -56,5 +55,5 @@ public:
private:
void SetFileProgress(int currentSize);
void SetError();
void WriteImage(ghc::filesystem::path hddPath, int reqSizeMB);
void WriteImage(fs::path hddPath, int reqSizeMB);
};

View File

@ -18,7 +18,6 @@
#include <stdio.h>
#include <vector>
#include <ghc/filesystem.h>
#include <wx/wx.h>
#include <wx/collpane.h>
@ -383,16 +382,16 @@ void DEV9configure()
ConfigDEV9 oldConfig = config;
dialog.Save(config);
ghc::filesystem::path hddPath(config.Hdd);
fs::path hddPath(config.Hdd);
if (hddPath.is_relative())
{
//GHC uses UTF8 on all platforms
ghc::filesystem::path path(EmuFolders::Settings.ToString().wx_str());
fs::path path(EmuFolders::Settings.ToString().wx_str());
hddPath = path / hddPath;
}
if (config.hddEnable && !ghc::filesystem::exists(hddPath))
if (config.hddEnable && !fs::exists(hddPath))
{
HddCreate hddCreator;
hddCreator.filePath = hddPath;

View File

@ -25,8 +25,6 @@
#include <err.h>
#endif
#include "ghc/filesystem.h"
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
@ -96,6 +94,23 @@ std::string s_strLogPath = "logs";
bool isRunning = false;
fs::path GetHDDPath()
{
//GHC uses UTF8 on all platforms
fs::path hddPath(config.Hdd);
if (hddPath.empty())
config.hddEnable = false;
if (hddPath.is_relative())
{
fs::path path(EmuFolders::Settings.ToString().wx_str());
hddPath = path / hddPath;
}
return hddPath;
}
s32 DEV9init()
{
DevCon.WriteLn("DEV9: DEV9init");
@ -196,16 +211,7 @@ s32 DEV9open()
DevCon.WriteLn("DEV9: open r+: %s", config.Hdd);
#endif
ghc::filesystem::path hddPath(config.Hdd);
if (hddPath.empty())
config.hddEnable = false;
if (hddPath.is_relative())
{
ghc::filesystem::path path(EmuFolders::Settings.ToString().wx_str());
hddPath = path / hddPath;
}
fs::path hddPath = GetHDDPath();
if (config.hddEnable)
{
@ -1084,17 +1090,7 @@ void ApplyConfigIfRunning(ConfigDEV9 oldConfig)
//Hdd
//Hdd Validate Path
ghc::filesystem::path hddPath(config.Hdd);
if (hddPath.empty())
config.hddEnable = false;
if (hddPath.is_relative())
{
//GHC uses UTF8 on all platforms
ghc::filesystem::path path(EmuFolders::Settings.ToString().wx_str());
hddPath = path / hddPath;
}
fs::path hddPath = GetHDDPath();
//Hdd Compare with old config
if (config.hddEnable)