MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / Save

Method Save

pcsx2/INISettingsInterface.cpp:90–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90bool INISettingsInterface::Save(Error* error)
91{
92 if (m_filename.empty())
93 {
94 Error::SetStringView(error, "Filename is not set.");
95 return false;
96 }
97
98 std::unique_lock lock(s_ini_load_save_mutex);
99 std::string temp_filename;
100 std::FILE* fp = GetTemporaryFile(&temp_filename, m_filename, "wb", error);
101 SI_Error err = SI_FAIL;
102 if (fp)
103 {
104 err = m_ini.SaveFile(fp, false);
105 std::fclose(fp);
106
107 if (err != SI_OK)
108 {
109 Error::SetStringFmt(error, "INI SaveFile() failed: {}", static_cast<int>(err));
110
111 // remove temporary file
112 FileSystem::DeleteFilePath(temp_filename.c_str());
113 }
114 else if (!FileSystem::RenamePath(temp_filename.c_str(), m_filename.c_str(), error))
115 {
116 Console.Error("Failed to rename '%s' to '%s'", temp_filename.c_str(), m_filename.c_str());
117 FileSystem::DeleteFilePath(temp_filename.c_str());
118 return false;
119 }
120 }
121
122 if (err != SI_OK)
123 {
124 Console.Warning("Failed to save settings to '%s'.", m_filename.c_str());
125 return false;
126 }
127
128 m_dirty = false;
129 return true;
130}
131
132void INISettingsInterface::Clear()
133{

Callers 15

CreateShortcutMethod · 0.45
saveCoverURLsMethod · 0.45
InitializeConfigMethod · 0.45
SaveSettingsMethod · 0.45
SaveGameSettingsMethod · 0.45
mainFunction · 0.45
onNewProfileClickedMethod · 0.45
onEthHostExportMethod · 0.45
setNewBindingMethod · 0.45
clearBindingMethod · 0.45
saveListToSettingsMethod · 0.45
disableAllCheatsMethod · 0.45

Calls 6

GetTemporaryFileFunction · 0.85
SaveFileMethod · 0.80
emptyMethod · 0.45
c_strMethod · 0.45
ErrorMethod · 0.45
WarningMethod · 0.45

Tested by

no test coverage detected