Don't spam logs and replays all over my home directory kthx.

Logs and replays are written to subdirectories of the "Support" folder. Default location is <game dir>/Support/; Can be overridden on game start.
This commit is contained in:
Paul Chote
2010-07-08 12:21:28 +12:00
parent fb6c44bce3
commit fdc85b6e48
7 changed files with 43 additions and 18 deletions

View File

@@ -37,14 +37,20 @@ namespace OpenRA
public static class Log
{
public static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
static string LogPathPrefix = Environment.GetFolderPath(Environment.SpecialFolder.Personal) + Path.DirectorySeparatorChar;
static Dictionary<string, ChannelInfo> channels = new Dictionary<string,ChannelInfo>();
static Log()
public static string LogPath
{
AddChannel("debug", "openra.log.txt", false, false);
get { return LogPathPrefix; }
set
{
LogPathPrefix = value;
if (!Directory.Exists(LogPathPrefix))
Directory.CreateDirectory(LogPathPrefix);
}
}
public static void AddChannel(string channelName, string filename, bool upload, bool diff)
{
if (channels.ContainsKey(channelName)) return;
@@ -57,7 +63,7 @@ namespace OpenRA
{
writer = File.CreateText(LogPathPrefix + filename);
}
catch(IOException e){ filename = new Random().Next().ToString() + filename; }
catch(IOException){ filename = new Random().Next().ToString() + filename; }
}
writer.AutoFlush = true;