Adding initial files
This commit is contained in:
35
axios/Engine/File/AxiosFile.cs
Normal file
35
axios/Engine/File/AxiosFile.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
using Axios.Engine.Interfaces;
|
||||
|
||||
namespace Axios.Engine.File
|
||||
{
|
||||
public class AxiosFile : IAxiosFile
|
||||
{
|
||||
protected string _content;
|
||||
|
||||
public String Content
|
||||
{
|
||||
get { return _content; }
|
||||
protected set { this._content = value; }
|
||||
}
|
||||
|
||||
protected string _filename;
|
||||
|
||||
|
||||
|
||||
public virtual void WriteData(string data, FileMode mode)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual string ReadData()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
59
axios/Engine/File/AxiosIsolatedFile.cs
Normal file
59
axios/Engine/File/AxiosIsolatedFile.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO.IsolatedStorage;
|
||||
using System.IO;
|
||||
|
||||
using Axios.Engine.Interfaces;
|
||||
|
||||
namespace Axios.Engine.File
|
||||
{
|
||||
public class AxiosIsolatedFile : AxiosFile, IAxiosFile
|
||||
{
|
||||
|
||||
public AxiosIsolatedFile(string filename)
|
||||
{
|
||||
this._filename = filename;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
#if WINDOWS
|
||||
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForDomain();
|
||||
#else
|
||||
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();
|
||||
#endif
|
||||
IsolatedStorageFileStream fs = null;
|
||||
fs = savegameStorage.OpenFile(_filename, mode);
|
||||
StreamWriter sw = new StreamWriter(fs);
|
||||
sw.Write(data);
|
||||
sw.Close();
|
||||
this.Content = data;
|
||||
}
|
||||
}
|
||||
|
||||
public override string ReadData()
|
||||
{
|
||||
string ret = "";
|
||||
#if WINDOWS
|
||||
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForDomain();
|
||||
#else
|
||||
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();
|
||||
#endif
|
||||
IsolatedStorageFileStream fs = null;
|
||||
fs = savegameStorage.OpenFile(_filename, System.IO.FileMode.Open);
|
||||
StreamReader sr = new StreamReader(fs);
|
||||
ret = sr.ReadToEnd();
|
||||
sr.Close();
|
||||
Content = ret;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
44
axios/Engine/File/AxiosRegularFile.cs
Normal file
44
axios/Engine/File/AxiosRegularFile.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
35
axios/Engine/File/AxiosTitleFile.cs
Normal file
35
axios/Engine/File/AxiosTitleFile.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Axios.Engine.File;
|
||||
using Axios.Engine.Interfaces;
|
||||
|
||||
namespace Axios.Engine.File
|
||||
{
|
||||
public class AxiosTitleFile : AxiosFile, IAxiosFile
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user