Save "ver" file in the session directory to know which Aseprite version was used

This commit is contained in:
David Capello 2015-04-09 08:10:09 -03:00
parent 21a57ff793
commit 2ee6df8038
2 changed files with 19 additions and 6 deletions

View File

@ -104,19 +104,26 @@ void Session::create(base::pid pid)
m_pid = pid;
#ifdef _WIN32
std::ofstream of(base::from_utf8(pidFilename()));
std::ofstream pidf(base::from_utf8(pidFilename()));
std::ofstream verf(base::from_utf8(verFilename()));
#else
std::ofstream of(pidFilename());
std::ofstream pidf(pidFilename());
std::ofstream verf(verFilename());
#endif
of << m_pid;
pidf << m_pid;
verf << VERSION;
}
void Session::removeFromDisk()
{
if (base::is_file(pidFilename()))
base::delete_file(pidFilename());
try {
if (base::is_file(pidFilename()))
base::delete_file(pidFilename());
if (base::is_file(verFilename()))
base::delete_file(verFilename());
base::remove_directory(m_path);
}
catch (const std::exception& ex) {
@ -204,6 +211,11 @@ std::string Session::pidFilename() const
return base::join_path(m_path, "pid");
}
std::string Session::verFilename() const
{
return base::join_path(m_path, "ver");
}
void Session::deleteDirectory(const std::string& dir)
{
ASSERT(!dir.empty());

View File

@ -57,6 +57,7 @@ namespace crash {
private:
void loadPid();
std::string pidFilename() const;
std::string verFilename() const;
void deleteDirectory(const std::string& dir);
base::pid m_pid;