UltimateZoneBuilder/Source/Config/CompilerInfo.cs

103 lines
2.7 KiB
C#
Raw Normal View History

#region ================== Copyright (c) 2007 Pascal vd Heiden
/*
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
* This program is released under GNU General Public License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#endregion
#region ================== Namespaces
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using CodeImp.DoomBuilder.IO;
using CodeImp.DoomBuilder.Data;
using System.IO;
using System.Diagnostics;
#endregion
namespace CodeImp.DoomBuilder.Config
{
2008-01-02 21:49:43 +00:00
internal class CompilerInfo
{
#region ================== Constants
2008-11-11 16:19:50 +00:00
#endregion
2008-11-11 16:19:50 +00:00
#region ================== Variables
2008-11-11 16:19:50 +00:00
private string name;
private string programfile;
2008-11-11 16:19:50 +00:00
private string programinterface;
private List<string> files;
2008-11-11 16:19:50 +00:00
#endregion
2008-11-11 16:19:50 +00:00
#region ================== Properties
2008-11-11 16:19:50 +00:00
public string Name { get { return name; } }
public string ProgramFile { get { return programfile; } }
2008-11-11 16:19:50 +00:00
public string ProgramInterface { get { return programinterface; } }
public List<string> Files { get { return files; } }
2008-11-11 16:19:50 +00:00
#endregion
2008-11-11 16:19:50 +00:00
#region ================== Constructor / Disposer
2008-11-11 16:19:50 +00:00
// Constructor
public CompilerInfo(string filename, string name, Configuration cfg)
{
IDictionary cfgfiles;
2008-11-11 16:19:50 +00:00
General.WriteLogLine("Registered compiler configuration '" + name + "' from '" + filename + "'");
2008-11-11 16:19:50 +00:00
// Initialize
this.name = name;
this.files = new List<string>();
2008-11-11 16:19:50 +00:00
// Read program file and interface
this.programfile = cfg.ReadSetting("compilers." + name + ".program", "");
2008-11-11 16:19:50 +00:00
this.programinterface = cfg.ReadSetting("compilers." + name + ".interface", "");
// Make list of files required
cfgfiles = cfg.ReadSetting("compilers." + name, new Hashtable());
foreach(DictionaryEntry de in cfgfiles)
2008-11-11 16:19:50 +00:00
{
if(de.Key.ToString() != "interface")
files.Add(de.Value.ToString());
}
}
2008-11-11 16:19:50 +00:00
#endregion
2008-11-11 16:19:50 +00:00
#region ================== Methods
2008-11-11 16:19:50 +00:00
// This copies all compiler files to a given destination
public void CopyRequiredFiles(string targetpath)
{
// Copy files
foreach(string f in files)
2008-11-11 16:19:50 +00:00
{
string sourcefile = Path.Combine(General.CompilersPath, f);
string targetfile = Path.Combine(targetpath, f);
if(!File.Exists(sourcefile)) General.WriteLogLine("WARNING: The file '" + f + "' required by the '" + name + "' compiler is missing!");
File.Copy(sourcefile, targetfile, true);
}
}
2008-11-11 16:19:50 +00:00
#endregion
}
}