MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / Snapshot_SetPathname

Function Snapshot_SetPathname

source/SaveState.cpp:108–135  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106//-----------------------------------------------------------------------------
107
108static void Snapshot_SetPathname(const std::string& strPathname)
109{
110 if (strPathname.empty())
111 {
112 g_strSaveStateFilename = DEFAULT_SNAPSHOT_NAME;
113
114 g_strSaveStatePathname = g_sCurrentDir;
115 if (!g_strSaveStatePathname.empty() && *g_strSaveStatePathname.rbegin() != PATH_SEPARATOR)
116 g_strSaveStatePathname += PATH_SEPARATOR;
117 g_strSaveStatePathname.append(DEFAULT_SNAPSHOT_NAME);
118
119 g_strSaveStatePath = g_sCurrentDir;
120 return;
121 }
122
123 std::string strFilename = strPathname; // Set default, as maybe there's no path
124 g_strSaveStatePath.clear();
125
126 size_t nIdx = strPathname.find_last_of(PATH_SEPARATOR);
127 if (nIdx >= 0 && nIdx+1 < (int)strPathname.length()) // path exists?
128 {
129 strFilename = &strPathname[nIdx+1];
130 g_strSaveStatePath = strPathname.substr(0, nIdx+1); // Bugfix: 1.25.0.2 // Snapshot_LoadState() -> SetCurrentImageDir() -> g_sCurrentDir
131 }
132
133 g_strSaveStateFilename = strFilename;
134 g_strSaveStatePathname = strPathname;
135}
136
137void Snapshot_SetFilename(const std::string& filename, const std::string& path/*=""*/)
138{

Callers 1

Snapshot_SetFilenameFunction · 0.85

Calls 1

clearMethod · 0.45

Tested by

no test coverage detected