Don't create an empty oos_logs directory when starting the game. Rename getDateIndexSubdirectory to createDateIndexSubdirectory. Add a comment for the breakpoint argument of CreateDirectories. This was SVN commit r18183.
This commit is contained in:
parent
24b262e4d1
commit
f4e69b7c07
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2015 Wildfire Games
|
||||
/* Copyright (c) 2016 Wildfire Games
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Wildfire Games
|
||||
/* Copyright (c) 2016 Wildfire Games
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -80,6 +80,7 @@ LIB_API Status GetDirectoryEntries(const OsPath& path, CFileInfos* files, Direct
|
||||
|
||||
// same as boost::filesystem::create_directories, except that mkdir is invoked with
|
||||
// <mode> instead of 0755.
|
||||
// If the breakpoint is enabled, debug_break will be called if the directory didn't exist and couldn't be created.
|
||||
LIB_API Status CreateDirectories(const OsPath& path, mode_t mode, bool breakpoint = true);
|
||||
|
||||
LIB_API Status DeleteDirectory(const OsPath& dirPath);
|
||||
|
@ -70,7 +70,7 @@ void CReplayLogger::StartGame(JS::MutableHandleValue attribs)
|
||||
m_ScriptInterface.SetProperty(attribs, "engine_version", CStr(engine_version));
|
||||
m_ScriptInterface.SetProperty(attribs, "mods", g_modsLoaded);
|
||||
|
||||
m_Directory = getDateIndexSubdirectory(VisualReplay::GetDirectoryName());
|
||||
m_Directory = createDateIndexSubdirectory(VisualReplay::GetDirectoryName());
|
||||
debug_printf("Writing replay to %s\n", m_Directory.string8().c_str());
|
||||
|
||||
m_Stream = new std::ofstream(OsString(m_Directory / L"commands.txt").c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
|
@ -196,7 +196,7 @@ Status tex_write(Tex* t, const VfsPath& filename)
|
||||
/**
|
||||
* Return an unused directory, based on date and index (for example 2016-02-09_0001)
|
||||
*/
|
||||
OsPath getDateIndexSubdirectory(const OsPath& parentDir)
|
||||
OsPath createDateIndexSubdirectory(const OsPath& parentDir)
|
||||
{
|
||||
const std::time_t timestamp = std::time(nullptr);
|
||||
const struct std::tm* now = std::localtime(×tamp);
|
||||
|
@ -26,7 +26,7 @@ extern void WriteSystemInfo();
|
||||
|
||||
extern const wchar_t* ErrorString(int err);
|
||||
|
||||
extern OsPath getDateIndexSubdirectory(const OsPath& parentDir);
|
||||
extern OsPath createDateIndexSubdirectory(const OsPath& parentDir);
|
||||
|
||||
extern void WriteScreenshot(const VfsPath& extension);
|
||||
extern void WriteBigScreenshot(const VfsPath& extension, int tiles);
|
||||
|
@ -76,10 +76,11 @@ public:
|
||||
CFG_GET_VAL("serializationtest", m_EnableSerializationTest);
|
||||
}
|
||||
|
||||
m_OOSLogPath = getDateIndexSubdirectory(psLogDir() / "oos_logs");
|
||||
|
||||
if (m_EnableOOSLog)
|
||||
{
|
||||
m_OOSLogPath = createDateIndexSubdirectory(psLogDir() / "oos_logs");
|
||||
debug_printf("Writing ooslogs to %s\n", m_OOSLogPath.string8().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
~CSimulation2Impl()
|
||||
@ -296,7 +297,7 @@ void CSimulation2Impl::ReportSerializationFailure(
|
||||
SerializationTestState* primaryStateBefore, SerializationTestState* primaryStateAfter,
|
||||
SerializationTestState* secondaryStateBefore, SerializationTestState* secondaryStateAfter)
|
||||
{
|
||||
const OsPath path = getDateIndexSubdirectory(psLogDir() / "serializationtest");
|
||||
const OsPath path = createDateIndexSubdirectory(psLogDir() / "serializationtest");
|
||||
debug_printf("Writing serializationtest-data to %s\n", path.string8().c_str());
|
||||
|
||||
// Clean up obsolete files from previous runs
|
||||
@ -555,6 +556,12 @@ void CSimulation2Impl::DumpState()
|
||||
const OsPath path = m_OOSLogPath / name.str();
|
||||
std::ofstream file (OsString(path).c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
|
||||
if (!DirectoryExists(m_OOSLogPath))
|
||||
{
|
||||
LOGWARNING("OOS-log directory %s was deleted, creating it again.", m_OOSLogPath.string8().c_str());
|
||||
CreateDirectories(m_OOSLogPath, 0700);
|
||||
}
|
||||
|
||||
file << "State hash: " << std::hex;
|
||||
std::string hashRaw;
|
||||
m_ComponentManager.ComputeStateHash(hashRaw, false);
|
||||
@ -590,6 +597,8 @@ void CSimulation2::EnableOOSLog()
|
||||
return;
|
||||
|
||||
m->m_EnableOOSLog = true;
|
||||
m->m_OOSLogPath = createDateIndexSubdirectory(psLogDir() / "oos_logs");
|
||||
|
||||
debug_printf("Writing ooslogs to %s\n", m->m_OOSLogPath.string8().c_str());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user