2012-03-24 23:06:51 +00:00
|
|
|
|
using System.IO;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
|
|
|
|
using Axios.Engine.Interfaces;
|
|
|
|
|
|
|
|
|
|
namespace Axios.Engine.File
|
|
|
|
|
{
|
|
|
|
|
public class AxiosRegularFile : AxiosFile, IAxiosFile
|
|
|
|
|
{
|
|
|
|
|
public AxiosRegularFile(string file)
|
|
|
|
|
{
|
|
|
|
|
_filename = file;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void WriteData(string data, FileMode mode)
|
|
|
|
|
{
|
|
|
|
|
//Make sure that a proper mode is passed
|
|
|
|
|
if (mode == FileMode.Append
|
|
|
|
|
|| mode == FileMode.Create
|
|
|
|
|
|| mode == FileMode.CreateNew
|
|
|
|
|
|| mode == FileMode.Truncate)
|
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream(_filename, mode);
|
|
|
|
|
StreamWriter sw = new StreamWriter(fs);
|
|
|
|
|
sw.Write(data);
|
|
|
|
|
sw.Close();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ReadData()
|
|
|
|
|
{
|
|
|
|
|
string ret = "";
|
|
|
|
|
FileStream fs = new FileStream(_filename, FileMode.Open);
|
|
|
|
|
StreamReader sr = new StreamReader(fs);
|
|
|
|
|
ret = sr.ReadToEnd();
|
|
|
|
|
sr.Close();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2012-05-12 23:36:46 +00:00
|
|
|
|
|
|
|
|
|
public override FileStream GetStream(FileMode mode)
|
|
|
|
|
{
|
|
|
|
|
FileStream fs = new FileStream(_filename, mode);
|
|
|
|
|
return fs;
|
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|