shadps4-emu / shadPS4

PS4 emulator for Windows,Linux,MacOS
https://shadps4.net/
GNU General Public License v2.0
10.92k stars 682 forks source link

*A NICE TO HAVE ADDITION* Period (.) being represented as current directory for detecting the games folder #1466

Open HelmXGaming opened 2 weeks ago

HelmXGaming commented 2 weeks ago

I don't know how C++ programming works since I use python but I tend to move files around quite frequently such as the games folder and having the ability to have . recognized as the current directory would be a nice to have. So instead of specifying a whole directory I can simply just have "./games" as the directory.

I think the code could look something like this:

#include <filesystem>
#include <string>

std::string resolvePath(const std::string& path) {
    if (path == "." || path.find("./") == 0) {
        // Get the current working directory
        std::string current_dir = std::filesystem::current_path().string();

        // If path is exactly ".", return current directory
        if (path == ".") {
            return current_dir;
        }

        // Otherwise, replace "./" with the current directory
        return current_dir + path.substr(1);
    }
    return path;  // Return original path if it doesn't start with "."
}
Hermiten commented 3 days ago

I'm not sure if it's really necessary. Anyone else have an idea ?