diff --git a/Utilities/File.h b/Utilities/File.h index 0498a9ab74..0d9e985785 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -576,4 +576,17 @@ namespace fs result.reset(std::make_unique>(std::forward(container))); return result; } + + template + bool write_file(const std::string& path, bs_t mode, const Args&... args) + { + if (fs::file f{path, mode}) + { + // Write args sequentially + int seq[]{ (f.write(args), 0)... }; + return true; + } + + return false; + } } diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 4d0031625e..67203e332d 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -95,7 +95,7 @@ void Emulator::Init() fs::create_dir(dev_hdd0 + "home/00000001/exdata/"); fs::create_dir(dev_hdd0 + "home/00000001/savedata/"); fs::create_dir(dev_hdd0 + "home/00000001/trophy/"); - if (fs::file f{dev_hdd0 + "home/00000001/localusername", fs::create + fs::excl + fs::write}) f.write("User"s); + fs::write_file(dev_hdd0 + "home/00000001/localusername", fs::create + fs::excl + fs::write, "User"s); fs::create_dir(dev_hdd1 + "cache/"); fs::create_dir(dev_hdd1 + "game/"); fs::create_path(dev_hdd1);