From e74c663c0258ea16655ffa747ff7116383e9ee66 Mon Sep 17 00:00:00 2001 From: Nathan Adams Date: Sat, 12 May 2012 18:36:46 -0500 Subject: [PATCH] Adding GetStream(FileMode) to get the stream of a file --- axios/Axios_settings.cs | 1 + axios/Engine/File/AxiosFile.cs | 5 +++++ axios/Engine/File/AxiosIsolatedFile.cs | 13 +++++++++++++ axios/Engine/File/AxiosRegularFile.cs | 6 ++++++ axios/Engine/File/AxiosTitleFile.cs | 6 ++++++ axios/Engine/Interfaces/IAxiosFile.cs | 1 + 6 files changed, 32 insertions(+) diff --git a/axios/Axios_settings.cs b/axios/Axios_settings.cs index 72e2666..fc86aa6 100644 --- a/axios/Axios_settings.cs +++ b/axios/Axios_settings.cs @@ -72,6 +72,7 @@ * - Adding support for Gleed2D * - Splitting the code for Gleed2D into seperate files * - Adding a cache for loading in textures for Gleed2D + * - Adding GetStream(FileMode) to get the stream of a file * */ diff --git a/axios/Engine/File/AxiosFile.cs b/axios/Engine/File/AxiosFile.cs index b8e8a83..1014720 100644 --- a/axios/Engine/File/AxiosFile.cs +++ b/axios/Engine/File/AxiosFile.cs @@ -28,5 +28,10 @@ namespace Axios.Engine.File { throw new NotImplementedException(); } + + public virtual FileStream GetStream(FileMode mode) + { + throw new NotImplementedException(); + } } } diff --git a/axios/Engine/File/AxiosIsolatedFile.cs b/axios/Engine/File/AxiosIsolatedFile.cs index 02fbec1..08656ba 100644 --- a/axios/Engine/File/AxiosIsolatedFile.cs +++ b/axios/Engine/File/AxiosIsolatedFile.cs @@ -50,5 +50,18 @@ namespace Axios.Engine.File Content = ret; return ret; } + + public override FileStream GetStream(FileMode mode) + { +#if WINDOWS + IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForDomain(); +#else + IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication(); +#endif + IsolatedStorageFileStream fs = null; + fs = savegameStorage.OpenFile(_filename, mode); + return fs; + } + } } diff --git a/axios/Engine/File/AxiosRegularFile.cs b/axios/Engine/File/AxiosRegularFile.cs index 295f769..e044aa3 100644 --- a/axios/Engine/File/AxiosRegularFile.cs +++ b/axios/Engine/File/AxiosRegularFile.cs @@ -36,5 +36,11 @@ namespace Axios.Engine.File sr.Close(); return ret; } + + public override FileStream GetStream(FileMode mode) + { + FileStream fs = new FileStream(_filename, mode); + return fs; + } } } diff --git a/axios/Engine/File/AxiosTitleFile.cs b/axios/Engine/File/AxiosTitleFile.cs index 576dd0c..f6a6824 100644 --- a/axios/Engine/File/AxiosTitleFile.cs +++ b/axios/Engine/File/AxiosTitleFile.cs @@ -27,5 +27,11 @@ namespace Axios.Engine.File sr.Close(); return this.Content; } + + public override FileStream GetStream(FileMode mode) + { + FileStream fs = (FileStream)TitleContainer.OpenStream(_filename); + return fs; + } } } diff --git a/axios/Engine/Interfaces/IAxiosFile.cs b/axios/Engine/Interfaces/IAxiosFile.cs index e7ba5d9..ece7fe8 100644 --- a/axios/Engine/Interfaces/IAxiosFile.cs +++ b/axios/Engine/Interfaces/IAxiosFile.cs @@ -6,5 +6,6 @@ namespace Axios.Engine.Interfaces { void WriteData(string data, FileMode mode); string ReadData(); + FileStream GetStream(FileMode mode); } }