amxmodx/installer/builder/Config.cs

101 lines
1.9 KiB
C#
Raw Normal View History

2005-08-02 10:28:41 +04:00
using System;
using System.IO;
2005-08-02 10:28:41 +04:00
namespace AMXXRelease
{
//Reads in config file info
2005-08-02 10:28:41 +04:00
public class Config
{
private string m_SourceTree;
private string m_OutputPath;
private string m_DevenvPath;
private string m_PathToCompress;
private string m_ReleaseName;
private string m_MakeOpts;
2005-08-02 10:28:41 +04:00
public Config()
{
}
public string GetSourceTree()
{
return m_SourceTree;
2005-08-02 10:28:41 +04:00
}
public string OutputPath()
{
return m_OutputPath;
2005-08-02 10:28:41 +04:00
}
public string DevenvPath()
{
return m_DevenvPath;
}
public string CompressPath()
{
return m_PathToCompress;
}
public string GetReleaseName()
{
return m_ReleaseName;
2005-08-02 10:28:41 +04:00
}
public string MakeOpts()
2005-08-02 10:28:41 +04:00
{
return m_MakeOpts;
}
public bool ReadFromFile(string file)
{
try
{
StreamReader sr = new StreamReader(file);
string line;
string delim = "\t \n\r\v";
string splt = "=";
while ( (line = sr.ReadLine()) != null )
{
line = line.Trim(delim.ToCharArray());
if (line.Length < 1 || line[0] == ';')
continue;
string [] s = line.Split(splt.ToCharArray());
string key, val="";
if (s.GetLength(0) >= 1)
{
key = s[0];
if (s.GetLength(0) >= 2)
{
for(int i=1; i<s.GetLength(0); i++)
val += s[i];
}
key = key.Trim(delim.ToCharArray());
val = val.Trim(delim.ToCharArray());
if (key.CompareTo("compress")==0)
m_PathToCompress = val;
if (key.CompareTo("devenv")==0)
m_DevenvPath = val;
if (key.CompareTo("output")==0)
m_OutputPath = val;
if (key.CompareTo("source")==0)
m_SourceTree = val;
if (key.CompareTo("release")==0)
m_ReleaseName = val;
if (key.CompareTo("makeopts")==0)
m_MakeOpts = val;
}
}
return true;
} catch {
Console.WriteLine("Unable to read file: " + file);
}
return false;
2005-08-02 10:28:41 +04:00
}
}
}