Browse Source

[macOS] store logs in the standard system directory

~/Library/Logs/vcmi
Andrey Filipenkov 3 years ago
parent
commit
45f5fc04be
1 changed files with 9 additions and 0 deletions
  1. 9 0
      lib/VCMIDirs.cpp

+ 9 - 0
lib/VCMIDirs.cpp

@@ -368,6 +368,7 @@ class VCMIDirsOSX final : public IVCMIDirsUNIX
 		boost::filesystem::path userDataPath() const override;
 		boost::filesystem::path userCachePath() const override;
 		boost::filesystem::path userConfigPath() const override;
+		boost::filesystem::path userLogsPath() const override;
 
 		std::vector<boost::filesystem::path> dataPaths() const override;
 
@@ -437,6 +438,14 @@ bfs::path VCMIDirsOSX::userDataPath() const
 bfs::path VCMIDirsOSX::userCachePath() const { return userDataPath(); }
 bfs::path VCMIDirsOSX::userConfigPath() const { return userDataPath() / "config"; }
 
+bfs::path VCMIDirsOSX::userLogsPath() const
+{
+	// TODO: use proper objc code from Foundation framework
+	if(const auto homeDir = std::getenv("HOME"))
+		return bfs::path{homeDir} / "Library" / "Logs" / "vcmi";
+	return IVCMIDirsUNIX::userLogsPath();
+}
+
 std::vector<bfs::path> VCMIDirsOSX::dataPaths() const
 {
 	std::vector<bfs::path> ret;