diff --git a/.gitignore b/.gitignore index 122f78b..7375c1e 100644 --- a/.gitignore +++ b/.gitignore @@ -151,3 +151,4 @@ $RECYCLE.BIN/ build/1.* build/nuspec/FileFormatWavefront/lib build/nuspec/FileFormatWavefront/lib/ +/source/packages diff --git a/source/FileFormatWavefront/Extensions/ListExtensions.cs b/source/FileFormatWavefront/Extensions/ListExtensions.cs new file mode 100644 index 0000000..11fb792 --- /dev/null +++ b/source/FileFormatWavefront/Extensions/ListExtensions.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; + +namespace FileFormatWavefront.Extensions +{ + internal static class ListExtensions + { + /// + /// Returns a read-only IList<T> wrapper for the current collection. + /// + /// A ReadOnlyCollection<T> that acts as a read-only + /// wrapper around the current IList<T>. + /// + public static ReadOnlyCollection AsReadOnly(this List list) + { + return new ReadOnlyCollection(list); + } + } +} diff --git a/source/FileFormatWavefront/Extensions/StringExtensions.cs b/source/FileFormatWavefront/Extensions/StringExtensions.cs index 4c2bc61..0e28549 100644 --- a/source/FileFormatWavefront/Extensions/StringExtensions.cs +++ b/source/FileFormatWavefront/Extensions/StringExtensions.cs @@ -16,7 +16,7 @@ internal static class StringExtensions /// True if the string matches the linetype. public static bool IsLineType(this string @this, string lineType) { - return string.Equals(@this, lineType, StringComparison.InvariantCultureIgnoreCase); + return string.Equals(@this, lineType, StringComparison.OrdinalIgnoreCase); } } } \ No newline at end of file diff --git a/source/FileFormatWavefront/FileFormatMtl.cs b/source/FileFormatWavefront/FileFormatMtl.cs index 368b334..cd2634f 100644 --- a/source/FileFormatWavefront/FileFormatMtl.cs +++ b/source/FileFormatWavefront/FileFormatMtl.cs @@ -1,11 +1,12 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Linq; using FileFormatWavefront.Extensions; using FileFormatWavefront.Internals; using FileFormatWavefront.Model; +using PCLStorage; +using Splat; namespace FileFormatWavefront { @@ -23,10 +24,18 @@ public static class FileFormatMtl /// The results of the file load. public static FileLoadResult> Load(string path, bool loadTextureImages) { + var file = FileSystem.Current.GetFileFromPathAsync(path).Result; + + if (file == null) throw new FileNotFoundException("File not found", path); + // Create a streamreader and read the data. - using(var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) - using (var streamReader = new StreamReader(stream)) - return Read(streamReader, path, loadTextureImages); + using (var stream = file.OpenAsync(FileAccess.Read).Result) + { + using(var streamReader = new StreamReader(stream)) + { + return Read(streamReader, path, loadTextureImages); + } + } } /// @@ -180,7 +189,10 @@ private static TextureMap ReadTextureMap(string fileName, int lineNumber, List public static FileLoadResult Load(string path, bool loadTextureImages) { - // Create a stream reader. - using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read)) + var file = FileSystem.Current.GetFileFromPathAsync(path).Result; + + if (file == null) throw new FileNotFoundException("File not found", path); + + // Create a streamreader and read the data. + using (var stream = file.OpenAsync(FileAccess.Read).Result) { - using (var reader = new StreamReader(stream)) + using (var streamReader = new StreamReader(stream)) { - // Read the scene. - return ReadScene(reader, path, loadTextureImages); + return ReadScene(streamReader, path, loadTextureImages); } } } diff --git a/source/FileFormatWavefront/FileFormatWavefront.csproj b/source/FileFormatWavefront/FileFormatWavefront.csproj index da8472b..f9de166 100644 --- a/source/FileFormatWavefront/FileFormatWavefront.csproj +++ b/source/FileFormatWavefront/FileFormatWavefront.csproj @@ -11,6 +11,9 @@ FileFormatWavefront v4.0 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile111 + v4.5 true @@ -31,16 +34,21 @@ bin\Release\FileFormatWavefront.XML - - - - - - - - + + ..\packages\PCLStorage.1.0.2\lib\portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac\PCLStorage.dll + True + + + ..\packages\PCLStorage.1.0.2\lib\portable-net45+wp8+wpa81+win8+monoandroid+monotouch+Xamarin.iOS+Xamarin.Mac\PCLStorage.Abstractions.dll + True + + + ..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll + True + + @@ -59,7 +67,10 @@ - + + + +