Skip to content

Commit

Permalink
Loaders: Rename Path() to GetPath().
Browse files Browse the repository at this point in the history
Path is going to be a struct name.
  • Loading branch information
hrydgard authored and unknownbrackets committed May 10, 2021
1 parent 96c109e commit 9480b66
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions Core/ELF/PBPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@

PBPReader::PBPReader(FileLoader *fileLoader) : file_(nullptr), header_(), isELF_(false) {
if (!fileLoader->Exists()) {
ERROR_LOG(LOADER, "Failed to open PBP file %s", fileLoader->Path().c_str());
ERROR_LOG(LOADER, "Failed to open PBP file %s", fileLoader->GetPath().c_str());
return;
}

fileSize_ = (size_t)fileLoader->FileSize();
if (fileLoader->ReadAt(0, sizeof(header_), (u8 *)&header_) != sizeof(header_)) {
ERROR_LOG(LOADER, "PBP is too small to be valid: %s", fileLoader->Path().c_str());
ERROR_LOG(LOADER, "PBP is too small to be valid: %s", fileLoader->GetPath().c_str());
return;
}
if (memcmp(header_.magic, "\0PBP", 4) != 0) {
if (memcmp(header_.magic, "\nFLE", 4) != 0) {
VERBOSE_LOG(LOADER, "%s: File actually an ELF, not a PBP", fileLoader->Path().c_str());
VERBOSE_LOG(LOADER, "%s: File actually an ELF, not a PBP", fileLoader->GetPath().c_str());
isELF_ = true;
} else {
ERROR_LOG(LOADER, "Magic number in %s indicated no PBP: %s", fileLoader->Path().c_str(), header_.magic);
ERROR_LOG(LOADER, "Magic number in %s indicated no PBP: %s", fileLoader->GetPath().c_str(), header_.magic);
}
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Core/FileLoaders/DiskCachingFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ std::vector<std::string> DiskCachingFileLoader::GetCachedPathsInUse() {
void DiskCachingFileLoader::InitCache() {
std::lock_guard<std::mutex> guard(cachesMutex_);

std::string path = ProxiedFileLoader::Path();
std::string path = ProxiedFileLoader::GetPath();
auto &entry = caches_[path];
if (!entry) {
entry = new DiskCachingFileLoaderCache(path, filesize_);
Expand All @@ -149,7 +149,7 @@ void DiskCachingFileLoader::ShutdownCache() {
if (cache_->Release()) {
// If it ran out of counts, delete it.
delete cache_;
caches_.erase(ProxiedFileLoader::Path());
caches_.erase(ProxiedFileLoader::GetPath());
}
cache_ = nullptr;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/HTTPFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ s64 HTTPFileLoader::FileSize() {
return filesize_;
}

std::string HTTPFileLoader::Path() const {
std::string HTTPFileLoader::GetPath() const {
return filename_;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/HTTPFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class HTTPFileLoader : public FileLoader {
virtual bool ExistsFast() override;
virtual bool IsDirectory() override;
virtual s64 FileSize() override;
virtual std::string Path() const override;
virtual std::string GetPath() const override;

virtual size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override {
return ReadAt(absolutePos, bytes * count, data, flags) / bytes;
Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/LocalFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ s64 LocalFileLoader::FileSize() {
return filesize_;
}

std::string LocalFileLoader::Path() const {
std::string LocalFileLoader::GetPath() const {
return filename_;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/LocalFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LocalFileLoader : public FileLoader {
virtual bool Exists() override;
virtual bool IsDirectory() override;
virtual s64 FileSize() override;
virtual std::string Path() const override;
virtual std::string GetPath() const override;
virtual size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion Core/FileSystems/BlobFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ bool BlobFileSystem::RemoveFile(const std::string &filename) {
}

bool BlobFileSystem::GetHostPath(const std::string &inpath, std::string &outpath) {
outpath = fileLoader_->Path();
outpath = fileLoader_->GetPath();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion Core/FileSystems/BlockDevices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ CISOFileBlockDevice::CISOFileBlockDevice(FileLoader *fileLoader)
u64 expectedFileSize = lastIndexPos << indexShift;
if (expectedFileSize > fileSize) {
ERROR_LOG(LOADER, "Expected CSO to at least be %lld bytes, but file is %lld bytes. File: '%s'",
expectedFileSize, fileSize, fileLoader->Path().c_str());
expectedFileSize, fileSize, fileLoader->GetPath().c_str());
NotifyReadError();
}
}
Expand Down
18 changes: 9 additions & 9 deletions Core/Loaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
ERROR_LOG(LOADER, "Invalid fileLoader");
return IdentifiedFileType::ERROR_IDENTIFYING;
}
if (fileLoader->Path().size() == 0) {
ERROR_LOG(LOADER, "Invalid filename %s", fileLoader->Path().c_str());
if (fileLoader->GetPath().size() == 0) {
ERROR_LOG(LOADER, "Invalid filename %s", fileLoader->GetPath().c_str());
return IdentifiedFileType::ERROR_IDENTIFYING;
}

Expand Down Expand Up @@ -101,7 +101,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {

// First, check if it's a directory with an EBOOT.PBP in it.
if (fileLoader->IsDirectory()) {
std::string filename = fileLoader->Path();
std::string filename = fileLoader->GetPath();
if (filename.size() > 4) {
// Check for existence of EBOOT.PBP, as required for "Directory games".
if (File::Exists((filename + "/EBOOT.PBP").c_str())) {
Expand Down Expand Up @@ -142,7 +142,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
}

if (id == 'FLE\x7F') {
std::string filename = fileLoader->Path();
std::string filename = fileLoader->GetPath();
// There are a few elfs misnamed as pbp (like Trig Wars), accept that.
if (!strcasecmp(extension.c_str(), ".plf") || strstr(filename.c_str(),"BOOT.BIN") ||
!strcasecmp(extension.c_str(), ".elf") || !strcasecmp(extension.c_str(), ".prx") ||
Expand Down Expand Up @@ -177,7 +177,7 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {

// Let's check if we got pointed to a PBP within such a directory.
// If so we just move up and return the directory itself as the game.
std::string path = File::GetDir(fileLoader->Path());
std::string path = File::GetDir(fileLoader->GetPath());
// If loading from memstick...
size_t pos = path.find("/PSP/GAME/");
if (pos != std::string::npos) {
Expand Down Expand Up @@ -207,8 +207,8 @@ IdentifiedFileType Identify_File(FileLoader *fileLoader) {
FileLoader *ResolveFileLoaderTarget(FileLoader *fileLoader) {
IdentifiedFileType type = Identify_File(fileLoader);
if (type == IdentifiedFileType::PSP_PBP_DIRECTORY) {
const std::string ebootFilename = ResolvePBPFile(fileLoader->Path());
if (ebootFilename != fileLoader->Path()) {
const std::string ebootFilename = ResolvePBPFile(fileLoader->GetPath());
if (ebootFilename != fileLoader->GetPath()) {
// Switch fileLoader to the actual EBOOT.
delete fileLoader;
fileLoader = ConstructFileLoader(ebootFilename);
Expand Down Expand Up @@ -262,7 +262,7 @@ bool LoadFile(FileLoader **fileLoaderPtr, std::string *error_string) {
coreState = CORE_BOOT_ERROR;
return false;
}
std::string path = fileLoader->Path();
std::string path = fileLoader->GetPath();
size_t pos = path.find("/PSP/GAME/");
if (pos != std::string::npos) {
path = ResolvePBPDirectory(path);
Expand Down Expand Up @@ -369,7 +369,7 @@ bool UmdReplace(std::string filepath, std::string &error) {

if (!loadedFile->Exists()) {
delete loadedFile;
error = loadedFile->Path() + " doesn't exist";
error = loadedFile->GetPath() + " doesn't exist";
return false;
}
UpdateLoadedFile(loadedFile);
Expand Down
8 changes: 4 additions & 4 deletions Core/Loaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class FileLoader {
}
virtual bool IsDirectory() = 0;
virtual s64 FileSize() = 0;
virtual std::string Path() const = 0;
virtual std::string GetPath() const = 0;
virtual std::string Extension() {
const std::string filename = Path();
const std::string filename = GetPath();
size_t pos = filename.find_last_of('.');
if (pos == filename.npos) {
return "";
Expand Down Expand Up @@ -121,8 +121,8 @@ class ProxiedFileLoader : public FileLoader {
s64 FileSize() override {
return backend_->FileSize();
}
std::string Path() const override {
return backend_->Path();
std::string GetPath() const override {
return backend_->GetPath();
}
void Cancel() override {
backend_->Cancel();
Expand Down
6 changes: 3 additions & 3 deletions Core/PSPLoaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ void InitMemoryForGameISO(FileLoader *fileLoader) {
IFileSystem *blockSystem = nullptr;

if (fileLoader->IsDirectory()) {
fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->Path());
fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->GetPath());
blockSystem = fileSystem;
} else {
auto bd = constructBlockDevice(fileLoader);
Expand Down Expand Up @@ -152,7 +152,7 @@ bool ReInitMemoryForGameISO(FileLoader *fileLoader) {
IFileSystem *blockSystem = nullptr;

if (fileLoader->IsDirectory()) {
fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->Path());
fileSystem = new VirtualDiscFileSystem(&pspFileSystem, fileLoader->GetPath());
blockSystem = fileSystem;
} else {
auto bd = constructBlockDevice(fileLoader);
Expand Down Expand Up @@ -371,7 +371,7 @@ bool Load_PSP_ELF_PBP(FileLoader *fileLoader, std::string *error_string) {
}
}

std::string full_path = fileLoader->Path();
std::string full_path = fileLoader->GetPath();
std::string path, file, extension;
SplitPath(ReplaceAll(full_path, "\\", "/"), &path, &file, &extension);

Expand Down
2 changes: 1 addition & 1 deletion UI/GameInfoCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ class GameInfoWorkItem : public PrioritizedWorkQueueItem {
if (pbp.IsELF()) {
goto handleELF;
}
ERROR_LOG(LOADER, "invalid pbp %s\n", pbpLoader->Path().c_str());
ERROR_LOG(LOADER, "invalid pbp %s\n", pbpLoader->GetPath().c_str());
info_->pending = false;
info_->working = false;
return;
Expand Down
2 changes: 1 addition & 1 deletion UWP/StorageFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ s64 StorageFileLoader::FileSize() {
return size_;
}

std::string StorageFileLoader::Path() const {
std::string StorageFileLoader::GetPath() const {
return path_;
}

Expand Down
2 changes: 1 addition & 1 deletion UWP/StorageFileLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class StorageFileLoader : public FileLoader {

bool IsDirectory() override;
s64 FileSize() override;
std::string Path() const override;
std::string GetPath() const override;
std::string Extension() override;

size_t ReadAt(s64 absolutePos, size_t bytes, size_t count, void *data, Flags flags = Flags::NONE) override;
Expand Down
2 changes: 1 addition & 1 deletion UWP/StorageFolderBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class StorageFolderBrowser {
StorageFolderBrowser(Windows::Storage::StorageFolder ^folder);
~StorageFolderBrowser();

std::string Path() const {
std::string GetPath() const {
return path_;
}

Expand Down

0 comments on commit 9480b66

Please sign in to comment.