mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-29 11:06:07 +00:00
Some nits and fixes on paths (#1190)
Some checks are pending
Build and Release / get-info (push) Waiting to run
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Some checks are pending
Build and Release / get-info (push) Waiting to run
Build and Release / pre-release (push) Blocked by required conditions
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
* Some nits and fixes * More path conversions * Add some more logging * Log the path too
This commit is contained in:
parent
ee1e55d5e1
commit
d20efcb0d2
|
@ -205,9 +205,9 @@ public:
|
|||
return WriteSpan(string);
|
||||
}
|
||||
|
||||
static void WriteBytes(const std::filesystem::path path, std::span<const u8> data) {
|
||||
static size_t WriteBytes(const std::filesystem::path path, std::span<const u8> data) {
|
||||
IOFile out(path, FileAccessMode::Write);
|
||||
out.Write(data);
|
||||
return out.Write(data);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -12,6 +12,7 @@ void TRP::GetNPcommID(const std::filesystem::path& trophyPath, int index) {
|
|||
std::filesystem::path trpPath = trophyPath / "sce_sys/npbind.dat";
|
||||
Common::FS::IOFile npbindFile(trpPath, Common::FS::FileAccessMode::Read);
|
||||
if (!npbindFile.IsOpen()) {
|
||||
LOG_CRITICAL(Common_Filesystem, "Failed to open npbind.dat file");
|
||||
return;
|
||||
}
|
||||
if (!npbindFile.Seek(0x84 + (index * 0x180))) {
|
||||
|
@ -35,6 +36,7 @@ static void removePadding(std::vector<u8>& vec) {
|
|||
bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string titleId) {
|
||||
std::filesystem::path gameSysDir = trophyPath / "sce_sys/trophy/";
|
||||
if (!std::filesystem::exists(gameSysDir)) {
|
||||
LOG_CRITICAL(Common_Filesystem, "Game sce_sys directory doesn't exist");
|
||||
return false;
|
||||
}
|
||||
for (int index = 0; const auto& it : std::filesystem::directory_iterator(gameSysDir)) {
|
||||
|
@ -43,13 +45,16 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit
|
|||
|
||||
Common::FS::IOFile file(it.path(), Common::FS::FileAccessMode::Read);
|
||||
if (!file.IsOpen()) {
|
||||
LOG_CRITICAL(Common_Filesystem, "Unable to open trophy file for read");
|
||||
return false;
|
||||
}
|
||||
|
||||
TrpHeader header;
|
||||
file.Read(header);
|
||||
if (header.magic != 0xDCA24D00)
|
||||
if (header.magic != 0xDCA24D00) {
|
||||
LOG_CRITICAL(Common_Filesystem, "Wrong trophy magic number");
|
||||
return false;
|
||||
}
|
||||
|
||||
s64 seekPos = sizeof(TrpHeader);
|
||||
std::filesystem::path trpFilesPath(
|
||||
|
@ -98,7 +103,14 @@ bool TRP::Extract(const std::filesystem::path& trophyPath, const std::string tit
|
|||
size_t pos = xml_name.find("ESFM");
|
||||
if (pos != std::string::npos)
|
||||
xml_name.replace(pos, xml_name.length(), "XML");
|
||||
Common::FS::IOFile::WriteBytes(trpFilesPath / "Xml" / xml_name, XML);
|
||||
std::filesystem::path path = trpFilesPath / "Xml" / xml_name;
|
||||
size_t written = Common::FS::IOFile::WriteBytes(path, XML);
|
||||
if (written != XML.size()) {
|
||||
LOG_CRITICAL(
|
||||
Common_Filesystem,
|
||||
"Trophy XML {} write failed, wanted to write {} bytes, wrote {}",
|
||||
fmt::UTF(path.u8string()), XML.size(), written);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -966,7 +966,7 @@ int PS4_SYSV_ABI sceNpTrophyUnlockTrophy(OrbisNpTrophyContext context, OrbisNpTr
|
|||
}
|
||||
}
|
||||
|
||||
doc.save_file((trophy_dir.string() + "/trophy00/Xml/TROP.XML").c_str());
|
||||
doc.save_file((trophy_dir / "trophy00" / "Xml" / "TROP.XML").native().c_str());
|
||||
|
||||
return ORBIS_OK;
|
||||
}
|
||||
|
|
|
@ -16,12 +16,13 @@ std::optional<TrophyUI> current_trophy_ui;
|
|||
std::queue<TrophyInfo> trophy_queue;
|
||||
std::mutex queueMtx;
|
||||
|
||||
TrophyUI::TrophyUI(std::filesystem::path trophyIconPath, std::string trophyName)
|
||||
TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName)
|
||||
: trophy_name(trophyName) {
|
||||
if (std::filesystem::exists(trophyIconPath)) {
|
||||
trophy_icon = RefCountedTexture::DecodePngFile(trophyIconPath);
|
||||
} else {
|
||||
LOG_ERROR(Lib_NpTrophy, "Couldnt load trophy icon at {}", trophyIconPath.string());
|
||||
LOG_ERROR(Lib_NpTrophy, "Couldnt load trophy icon at {}",
|
||||
fmt::UTF(trophyIconPath.u8string()));
|
||||
}
|
||||
AddLayer(this);
|
||||
}
|
||||
|
@ -66,7 +67,7 @@ void TrophyUI::Draw() {
|
|||
|
||||
trophy_timer -= io.DeltaTime;
|
||||
if (trophy_timer <= 0) {
|
||||
queueMtx.lock();
|
||||
std::lock_guard<std::mutex> lock(queueMtx);
|
||||
if (!trophy_queue.empty()) {
|
||||
TrophyInfo next_trophy = trophy_queue.front();
|
||||
trophy_queue.pop();
|
||||
|
@ -74,12 +75,11 @@ void TrophyUI::Draw() {
|
|||
} else {
|
||||
current_trophy_ui.reset();
|
||||
}
|
||||
queueMtx.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyName) {
|
||||
queueMtx.lock();
|
||||
void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName) {
|
||||
std::lock_guard<std::mutex> lock(queueMtx);
|
||||
if (current_trophy_ui.has_value()) {
|
||||
TrophyInfo new_trophy;
|
||||
new_trophy.trophy_icon_path = trophyIconPath;
|
||||
|
@ -88,7 +88,6 @@ void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyNa
|
|||
} else {
|
||||
current_trophy_ui.emplace(trophyIconPath, trophyName);
|
||||
}
|
||||
queueMtx.unlock();
|
||||
}
|
||||
|
||||
} // namespace Libraries::NpTrophy
|
|
@ -17,7 +17,7 @@ namespace Libraries::NpTrophy {
|
|||
|
||||
class TrophyUI final : public ImGui::Layer {
|
||||
public:
|
||||
TrophyUI(std::filesystem::path trophyIconPath, std::string trophyName);
|
||||
TrophyUI(const std::filesystem::path& trophyIconPath, const std::string& trophyName);
|
||||
~TrophyUI() override;
|
||||
|
||||
void Finish();
|
||||
|
@ -35,6 +35,6 @@ struct TrophyInfo {
|
|||
std::string trophy_name;
|
||||
};
|
||||
|
||||
void AddTrophyToQueue(std::filesystem::path trophyIconPath, std::string trophyName);
|
||||
void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::string& trophyName);
|
||||
|
||||
}; // namespace Libraries::NpTrophy
|
|
@ -343,8 +343,8 @@ void CheckUpdate::DownloadUpdate(const QString& url) {
|
|||
return;
|
||||
}
|
||||
|
||||
QString userPath =
|
||||
QString::fromStdString(Common::FS::GetUserPath(Common::FS::PathType::UserDir).string());
|
||||
QString userPath;
|
||||
Common::FS::PathToQString(userPath, Common::FS::GetUserPath(Common::FS::PathType::UserDir));
|
||||
QString tempDownloadPath = userPath + "/temp_download_update";
|
||||
QDir dir(tempDownloadPath);
|
||||
if (!dir.exists()) {
|
||||
|
@ -371,12 +371,13 @@ void CheckUpdate::DownloadUpdate(const QString& url) {
|
|||
}
|
||||
|
||||
void CheckUpdate::Install() {
|
||||
QString userPath =
|
||||
QString::fromStdString(Common::FS::GetUserPath(Common::FS::PathType::UserDir).string());
|
||||
QString userPath;
|
||||
Common::FS::PathToQString(userPath, Common::FS::GetUserPath(Common::FS::PathType::UserDir));
|
||||
|
||||
QString startingUpdate = tr("Starting Update...");
|
||||
QString tempDirPath = userPath + "/temp_download_update";
|
||||
QString rootPath = QString::fromStdString(std::filesystem::current_path().string());
|
||||
QString rootPath;
|
||||
Common::FS::PathToQString(rootPath, std::filesystem::current_path());
|
||||
|
||||
QString scriptContent;
|
||||
QString scriptFileName;
|
||||
|
|
Loading…
Reference in a new issue