mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-14 13:45:59 +00:00
added createdDefaultUser
This commit is contained in:
parent
7b0d6c4bf8
commit
32fcd80a66
4 changed files with 26 additions and 7 deletions
|
@ -14,8 +14,8 @@ user_account::user_account(const std::string& user_id) {
|
|||
// Setting userId.
|
||||
m_user_id = user_id;
|
||||
|
||||
m_user_dir = Common::FS::GetUserPathString(Common::FS::PathType::HomeDir) + "/" +
|
||||
Config::getDefaultUserId() + "/";
|
||||
m_user_dir =
|
||||
Common::FS::GetUserPathString(Common::FS::PathType::HomeDir) + "/" + m_user_id + "/";
|
||||
|
||||
Common::FS::IOFile userfile(m_user_dir + "localuser.json", Common::FS::FileAccessMode::Read);
|
||||
if (userfile.IsOpen()) {
|
||||
|
@ -40,3 +40,21 @@ std::map<u32, user_account> user_account::GetUserAccounts(const std::string& bas
|
|||
|
||||
return user_list;
|
||||
}
|
||||
|
||||
void user_account::createdDefaultUser() {
|
||||
const auto& default_user_dir =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::HomeDir) / Config::getDefaultUserId();
|
||||
if (!std::filesystem::exists(default_user_dir)) {
|
||||
std::filesystem::create_directory(default_user_dir);
|
||||
Common::FS::IOFile userfile(default_user_dir / "localuser.json",
|
||||
Common::FS::FileAccessMode::Write);
|
||||
nlohmann::json jsonfile;
|
||||
|
||||
// Assign values
|
||||
jsonfile["username"] = "shadps4";
|
||||
|
||||
std::string jsonStr = jsonfile.dump(4);
|
||||
userfile.WriteString(jsonStr);
|
||||
userfile.Close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ public:
|
|||
}
|
||||
|
||||
static std::map<u32, user_account> GetUserAccounts(const std::string& base_dir);
|
||||
static void createdDefaultUser();
|
||||
|
||||
private:
|
||||
std::string m_user_id;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "system_error"
|
||||
#include "unordered_map"
|
||||
|
||||
#include <core/user_account.h>
|
||||
#include <fmt/core.h>
|
||||
#include "common/config.h"
|
||||
#include "common/memory_patcher.h"
|
||||
|
@ -27,6 +28,8 @@ int main(int argc, char* argv[]) {
|
|||
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::load(user_dir / "config.toml");
|
||||
|
||||
user_account::createdDefaultUser();
|
||||
|
||||
bool has_game_argument = false;
|
||||
std::string game_path;
|
||||
std::vector<std::string> game_args{};
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "system_error"
|
||||
#include "unordered_map"
|
||||
|
||||
#include <core/user_account.h>
|
||||
#include "common/config.h"
|
||||
#include "common/memory_patcher.h"
|
||||
#include "core/file_sys/fs.h"
|
||||
|
@ -32,11 +33,7 @@ int main(int argc, char* argv[]) {
|
|||
const auto user_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::load(user_dir / "config.toml");
|
||||
|
||||
const auto& default_user_dir =
|
||||
Common::FS::GetUserPath(Common::FS::PathType::HomeDir) / Config::getDefaultUserId();
|
||||
if (!std::filesystem::exists(default_user_dir)) {
|
||||
std::filesystem::create_directory(default_user_dir);
|
||||
}
|
||||
user_account::createdDefaultUser();
|
||||
|
||||
bool has_command_line_argument = argc > 1;
|
||||
bool show_gui = false, has_game_argument = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue