axiosengine/axios/Engine/File/AxiosRegularFile.cs
Nathan Adams 5de23be1fe + * - Changing AxiosTitleFile.GetStream() to return Stream instead of FileStream
+ * - Changing IAxiosFile.GetStream() to return Stream instead of FileStream
2012-05-21 21:53:14 -05:00

47 lines
1.3 KiB
C#

using System.IO;
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;
}
public override Stream GetStream(FileMode mode)
{
FileStream fs = new FileStream(_filename, mode);
return (Stream)fs;
}
}
}