mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 05:19:56 +00:00
Use Path for fullName in dirlisting. Bugfixes.
Buildfixes UWP: Buildfix. headless: Buildfix. Common: Buildfix. iOS: Buildfixes. libretro: Buildfix. Qt: Buildfix.
This commit is contained in:
parent
ae06499a0c
commit
a40b1dec5f
@ -120,7 +120,7 @@ static std::vector<int> ParseCPUList(const std::string &filename) {
|
||||
std::string data;
|
||||
std::vector<int> results;
|
||||
|
||||
if (File::ReadFileToString(true, filename.c_str(), data)) {
|
||||
if (File::ReadFileToString(true, Path(filename), data)) {
|
||||
std::vector<std::string> ranges;
|
||||
SplitString(data, ',', ranges);
|
||||
for (auto range : ranges) {
|
||||
@ -372,7 +372,7 @@ void CPUInfo::Detect() {
|
||||
// This seems to be the count per core. Hopefully all cores are the same, but we counted each above.
|
||||
logical_cpu_count /= std::max(num_cores, 1);
|
||||
#elif PPSSPP_PLATFORM(LINUX)
|
||||
if (File::Exists("/sys/devices/system/cpu/present")) {
|
||||
if (File::Exists(Path("/sys/devices/system/cpu/present"))) {
|
||||
// This may not count unplugged cores, but at least it's a best guess.
|
||||
// Also, this assumes the CPU cores are heterogeneous (e.g. all cores could be active simultaneously.)
|
||||
num_cores = 0;
|
||||
|
@ -45,7 +45,7 @@ bool GetFileInfo(const Path &path, FileInfo * fileInfo) {
|
||||
}
|
||||
|
||||
// TODO: Expand relative paths?
|
||||
fileInfo->fullName = path.ToString();
|
||||
fileInfo->fullName = path;
|
||||
|
||||
#ifdef _WIN32
|
||||
auto FiletimeToStatTime = [](FILETIME ft) {
|
||||
@ -191,15 +191,7 @@ size_t GetFilesInDir(const Path &directory, std::vector<FileInfo> * files, const
|
||||
FileInfo info;
|
||||
info.name = virtualName;
|
||||
|
||||
// It's OK not to use Path /-concat here.
|
||||
std::string dir = directory.ToString();
|
||||
|
||||
// Only append a slash if there isn't one on the end.
|
||||
size_t lastSlash = dir.find_last_of("/");
|
||||
if (lastSlash != (dir.length() - 1))
|
||||
dir.append("/");
|
||||
|
||||
info.fullName = dir + virtualName;
|
||||
info.fullName = directory / virtualName;
|
||||
info.isDirectory = IsDirectory(Path(info.fullName));
|
||||
info.exists = true;
|
||||
info.size = 0;
|
||||
|
@ -13,7 +13,7 @@ namespace File {
|
||||
|
||||
struct FileInfo {
|
||||
std::string name;
|
||||
std::string fullName; // TODO: Make into Path
|
||||
Path fullName;
|
||||
bool exists = false;
|
||||
bool isDirectory = false;
|
||||
bool isWritable = false;
|
||||
|
@ -55,7 +55,7 @@ Path Path::WithExtraExtension(const std::string &ext) const {
|
||||
|
||||
Path Path::WithReplacedExtension(const std::string &oldExtension, const std::string &newExtension) const {
|
||||
if (endsWithNoCase(path_, "." + oldExtension)) {
|
||||
std::string newPath = path_.substr(path_.size() - oldExtension.size() - 1);
|
||||
std::string newPath = path_.substr(0, path_.size() - oldExtension.size() - 1);
|
||||
return Path(newPath + "." + newExtension);
|
||||
} else {
|
||||
return Path(*this);
|
||||
|
@ -83,7 +83,7 @@ bool LoadRemoteFileList(const std::string &url, bool *cancel, std::vector<File::
|
||||
|
||||
File::FileInfo info;
|
||||
info.name = item;
|
||||
info.fullName = baseURL.Relative(item).ToString();
|
||||
info.fullName = Path(baseURL.Relative(item).ToString());
|
||||
info.isDirectory = endsWith(item, "/");
|
||||
info.exists = true;
|
||||
info.size = 0;
|
||||
@ -115,7 +115,7 @@ std::vector<File::FileInfo> ApplyFilter(std::vector<File::FileInfo> files, const
|
||||
auto pred = [&](const File::FileInfo &info) {
|
||||
if (info.isDirectory || !filter)
|
||||
return false;
|
||||
std::string ext = File::GetFileExtension(info.fullName);
|
||||
std::string ext = info.fullName.GetFileExtension();
|
||||
return filters.find(ext) == filters.end();
|
||||
};
|
||||
files.erase(std::remove_if(files.begin(), files.end(), pred), files.end());
|
||||
@ -255,7 +255,7 @@ bool PathBrowser::GetListing(std::vector<File::FileInfo> &fileInfo, const char *
|
||||
if (*drive == "A:/" || *drive == "B:/")
|
||||
continue;
|
||||
File::FileInfo fake;
|
||||
fake.fullName = *drive;
|
||||
fake.fullName = Path(*drive);
|
||||
fake.name = *drive;
|
||||
fake.isDirectory = true;
|
||||
fake.exists = true;
|
||||
|
@ -113,13 +113,9 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
|
||||
for (auto diter = directories.begin(); diter != directories.end(); ++diter) {
|
||||
File::FileInfo info;
|
||||
info.name = *diter;
|
||||
info.fullName = std::string(path);
|
||||
if (info.fullName[info.fullName.size() - 1] == '/')
|
||||
info.fullName = info.fullName.substr(0, info.fullName.size() - 1);
|
||||
|
||||
// Remove the "inzip" part of the fullname.
|
||||
info.fullName = info.fullName.substr(strlen(in_zip_path_));
|
||||
info.fullName += "/" + *diter;
|
||||
info.fullName = Path(std::string(path).substr(strlen(in_zip_path_))) / *diter;
|
||||
info.exists = true;
|
||||
info.isWritable = false;
|
||||
info.isDirectory = true;
|
||||
@ -127,17 +123,14 @@ bool ZipAssetReader::GetFileListing(const char *orig_path, std::vector<File::Fil
|
||||
}
|
||||
|
||||
for (auto fiter = files.begin(); fiter != files.end(); ++fiter) {
|
||||
std::string fpath = path;
|
||||
File::FileInfo info;
|
||||
info.name = *fiter;
|
||||
info.fullName = std::string(path);
|
||||
if (info.fullName[info.fullName.size() - 1] == '/')
|
||||
info.fullName = info.fullName.substr(0, info.fullName.size() - 1);
|
||||
info.fullName = info.fullName.substr(strlen(in_zip_path_));
|
||||
info.fullName += "/" + *fiter;
|
||||
info.fullName = Path(std::string(path).substr(strlen(in_zip_path_))) / *fiter;
|
||||
info.exists = true;
|
||||
info.isWritable = false;
|
||||
info.isDirectory = false;
|
||||
std::string ext = File::GetFileExtension(info.fullName);
|
||||
std::string ext = File::GetFileExtension(info.fullName.ToString());
|
||||
if (filter) {
|
||||
if (filters.find(ext) == filters.end())
|
||||
continue;
|
||||
@ -162,7 +155,7 @@ bool ZipAssetReader::GetFileInfo(const char *path, File::FileInfo *info) {
|
||||
return false;
|
||||
}
|
||||
|
||||
info->fullName = path;
|
||||
info->fullName = Path(path);
|
||||
info->exists = true; // TODO
|
||||
info->isWritable = false;
|
||||
info->isDirectory = false; // TODO
|
||||
|
@ -56,7 +56,7 @@ void MemArena::GrabLowMemSpace(size_t size) {
|
||||
// Some platforms (like Raspberry Pi) end up flushing to disk.
|
||||
// To avoid this, we try to use /dev/shm (tmpfs) if it exists.
|
||||
fd = -1;
|
||||
if (File::Exists(tmpfs_location)) {
|
||||
if (File::Exists(Path(tmpfs_location))) {
|
||||
fd = open(tmpfs_ram_temp_file.c_str(), O_RDWR | O_CREAT, mode);
|
||||
if (fd >= 0) {
|
||||
// Great, this definitely shouldn't flush to disk.
|
||||
|
@ -827,7 +827,7 @@ void DiskCachingFileLoaderCache::GarbageCollectCacheFiles(u64 goalBytes) {
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
const std::wstring w32path = ConvertUTF8ToWString(file.fullName);
|
||||
const std::wstring w32path = file.fullName.ToWString();
|
||||
bool success = DeleteFileW(w32path.c_str()) != 0;
|
||||
#else
|
||||
bool success = unlink(file.fullName.c_str()) == 0;
|
||||
|
@ -88,18 +88,19 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
|
||||
for (size_t f = 0; f < fileInfo.size(); f++) {
|
||||
IniFile ini;
|
||||
bool success = false;
|
||||
std::string name = fileInfo[f].fullName;
|
||||
std::string path = directories[d].ToString();
|
||||
Path name = fileInfo[f].fullName;
|
||||
Path path = directories[d];
|
||||
// Hack around Android VFS path bug. really need to redesign this.
|
||||
if (name.substr(0, 7) == "assets/")
|
||||
name = name.substr(7);
|
||||
if (path.substr(0, 7) == "assets/")
|
||||
path = path.substr(7);
|
||||
if (name.ToString().substr(0, 7) == "assets/")
|
||||
name = Path(name.ToString().substr(7));
|
||||
if (path.ToString().substr(0, 7) == "assets/")
|
||||
path = Path(path.ToString().substr(7));
|
||||
|
||||
if (ini.LoadFromVFS(name) || ini.Load(fileInfo[f].fullName)) {
|
||||
if (ini.LoadFromVFS(name.ToString()) || ini.Load(fileInfo[f].fullName)) {
|
||||
success = true;
|
||||
// vsh load. meh.
|
||||
}
|
||||
|
||||
if (!success)
|
||||
continue;
|
||||
|
||||
@ -118,9 +119,9 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
|
||||
section.Get("Parent", &info.parent, "");
|
||||
section.Get("Visible", &info.visible, true);
|
||||
section.Get("Fragment", &temp, "");
|
||||
info.fragmentShaderFile = path + "/" + temp;
|
||||
info.fragmentShaderFile = path / temp;
|
||||
section.Get("Vertex", &temp, "");
|
||||
info.vertexShaderFile = path + "/" + temp;
|
||||
info.vertexShaderFile = path / temp;
|
||||
section.Get("OutputResolution", &info.outputResolution, false);
|
||||
section.Get("Upscaling", &info.isUpscalingFilter, false);
|
||||
section.Get("SSAA", &info.SSAAFilterLevel, 0);
|
||||
@ -165,7 +166,7 @@ void LoadPostShaderInfo(const std::vector<Path> &directories) {
|
||||
section.Get("Name", &info.name, section.name().c_str());
|
||||
section.Get("Compute", &temp, "");
|
||||
section.Get("MaxScale", &info.maxScale, 255);
|
||||
info.computeShaderFile = path + "/" + temp;
|
||||
info.computeShaderFile = path / temp;
|
||||
|
||||
appendTextureShader(info);
|
||||
}
|
||||
|
@ -25,13 +25,13 @@
|
||||
#include "Common/Data/Format/IniFile.h"
|
||||
|
||||
struct ShaderInfo {
|
||||
std::string iniFile; // which ini file was this definition in? So we can write settings back later
|
||||
Path iniFile; // which ini file was this definition in? So we can write settings back later
|
||||
std::string section; // ini file section. This is saved.
|
||||
std::string name; // Fancy display name.
|
||||
std::string parent; // Parent shader ini section name.
|
||||
|
||||
std::string fragmentShaderFile;
|
||||
std::string vertexShaderFile;
|
||||
Path fragmentShaderFile;
|
||||
Path vertexShaderFile;
|
||||
|
||||
// Show this shader in lists (i.e. not just for chaining.)
|
||||
bool visible;
|
||||
@ -65,11 +65,11 @@ struct ShaderInfo {
|
||||
};
|
||||
|
||||
struct TextureShaderInfo {
|
||||
std::string iniFile;
|
||||
Path iniFile;
|
||||
std::string section;
|
||||
std::string name;
|
||||
|
||||
std::string computeShaderFile;
|
||||
Path computeShaderFile;
|
||||
int maxScale;
|
||||
|
||||
bool operator == (const std::string &other) {
|
||||
|
@ -197,11 +197,13 @@ void PresentationCommon::CalculatePostShaderUniforms(int bufferWidth, int buffer
|
||||
uniforms->setting[3] = g_Config.mPostShaderSetting[shaderInfo->section + "SettingValue4"];
|
||||
}
|
||||
|
||||
static std::string ReadShaderSrc(const std::string &filename) {
|
||||
static std::string ReadShaderSrc(const Path &filename) {
|
||||
size_t sz = 0;
|
||||
// TODO(scoped): VFS paths not handled well.
|
||||
char *data = (char *)VFSReadFile(filename.c_str(), &sz);
|
||||
if (!data)
|
||||
if (!data) {
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string src(data, sz);
|
||||
delete[] data;
|
||||
|
@ -375,7 +375,7 @@ void TextureCacheVulkan::NotifyConfigChanged() {
|
||||
CompileScalingShader();
|
||||
}
|
||||
|
||||
static std::string ReadShaderSrc(const std::string &filename) {
|
||||
static std::string ReadShaderSrc(const Path &filename) {
|
||||
size_t sz = 0;
|
||||
char *data = (char *)VFSReadFile(filename.c_str(), &sz);
|
||||
if (!data)
|
||||
|
@ -18,12 +18,10 @@
|
||||
#include <string>
|
||||
#include "Qt/QtHost.h"
|
||||
|
||||
std::string QtHost::SymbolMapFilename(std::string currentFilename) {
|
||||
size_t dot = currentFilename.rfind('.');
|
||||
if (dot == std::string::npos)
|
||||
currentFilename.append(".map");
|
||||
Path QtHost::SymbolMapFilename(Path currentFilename) {
|
||||
std::string ext = currentFilename.GetFileExtension();
|
||||
if (ext == "")
|
||||
return currentFilename.WithExtraExtension("map");
|
||||
else
|
||||
currentFilename.replace(dot, -1, ".map");
|
||||
|
||||
return currentFilename;
|
||||
return currentFilename.WithReplacedExtension(ext, "map");
|
||||
}
|
||||
|
@ -65,14 +65,14 @@ public:
|
||||
}
|
||||
virtual bool AttemptLoadSymbolMap() override {
|
||||
auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
|
||||
return g_symbolMap->LoadSymbolMap(fn.c_str());
|
||||
return g_symbolMap->LoadSymbolMap(fn);
|
||||
}
|
||||
|
||||
virtual void NotifySymbolMapUpdated() override { g_symbolMap->SortSymbols(); }
|
||||
|
||||
void PrepareShutdown() {
|
||||
auto fn = SymbolMapFilename(PSP_CoreParameter().fileToStart);
|
||||
g_symbolMap->SaveSymbolMap(fn.c_str());
|
||||
g_symbolMap->SaveSymbolMap(fn);
|
||||
}
|
||||
void SetWindowTitle(const char *message) override {
|
||||
std::string title = std::string("PPSSPP ") + PPSSPP_GIT_VERSION;
|
||||
@ -95,6 +95,6 @@ public:
|
||||
void NotifySwitchUMDUpdated() override {}
|
||||
|
||||
private:
|
||||
std::string SymbolMapFilename(std::string currentFilename);
|
||||
Path SymbolMapFilename(Path currentFilename);
|
||||
MainWindow* mainWindow;
|
||||
};
|
||||
|
@ -156,13 +156,13 @@ void SaveStateActionFinished(SaveState::Status status, const std::string &messag
|
||||
|
||||
void MainWindow::qlstateAct()
|
||||
{
|
||||
std::string gamePath = PSP_CoreParameter().fileToStart;
|
||||
std::string gamePath = PSP_CoreParameter().fileToStart.ToString();
|
||||
SaveState::LoadSlot(gamePath, 0, SaveStateActionFinished, this);
|
||||
}
|
||||
|
||||
void MainWindow::qsstateAct()
|
||||
{
|
||||
std::string gamePath = PSP_CoreParameter().fileToStart;
|
||||
std::string gamePath = PSP_CoreParameter().fileToStart.ToString();
|
||||
SaveState::SaveSlot(gamePath, 0, SaveStateActionFinished, this);
|
||||
}
|
||||
|
||||
@ -177,7 +177,7 @@ void MainWindow::lstateAct()
|
||||
if (dialog.exec())
|
||||
{
|
||||
QStringList fileNames = dialog.selectedFiles();
|
||||
SaveState::Load(fileNames[0].toStdString(), -1, SaveStateActionFinished, this);
|
||||
SaveState::Load(Path(fileNames[0].toStdString()), -1, SaveStateActionFinished, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ void MainWindow::sstateAct()
|
||||
if (dialog.exec())
|
||||
{
|
||||
QStringList fileNames = dialog.selectedFiles();
|
||||
SaveState::Save(fileNames[0].toStdString(), -1, SaveStateActionFinished, this);
|
||||
SaveState::Save(Path(fileNames[0].toStdString()), -1, SaveStateActionFinished, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ void MainWindow::lmapAct()
|
||||
if (fileNames.count() > 0)
|
||||
{
|
||||
QString fileName = QFileInfo(fileNames[0]).absoluteFilePath();
|
||||
g_symbolMap->LoadSymbolMap(fileName.toStdString().c_str());
|
||||
g_symbolMap->LoadSymbolMap(Path(fileName.toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -292,7 +292,7 @@ void MainWindow::smapAct()
|
||||
if (dialog.exec())
|
||||
{
|
||||
fileNames = dialog.selectedFiles();
|
||||
g_symbolMap->SaveSymbolMap(fileNames[0].toStdString().c_str());
|
||||
g_symbolMap->SaveSymbolMap(Path(fileNames[0].toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +311,7 @@ void MainWindow::lsymAct()
|
||||
if (fileNames.count() > 0)
|
||||
{
|
||||
QString fileName = QFileInfo(fileNames[0]).absoluteFilePath();
|
||||
g_symbolMap->LoadNocashSym(fileName.toStdString().c_str());
|
||||
g_symbolMap->LoadNocashSym(Path(fileName.toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ void MainWindow::ssymAct()
|
||||
if (dialog.exec())
|
||||
{
|
||||
fileNames = dialog.selectedFiles();
|
||||
g_symbolMap->SaveNocashSym(fileNames[0].toStdString().c_str());
|
||||
g_symbolMap->SaveNocashSym(Path(fileNames[0].toStdString()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ static bool IsTempPath(const Path &str) {
|
||||
|
||||
class GameButton : public UI::Clickable {
|
||||
public:
|
||||
GameButton(const std::string &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
|
||||
GameButton(const Path &gamePath, bool gridStyle, UI::LayoutParams *layoutParams = 0)
|
||||
: UI::Clickable(layoutParams), gridStyle_(gridStyle), gamePath_(gamePath) {}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
@ -418,14 +418,14 @@ std::string GameButton::DescribeText() const {
|
||||
|
||||
class DirButton : public UI::Button {
|
||||
public:
|
||||
DirButton(const std::string &path, bool gridStyle, UI::LayoutParams *layoutParams)
|
||||
: UI::Button(path, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {}
|
||||
DirButton(const std::string &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0)
|
||||
DirButton(const Path &path, bool gridStyle, UI::LayoutParams *layoutParams)
|
||||
: UI::Button(path.ToString(), layoutParams), path_(path), gridStyle_(gridStyle), absolute_(false) {}
|
||||
DirButton(const Path &path, const std::string &text, bool gridStyle, UI::LayoutParams *layoutParams = 0)
|
||||
: UI::Button(text, layoutParams), path_(path), gridStyle_(gridStyle), absolute_(true) {}
|
||||
|
||||
virtual void Draw(UIContext &dc);
|
||||
|
||||
const std::string GetPath() const {
|
||||
const Path &GetPath() const {
|
||||
return path_;
|
||||
}
|
||||
|
||||
@ -434,7 +434,7 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
std::string path_;
|
||||
Path path_;
|
||||
bool gridStyle_;
|
||||
bool absolute_;
|
||||
};
|
||||
@ -565,9 +565,12 @@ bool GameBrowser::DisplayTopBar() {
|
||||
return path_.GetPath() != "!RECENT";
|
||||
}
|
||||
|
||||
bool GameBrowser::HasSpecialFiles(std::vector<std::string> &filenames) {
|
||||
bool GameBrowser::HasSpecialFiles(std::vector<Path> &filenames) {
|
||||
if (path_.GetPath() == "!RECENT") {
|
||||
filenames = g_Config.recentIsos;
|
||||
filenames.clear();
|
||||
for (auto &str : g_Config.recentIsos) {
|
||||
filenames.push_back(Path(str));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -707,7 +710,7 @@ void GameBrowser::Refresh() {
|
||||
|
||||
listingPending_ = !path_.IsListingReady();
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
std::vector<Path> filenames;
|
||||
if (HasSpecialFiles(filenames)) {
|
||||
for (size_t i = 0; i < filenames.size(); i++) {
|
||||
gameButtons.push_back(new GameButton(filenames[i], *gridStyle_, new UI::LinearLayoutParams(*gridStyle_ == true ? UI::WRAP_CONTENT : UI::FILL_PARENT, UI::WRAP_CONTENT)));
|
||||
@ -757,14 +760,15 @@ void GameBrowser::Refresh() {
|
||||
|
||||
if (browseFlags_ & BrowseFlags::NAVIGATE) {
|
||||
if (path_.CanNavigateUp()) {
|
||||
gameList_->Add(new DirButton("..", *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
|
||||
gameList_->Add(new DirButton(Path(std::string("..")), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
|
||||
OnClick.Handle(this, &GameBrowser::NavigateClick);
|
||||
}
|
||||
|
||||
// Add any pinned paths before other directories.
|
||||
auto pinnedPaths = GetPinnedPaths();
|
||||
for (auto it = pinnedPaths.begin(), end = pinnedPaths.end(); it != end; ++it) {
|
||||
gameList_->Add(new DirButton(*it, GetBaseName(*it), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
|
||||
// TODO(scoped): Hmm
|
||||
gameList_->Add(new DirButton(*it, GetBaseName((*it).ToString()), *gridStyle_, new UI::LinearLayoutParams(UI::FILL_PARENT, UI::FILL_PARENT)))->
|
||||
OnClick.Handle(this, &GameBrowser::NavigateClick);
|
||||
}
|
||||
}
|
||||
@ -814,7 +818,7 @@ bool GameBrowser::IsCurrentPathPinned() {
|
||||
return std::find(paths.begin(), paths.end(), File::ResolvePath(path_.GetPath())) != paths.end();
|
||||
}
|
||||
|
||||
const std::vector<std::string> GameBrowser::GetPinnedPaths() {
|
||||
const std::vector<Path> GameBrowser::GetPinnedPaths() {
|
||||
#ifndef _WIN32
|
||||
static const std::string sepChars = "/";
|
||||
#else
|
||||
@ -823,7 +827,7 @@ const std::vector<std::string> GameBrowser::GetPinnedPaths() {
|
||||
|
||||
const std::string currentPath = File::ResolvePath(path_.GetPath());
|
||||
const std::vector<std::string> paths = g_Config.vPinnedPaths;
|
||||
std::vector<std::string> results;
|
||||
std::vector<Path> results;
|
||||
for (size_t i = 0; i < paths.size(); ++i) {
|
||||
// We want to exclude the current path, and its direct children.
|
||||
if (paths[i] == currentPath) {
|
||||
@ -837,7 +841,7 @@ const std::vector<std::string> GameBrowser::GetPinnedPaths() {
|
||||
}
|
||||
}
|
||||
|
||||
results.push_back(paths[i]);
|
||||
results.push_back(Path(paths[i]));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@ -891,7 +895,7 @@ UI::EventReturn GameBrowser::GameButtonHighlight(UI::EventParams &e) {
|
||||
|
||||
UI::EventReturn GameBrowser::NavigateClick(UI::EventParams &e) {
|
||||
DirButton *button = static_cast<DirButton *>(e.v);
|
||||
std::string text = button->GetPath();
|
||||
std::string text = button->GetPath().ToString();
|
||||
if (button->PathAbsolute()) {
|
||||
path_.SetPath(text);
|
||||
} else {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "Common/File/Path.h"
|
||||
#include "Common/UI/UIScreen.h"
|
||||
#include "Common/UI/ViewGroup.h"
|
||||
#include "UI/MiscScreens.h"
|
||||
@ -55,13 +56,13 @@ public:
|
||||
|
||||
protected:
|
||||
virtual bool DisplayTopBar();
|
||||
virtual bool HasSpecialFiles(std::vector<std::string> &filenames);
|
||||
virtual bool HasSpecialFiles(std::vector<Path> &filenames);
|
||||
|
||||
void Refresh();
|
||||
|
||||
private:
|
||||
bool IsCurrentPathPinned();
|
||||
const std::vector<std::string> GetPinnedPaths();
|
||||
const std::vector<Path> GetPinnedPaths();
|
||||
const std::string GetBaseName(const std::string &path);
|
||||
|
||||
UI::EventReturn GameButtonClick(UI::EventParams &e);
|
||||
|
@ -511,11 +511,11 @@ void NativeInit(int argc, const char *argv[], const char *savegame_dir, const ch
|
||||
}
|
||||
}
|
||||
#elif PPSSPP_PLATFORM(IOS)
|
||||
g_Config.memStickDirectory = user_data_path;
|
||||
g_Config.flash0Directory = std::string(external_dir) + "/flash0/";
|
||||
g_Config.memStickDirectory = Path(user_data_path);
|
||||
g_Config.flash0Directory = Path(std::string(external_dir)) / "flash0";
|
||||
#elif PPSSPP_PLATFORM(SWITCH)
|
||||
g_Config.memStickDirectory = g_Config.internalDataDirectory + "config/ppsspp/";
|
||||
g_Config.flash0Directory = g_Config.internalDataDirectory + "assets/flash0/";
|
||||
g_Config.memStickDirectory = Path(g_Config.internalDataDirectory) / "config/ppsspp";
|
||||
g_Config.flash0Directory = Path(g_Config.internalDataDirectory) / "assets/flash0";
|
||||
#elif !PPSSPP_PLATFORM(WINDOWS)
|
||||
std::string config;
|
||||
if (getenv("XDG_CONFIG_HOME") != NULL)
|
||||
|
@ -243,7 +243,7 @@ bool RemoteISOConnectScreen::FindServer(std::string &resultHost, int &resultPort
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool LoadGameList(const std::string &url, std::vector<std::string> &games) {
|
||||
static bool LoadGameList(const std::string &url, std::vector<Path> &games) {
|
||||
PathBrowser browser(url);
|
||||
std::vector<File::FileInfo> files;
|
||||
browser.GetListing(files, "iso:cso:pbp:elf:prx:ppdmp:", &scanCancelled);
|
||||
@ -498,7 +498,7 @@ void RemoteISOConnectScreen::ExecuteLoad() {
|
||||
|
||||
class RemoteGameBrowser : public GameBrowser {
|
||||
public:
|
||||
RemoteGameBrowser(const std::string &url, const std::vector<std::string> &games, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager* screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr)
|
||||
RemoteGameBrowser(const std::string &url, const std::vector<Path> &games, BrowseFlags browseFlags, bool *gridStyle_, ScreenManager* screenManager, std::string lastText, std::string lastLink, UI::LayoutParams *layoutParams = nullptr)
|
||||
: GameBrowser(url, browseFlags, gridStyle_, screenManager, lastText, lastLink, layoutParams) {
|
||||
games_ = games;
|
||||
Refresh();
|
||||
@ -509,18 +509,18 @@ protected:
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HasSpecialFiles(std::vector<std::string> &filenames) override;
|
||||
bool HasSpecialFiles(std::vector<Path> &filenames) override;
|
||||
|
||||
std::string url_;
|
||||
std::vector<std::string> games_;
|
||||
std::vector<Path> games_;
|
||||
};
|
||||
|
||||
bool RemoteGameBrowser::HasSpecialFiles(std::vector<std::string> &filenames) {
|
||||
bool RemoteGameBrowser::HasSpecialFiles(std::vector<Path> &filenames) {
|
||||
filenames = games_;
|
||||
return true;
|
||||
}
|
||||
|
||||
RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector<std::string> &games)
|
||||
RemoteISOBrowseScreen::RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games)
|
||||
: url_(url), games_(games) {
|
||||
}
|
||||
|
||||
|
@ -76,18 +76,18 @@ protected:
|
||||
std::string host_;
|
||||
int port_;
|
||||
std::string url_;
|
||||
std::vector<std::string> games_;
|
||||
std::vector<Path> games_;
|
||||
};
|
||||
|
||||
class RemoteISOBrowseScreen : public MainScreen {
|
||||
public:
|
||||
RemoteISOBrowseScreen(const std::string &url, const std::vector<std::string> &games);
|
||||
RemoteISOBrowseScreen(const std::string &url, const std::vector<Path> &games);
|
||||
|
||||
protected:
|
||||
void CreateViews() override;
|
||||
|
||||
std::string url_;
|
||||
std::vector<std::string> games_;
|
||||
std::vector<Path> games_;
|
||||
};
|
||||
|
||||
class RemoteISOSettingsScreen : public UIDialogScreenWithBackground {
|
||||
|
@ -170,9 +170,9 @@ void SortedLinearLayout::Update() {
|
||||
|
||||
class SavedataButton : public UI::Clickable {
|
||||
public:
|
||||
SavedataButton(const std::string &gamePath, UI::LayoutParams *layoutParams = 0)
|
||||
SavedataButton(const Path &gamePath, UI::LayoutParams *layoutParams = 0)
|
||||
: UI::Clickable(layoutParams), savePath_(gamePath) {
|
||||
SetTag(gamePath);
|
||||
SetTag(gamePath.ToString());
|
||||
}
|
||||
|
||||
void Draw(UIContext &dc) override;
|
||||
|
@ -97,9 +97,7 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
|
||||
|
||||
std::wstring memstickFolderW = ApplicationData::Current->LocalFolder->Path->Data();
|
||||
|
||||
g_Config.memStickDirectory = ReplaceAll(ConvertWStringToUTF8(memstickFolderW), "\\", "/");
|
||||
if (g_Config.memStickDirectory.back() != '/')
|
||||
g_Config.memStickDirectory += "/";
|
||||
g_Config.memStickDirectory = Path(ReplaceAll(ConvertWStringToUTF8(memstickFolderW), "\\", "/"));
|
||||
|
||||
// On Win32 it makes more sense to initialize the system directories here
|
||||
// because the next place it was called was in the EmuThread, and it's too late by then.
|
||||
@ -109,8 +107,8 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(App ^app, const std::shared_ptr<DX::DeviceResourc
|
||||
|
||||
// Load config up here, because those changes below would be overwritten
|
||||
// if it's not loaded here first.
|
||||
g_Config.AddSearchGetSysDirectory(DIRECTORY_SYSTEM);
|
||||
g_Config.SetDefaultGetSysDirectory(DIRECTORY_SYSTEM);
|
||||
g_Config.AddSearchPath(GetSysDirectory(DIRECTORY_SYSTEM));
|
||||
g_Config.SetDefaultPath(GetSysDirectory(DIRECTORY_SYSTEM));
|
||||
g_Config.Load(configFilename, controlsConfigFilename);
|
||||
|
||||
bool debugLogLevel = false;
|
||||
|
@ -121,44 +121,36 @@ void UWPHost::BootDone() {
|
||||
Core_EnableStepping(false);
|
||||
}
|
||||
|
||||
static std::string SymbolMapFilename(const char *currentFilename, char* ext) {
|
||||
static Path SymbolMapFilename(const char *currentFilename, const char *ext) {
|
||||
File::FileInfo info;
|
||||
|
||||
std::string result = currentFilename;
|
||||
|
||||
// can't fail, definitely exists if it gets this far
|
||||
File::GetFileInfo(currentFilename, &info);
|
||||
File::GetFileInfo(Path(currentFilename), &info);
|
||||
if (info.isDirectory) {
|
||||
#ifdef _WIN32
|
||||
char* slash = "\\";
|
||||
#else
|
||||
char* slash = "/";
|
||||
#endif
|
||||
if (!endsWith(result, slash))
|
||||
result += slash;
|
||||
|
||||
return result + ".ppsspp-symbols" + ext;
|
||||
return Path(result) / (std::string(".ppsspp-symbols") + ext);
|
||||
} else {
|
||||
size_t dot = result.rfind('.');
|
||||
if (dot == result.npos)
|
||||
return result + ext;
|
||||
return Path(result + ext);
|
||||
|
||||
result.replace(dot, result.npos, ext);
|
||||
return result;
|
||||
return Path(result);
|
||||
}
|
||||
}
|
||||
|
||||
bool UWPHost::AttemptLoadSymbolMap() {
|
||||
bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap").c_str());
|
||||
bool result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap"));
|
||||
// Load the old-style map file.
|
||||
if (!result1)
|
||||
result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".map").c_str());
|
||||
bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".sym").c_str());
|
||||
result1 = g_symbolMap->LoadSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".map"));
|
||||
bool result2 = g_symbolMap->LoadNocashSym(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".sym"));
|
||||
return result1 || result2;
|
||||
}
|
||||
|
||||
void UWPHost::SaveSymbolMap() {
|
||||
g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap").c_str());
|
||||
g_symbolMap->SaveSymbolMap(SymbolMapFilename(PSP_CoreParameter().fileToStart.c_str(), ".ppmap"));
|
||||
}
|
||||
|
||||
void UWPHost::NotifySymbolMapUpdated() {
|
||||
|
@ -59,7 +59,7 @@ static std::string TrimNewlines(const std::string &s) {
|
||||
|
||||
bool TestsAvailable() {
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
Path testDirectory = Path(g_Config.flash0Directory) + "../";
|
||||
Path testDirectory = g_Config.flash0Directory / "..";
|
||||
#else
|
||||
Path testDirectory = g_Config.memStickDirectory;
|
||||
#endif
|
||||
@ -74,7 +74,7 @@ bool RunTests() {
|
||||
std::string output;
|
||||
|
||||
#if PPSSPP_PLATFORM(IOS)
|
||||
std::string baseDirectory = g_Config.flash0Directory + "../";
|
||||
Path baseDirectory = g_Config.flash0Directory / "..";
|
||||
#else
|
||||
Path baseDirectory = g_Config.memStickDirectory;
|
||||
// Hack to easily run the tests on Windows from the submodule
|
||||
|
@ -408,7 +408,7 @@ int main(int argc, const char* argv[])
|
||||
#endif
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(_WIN32)
|
||||
g_Config.memStickDirectory = std::string(getenv("HOME")) + "/.ppsspp/";
|
||||
g_Config.memStickDirectory = Path(std::string(getenv("HOME"))) / ".ppsspp";
|
||||
#endif
|
||||
|
||||
// Try to find the flash0 directory. Often this is from a subdirectory.
|
||||
|
@ -632,8 +632,8 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
|
||||
g_Config.currentDirectory = retro_base_dir;
|
||||
g_Config.externalDirectory = retro_base_dir;
|
||||
g_Config.memStickDirectory = retro_save_dir;
|
||||
g_Config.flash0Directory = retro_base_dir + "flash0" DIR_SEP;
|
||||
g_Config.memStickDirectory = Path(retro_save_dir);
|
||||
g_Config.flash0Directory = Path(retro_base_dir) / "flash0";
|
||||
g_Config.internalDataDirectory = retro_base_dir;
|
||||
|
||||
VFSRegister("", new DirectoryAssetReader(retro_base_dir.c_str()));
|
||||
@ -649,7 +649,7 @@ bool retro_load_game(const struct retro_game_info *game)
|
||||
|
||||
CoreParameter coreParam = {};
|
||||
coreParam.enableSound = true;
|
||||
coreParam.fileToStart = std::string(game->path);
|
||||
coreParam.fileToStart = Path(std::string(game->path));
|
||||
coreParam.mountIso.clear();
|
||||
coreParam.startBreak = false;
|
||||
coreParam.printfEmuLog = true;
|
||||
|
Loading…
Reference in New Issue
Block a user