Line data Source code
1 : /* Copyright (C) 2021 Wildfire Games.
2 : * This file is part of 0 A.D.
3 : *
4 : * 0 A.D. is free software: you can redistribute it and/or modify
5 : * it under the terms of the GNU General Public License as published by
6 : * the Free Software Foundation, either version 2 of the License, or
7 : * (at your option) any later version.
8 : *
9 : * 0 A.D. is distributed in the hope that it will be useful,
10 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 : * GNU General Public License for more details.
13 : *
14 : * You should have received a copy of the GNU General Public License
15 : * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 : */
17 :
18 : #include "precompiled.h"
19 :
20 : #include <cstdio>
21 :
22 : #include "Pyrogenesis.h"
23 :
24 : #include "lib/sysdep/sysdep.h"
25 : #include "lib/svn_revision.h"
26 :
27 : const char* engine_version = "0.0.27";
28 : const char* main_window_name = "0 A.D.";
29 :
30 : // convert contents of file <in_filename> from char to wchar_t and
31 : // append to <out> file.
32 0 : static void AppendAsciiFile(FILE* out, const OsPath& pathname)
33 : {
34 0 : FILE* in = sys_OpenFile(pathname, "rb");
35 0 : if (!in)
36 : {
37 0 : fwprintf(out, L"(unavailable)");
38 0 : return;
39 : }
40 :
41 0 : const size_t buf_size = 1024;
42 : char buf[buf_size+1]; // include space for trailing '\0'
43 :
44 0 : while (!feof(in))
45 : {
46 0 : size_t bytes_read = fread(buf, 1, buf_size, in);
47 0 : if (!bytes_read)
48 0 : break;
49 0 : buf[bytes_read] = 0; // 0-terminate
50 0 : fwprintf(out, L"%hs", buf);
51 : }
52 :
53 0 : fclose(in);
54 : }
55 :
56 : // for user convenience, bundle all logs into this file:
57 0 : void psBundleLogs(FILE* f)
58 : {
59 0 : fwprintf(f, L"SVN Revision: %ls\n\n", svn_revision);
60 0 : fwprintf(f, L"Engine Version: %hs\n\n", engine_version);
61 :
62 0 : fwprintf(f, L"System info:\n\n");
63 0 : OsPath path1 = psLogDir()/"system_info.txt";
64 0 : AppendAsciiFile(f, path1);
65 0 : fwprintf(f, L"\n\n====================================\n\n");
66 :
67 0 : fwprintf(f, L"Main log:\n\n");
68 0 : OsPath path2 = psLogDir()/"mainlog.html";
69 0 : AppendAsciiFile(f, path2);
70 0 : fwprintf(f, L"\n\n====================================\n\n");
71 0 : }
72 :
73 :
74 1 : static OsPath logDir;
75 :
76 0 : void psSetLogDir(const OsPath& newLogDir)
77 : {
78 0 : logDir = newLogDir;
79 0 : }
80 :
81 0 : const OsPath& psLogDir()
82 : {
83 0 : return logDir;
84 3 : }
|