From 27cc689176ae84a8be268fff08f4aec7c1d7f1d6 Mon Sep 17 00:00:00 2001 From: adelikat Date: Wed, 27 Nov 2013 21:45:50 +0000 Subject: [PATCH] Merge r5447 to trunk --- BizHawk.Client.Common/movie/Movie.cs | 12 ++++++++---- BizHawk.Client.EmuHawk/movie/PlayMovie.cs | 10 +++++----- BizHawk.Client.EmuHawk/movie/RecordMovie.cs | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.Common/movie/Movie.cs b/BizHawk.Client.Common/movie/Movie.cs index 506103f5ac..95952556c5 100644 --- a/BizHawk.Client.Common/movie/Movie.cs +++ b/BizHawk.Client.Common/movie/Movie.cs @@ -1,7 +1,7 @@ using System; using System.IO; using System.Globalization; - +using BizHawk.Common; using BizHawk.Emulation.Common; using System.Collections.Generic; @@ -298,10 +298,10 @@ namespace BizHawk.Client.Common /// Load Header information only for displaying file information in dialogs such as play movie /// /// - public bool PreLoadText() + public bool PreLoadText(HawkFile hawkFile) { Loaded = false; - var file = new FileInfo(Filename); + var file = new FileInfo(hawkFile.CanonicalFullPath); if (file.Exists == false) return false; @@ -311,7 +311,10 @@ namespace BizHawk.Client.Common _log.Clear(); } - using (StreamReader sr = file.OpenText()) + long origStreamPosn = hawkFile.GetStream().Position; + hawkFile.GetStream().Position = 0; //Reset to start + StreamReader sr = new StreamReader(hawkFile.GetStream()); //No using block because we're sharing the stream and need to give it back undisposed. + if(!sr.EndOfStream) { string str; while ((str = sr.ReadLine()) != null) @@ -346,6 +349,7 @@ namespace BizHawk.Client.Common } } } + hawkFile.GetStream().Position = origStreamPosn; return true; } diff --git a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs index 0fc077455e..cf5ffdbbd9 100644 --- a/BizHawk.Client.EmuHawk/movie/PlayMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/PlayMovie.cs @@ -171,15 +171,15 @@ namespace BizHawk.Client.EmuHawk return 0; } - private void PreLoadMovieFile(HawkFile path, bool force) + private void PreLoadMovieFile(HawkFile hf, bool force) { - Movie movie = new Movie(path.CanonicalFullPath); - movie.PreLoadText(); - if (path.Extension == ".FM2") + Movie movie = new Movie(hf.CanonicalFullPath); + movie.PreLoadText(hf); + if (hf.Extension == ".FM2") { movie.Header.SetHeaderLine(MovieHeader.PLATFORM, "NES"); } - else if (path.Extension == ".MC2") + else if (hf.Extension == ".MC2") { movie.Header.SetHeaderLine(MovieHeader.PLATFORM, "PCE"); } diff --git a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs index 18e4c133aa..16e022873f 100644 --- a/BizHawk.Client.EmuHawk/movie/RecordMovie.cs +++ b/BizHawk.Client.EmuHawk/movie/RecordMovie.cs @@ -30,10 +30,10 @@ namespace BizHawk.Client.EmuHawk if (RecordBox.Text.Length == 0) return ""; string path = RecordBox.Text; - if (path.LastIndexOf('\\') == -1) + if (path.LastIndexOf(Path.DirectorySeparatorChar) == -1) { - if (path[0] != '\\') - path = path.Insert(0, "\\"); + if (path[0] != Path.DirectorySeparatorChar) + path = path.Insert(0, Path.DirectorySeparatorChar.ToString()); path = PathManager.MakeAbsolutePath(Global.Config.PathEntries.MoviesPath, null) + path; if (path[path.Length - 4] != '.') //If no file extension, add movie extension