2012-03-19 23:57:59 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using Axios.Engine.Interfaces;
|
2012-03-24 23:06:51 +00:00
|
|
|
|
using Microsoft.Xna.Framework;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
|
|
|
|
|
namespace Axios.Engine.File
|
|
|
|
|
{
|
2015-01-03 02:14:38 +00:00
|
|
|
|
public class AxiosTitleFile : AxiosFile, IAxiosFile, IDisposable
|
2012-03-19 23:57:59 +00:00
|
|
|
|
{
|
2015-01-03 02:14:38 +00:00
|
|
|
|
protected Stream _fs;
|
2012-03-19 23:57:59 +00:00
|
|
|
|
public AxiosTitleFile(string filename)
|
|
|
|
|
{
|
|
|
|
|
//Title Files can only be opened for reading!
|
|
|
|
|
|
|
|
|
|
this._filename = filename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void WriteData(string data, FileMode mode)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string ReadData()
|
|
|
|
|
{
|
|
|
|
|
StreamReader sr = new StreamReader(TitleContainer.OpenStream(_filename));
|
|
|
|
|
this.Content = sr.ReadToEnd();
|
|
|
|
|
sr.Close();
|
|
|
|
|
return this.Content;
|
|
|
|
|
}
|
2012-05-12 23:36:46 +00:00
|
|
|
|
|
2012-05-22 02:53:14 +00:00
|
|
|
|
public override Stream GetStream(FileMode mode)
|
2012-05-12 23:36:46 +00:00
|
|
|
|
{
|
2015-01-03 02:14:38 +00:00
|
|
|
|
_fs = (Stream)TitleContainer.OpenStream(_filename);
|
|
|
|
|
return _fs;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
// http://msdn.microsoft.com/en-us/library/system.idisposable%28v=vs.110%29.aspx
|
|
|
|
|
Dispose(true);
|
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing)
|
|
|
|
|
{
|
|
|
|
|
if (disposed)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (disposing && _fs != null)
|
|
|
|
|
{
|
|
|
|
|
_fs.Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
disposed = true;
|
2012-05-12 23:36:46 +00:00
|
|
|
|
}
|
2012-03-19 23:57:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|