diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 362862815c..029f4eb4a0 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -181,6 +181,7 @@ void Emulator::Init() }; const std::string save_path = dev_hdd0 + "home/" + m_usr + "/savedata/"; + const std::string user_path = dev_hdd0 + "home/" + m_usr + "/localusername"; if (g_cfg.vfs.init_dirs) { @@ -198,11 +199,11 @@ void Emulator::Init() make_path_verbose(save_path); make_path_verbose(dev_hdd0 + "home/" + m_usr + "/trophy/"); - if (!fs::write_file(dev_hdd0 + "home/" + m_usr + "/localusername", fs::create + fs::excl + fs::write, "User"s)) + if (!fs::write_file(user_path, fs::create + fs::excl + fs::write, "User"s)) { if (fs::g_tls_error != fs::error::exist) { - sys_log.fatal("Failed to create file: %shome/%s/localusername (%s)", dev_hdd0, m_usr, fs::g_tls_error); + sys_log.fatal("Failed to create file: %s (%s)", user_path, fs::g_tls_error); } } @@ -212,6 +213,41 @@ void Emulator::Init() make_path_verbose(dev_hdd1 + "caches/"); } + // Log user + if (m_usr.empty()) + { + sys_log.fatal("No user configured"); + } + else + { + std::string username; + + if (const fs::file file = fs::file(user_path)) + { + if (const std::string localusername = file.to_string(); !localusername.empty()) + { + username = localusername; + } + else + { + sys_log.warning("Empty username in file: '%s'. Consider setting a username for user '%s' in the user manager.", user_path, m_usr); + } + } + else + { + sys_log.error("Could not read file: '%s'", user_path); + } + + if (username.empty()) + { + sys_log.notice("Logged in as user '%s'", m_usr); + } + else + { + sys_log.notice("Logged in as user '%s' with the username '%s'", m_usr, username); + } + } + // Fixup savedata for (const auto& entry : fs::dir(save_path)) { diff --git a/rpcs3/headless_application.cpp b/rpcs3/headless_application.cpp index 1b0572d748..e9b715d9ef 100644 --- a/rpcs3/headless_application.cpp +++ b/rpcs3/headless_application.cpp @@ -17,7 +17,7 @@ headless_application::headless_application(int& argc, char** argv) : QCoreApplic void headless_application::Init() { // Force init the emulator - InitializeEmulator("1", true, false); // TODO: get user from cli args if possible + InitializeEmulator("00000001", true, false); // TODO: get user from cli args if possible // Create callbacks from the emulator, which reference the handlers. InitializeCallbacks();