mirror of
https://github.com/obhq/obliteration.git
synced 2024-11-23 11:19:56 +00:00
Fixes incorrect path for system files (#145)
This commit is contained in:
parent
7a52cadce1
commit
250f947a83
@ -1,5 +1,5 @@
|
||||
#include "app_data.hpp"
|
||||
#include "util.hpp"
|
||||
#include "path.hpp"
|
||||
|
||||
#include <QStandardPaths>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "game_models.hpp"
|
||||
#include "path.hpp"
|
||||
#include "pkg.hpp"
|
||||
#include "util.hpp"
|
||||
|
||||
Game::Game(const QString &name, const QString &directory) :
|
||||
m_name(name),
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "game_models.hpp"
|
||||
#include "game_settings_dialog.hpp"
|
||||
#include "log_formatter.hpp"
|
||||
#include "path.hpp"
|
||||
#include "pkg.hpp"
|
||||
#include "progress_dialog.hpp"
|
||||
#include "settings.hpp"
|
||||
|
15
src/path.cpp
15
src/path.cpp
@ -2,6 +2,21 @@
|
||||
|
||||
using std::filesystem::path;
|
||||
|
||||
std::string joinPath(const QString &base, const QString &name)
|
||||
{
|
||||
try {
|
||||
auto p = toPath(base);
|
||||
#ifdef _WIN32
|
||||
p /= name.toStdWString();
|
||||
#else
|
||||
p /= name.toStdString();
|
||||
#endif
|
||||
return p.u8string();
|
||||
} catch (...) {
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
path toPath(const QString &v)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
|
@ -3,6 +3,10 @@
|
||||
#include <QString>
|
||||
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
|
||||
// Do not throw. Return empty string is case of error.
|
||||
std::string joinPath(const QString &base, const QString &name);
|
||||
|
||||
// v must be native format.
|
||||
std::filesystem::path toPath(const QString &v);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <QCloseEvent>
|
||||
#include <QCoreApplication>
|
||||
#include <QFontMetrics>
|
||||
#include <QLabel>
|
||||
#include <QProgressBar>
|
||||
#include <QTimer>
|
||||
@ -64,7 +65,10 @@ QString ProgressDialog::statusText() const
|
||||
|
||||
void ProgressDialog::setStatusText(const QString &v)
|
||||
{
|
||||
m_status->setText(v);
|
||||
QFontMetrics metrics(m_status->font());
|
||||
|
||||
m_status->setText(metrics.elidedText(v, Qt::ElideRight, m_status->width()));
|
||||
|
||||
QCoreApplication::processEvents();
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ use exfat::ExFat;
|
||||
use std::error::Error;
|
||||
use std::ffi::{c_void, CString};
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::fs::{create_dir, File};
|
||||
use std::fs::{create_dir, create_dir_all, File};
|
||||
use std::io::{Read, Seek, Write};
|
||||
use std::os::raw::c_char;
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -121,9 +121,17 @@ impl Pup {
|
||||
Err(e) => return Err(DumpSystemImageError::CreateImageReaderFailed(e)),
|
||||
};
|
||||
|
||||
// Dump files.
|
||||
// Create a destination directory.
|
||||
let output = output.as_ref();
|
||||
|
||||
if let Err(e) = create_dir_all(output) {
|
||||
return Err(DumpSystemImageError::CreateDirectoryFailed(
|
||||
output.into(),
|
||||
e,
|
||||
));
|
||||
}
|
||||
|
||||
// Dump files.
|
||||
for item in fat {
|
||||
use exfat::directory::Item;
|
||||
|
||||
|
@ -14,6 +14,7 @@ bool hasSystemFilesInstalled()
|
||||
auto libkernel = toPath(readSystemDirectorySetting());
|
||||
|
||||
try {
|
||||
libkernel /= STR("system");
|
||||
libkernel /= STR("common");
|
||||
libkernel /= STR("lib");
|
||||
libkernel /= STR("libkernel.sprx");
|
||||
@ -46,7 +47,7 @@ bool updateSystemFiles(QWidget *parent)
|
||||
}
|
||||
|
||||
// Dump system image.
|
||||
auto output = readSystemDirectorySetting().toStdString();
|
||||
auto output = joinPath(readSystemDirectorySetting(), "system");
|
||||
error = pup_dump_system(pup, output.c_str(), [](const char *name, std::uint64_t total, std::uint64_t written, void *ud) {
|
||||
auto toProgress = [total](std::uint64_t v) -> int {
|
||||
if (total >= 1024UL*1024UL*1024UL*1024UL) { // >= 1TB
|
||||
|
17
src/util.cpp
17
src/util.cpp
@ -1,23 +1,6 @@
|
||||
#include "util.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
|
||||
std::string joinPath(const QString &base, const QString &name)
|
||||
{
|
||||
try {
|
||||
#ifdef _WIN32
|
||||
std::filesystem::path p(base.toStdWString(), std::filesystem::path::native_format);
|
||||
p /= name.toStdWString();
|
||||
#else
|
||||
std::filesystem::path p(base.toStdString(), std::filesystem::path::native_format);
|
||||
p /= name.toStdString();
|
||||
#endif
|
||||
return p.u8string();
|
||||
} catch (...) {
|
||||
return std::string();
|
||||
}
|
||||
}
|
||||
|
||||
QString fromMalloc(char *s)
|
||||
{
|
||||
|
@ -2,10 +2,5 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <string>
|
||||
|
||||
// Do not throw. Return empty string is case of error.
|
||||
std::string joinPath(const QString &base, const QString &name);
|
||||
|
||||
// Create a copy of s then invoke std::free on s.
|
||||
QString fromMalloc(char *s);
|
||||
|
Loading…
Reference in New Issue
Block a user