Skip to content

Commit

Permalink
Make use of FileHelpers.NormalizeFilePathSeparators
Browse files Browse the repository at this point in the history
  • Loading branch information
danzel committed May 18, 2014
1 parent 035e1c9 commit bb79335
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 58 deletions.
11 changes: 2 additions & 9 deletions MonoGame.Framework/Audio/SoundBank.cs
Expand Up @@ -5,6 +5,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Utilities;

namespace Microsoft.Xna.Framework.Audio
{
Expand All @@ -25,15 +26,7 @@ public class SoundBank : IDisposable
/// <param name="fileName">Path to a .xsb SoundBank file.</param>
public SoundBank(AudioEngine audioEngine, string fileName)
{
#if WINRT
const char notSeparator = '/';
const char separator = '\\';
#else
const char notSeparator = '\\';
var separator = Path.DirectorySeparatorChar;
#endif
// Check for windows-style directory separator character
filename = fileName.Replace(notSeparator, separator);
filename = FileHelpers.NormalizeFilePathSeparators(fileName);
audioengine = audioEngine;
}

Expand Down
15 changes: 4 additions & 11 deletions MonoGame.Framework/Audio/WaveBank.cs
Expand Up @@ -28,8 +28,9 @@ MIT License
using System;
using System.IO;

using Microsoft.Xna.Framework;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Utilities;

namespace Microsoft.Xna.Framework.Audio
{
/// <summary>Represents a collection of wave files.</summary>
Expand Down Expand Up @@ -105,15 +106,7 @@ public WaveBank(AudioEngine audioEngine, string nonStreamingWaveBankFilename)

int wavebank_offset = 0;

#if WINRT
const char notSeparator = '/';
const char separator = '\\';
#else
const char notSeparator = '\\';
var separator = Path.DirectorySeparatorChar;
#endif
// Check for windows-style directory separator character
nonStreamingWaveBankFilename = nonStreamingWaveBankFilename.Replace(notSeparator, separator);
nonStreamingWaveBankFilename = FileHelpers.NormalizeFilePathSeparators(nonStreamingWaveBankFilename);

#if !ANDROID
BinaryReader reader = new BinaryReader(TitleContainer.OpenStream(nonStreamingWaveBankFilename));
Expand Down
11 changes: 2 additions & 9 deletions MonoGame.Framework/Content/ContentReader.cs
Expand Up @@ -148,17 +148,10 @@ public T ReadExternalReference<T>()

if (!String.IsNullOrEmpty(externalReference))
{
#if WINRT
const char notSeparator = '/';
const char separator = '\\';
#else
const char notSeparator = '\\';
var separator = Path.DirectorySeparatorChar;
#endif
externalReference = externalReference.Replace(notSeparator, separator);
externalReference = FileHelpers.NormalizeFilePathSeparators(externalReference);

// Get a uri for the asset path using the file:// schema and no host
var src = new Uri("file:///" + assetName.Replace(notSeparator, separator));
var src = new Uri("file:///" + FileHelpers.NormalizeFilePathSeparators(assetName));

// Add the relative path to the external reference
var dst = new Uri(src, externalReference);
Expand Down
12 changes: 3 additions & 9 deletions MonoGame.Framework/Content/ContentReaders/SongReader.cs
Expand Up @@ -43,6 +43,7 @@
using System.IO;

using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Utilities;

namespace Microsoft.Xna.Framework.Content
{
Expand All @@ -65,17 +66,10 @@ protected internal override Song Read(ContentReader input, Song existingInstance

if (!String.IsNullOrEmpty(path))
{
#if WINRT
const char notSeparator = '/';
const char separator = '\\';
#else
const char notSeparator = '\\';
var separator = Path.DirectorySeparatorChar;
#endif
path = path.Replace(notSeparator, separator);
path = FileHelpers.NormalizeFilePathSeparators(path);

// Get a uri for the asset path using the file:// schema and no host
var src = new Uri("file:///" + input.AssetName.Replace(notSeparator, separator));
var src = new Uri("file:///" + FileHelpers.NormalizeFilePathSeparators(input.AssetName));

// Add the relative path to the external reference
var dst = new Uri(src, path);
Expand Down
16 changes: 4 additions & 12 deletions MonoGame.Framework/TitleContainer.cs
Expand Up @@ -41,7 +41,6 @@
using System;
using System.IO;
using System.Text;

#if WINRT
using System.Threading.Tasks;
#elif IOS
Expand All @@ -51,8 +50,9 @@
using MonoMac.Foundation;
#elif PSM
using Sce.PlayStation.Core;
#endif

#endif
using Microsoft.Xna.Framework.Utilities;

namespace Microsoft.Xna.Framework
{
public static class TitleContainer
Expand Down Expand Up @@ -148,15 +148,7 @@ public static Stream OpenStream(string name)
// this same logic is duplicated all over the code base.
internal static string GetFilename(string name)
{
#if WINRT
const char notSeparator = '/';
const char separator = '\\';
#else
const char notSeparator = '\\';
var separator = Path.DirectorySeparatorChar;
#endif

return new Uri("file:///" + name).LocalPath.Substring(1).Replace(notSeparator, separator);
return FileHelpers.NormalizeFilePathSeparators(new Uri("file:///" + name).LocalPath.Substring(1));
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions MonoGame.Framework/Utilities/FileHelpers.cs
Expand Up @@ -32,7 +32,7 @@ internal static class FileHelpers

#region public properties

#if WINRT
#if WINRT
public static char notSeparator = '/';
public static char separator = '\\';
#else
Expand Down Expand Up @@ -206,14 +206,9 @@ public static string NormalizeFilename(string fileName, string[] extensions)
}

// Renamed from - public static string GetFilename(string name)
public static string NormalizeFilePathSeperators(string name)
public static string NormalizeFilePathSeparators(string name)
{
#if WINRT
name = name.Replace('/', '\\');
#else
name = name.Replace('\\', Path.DirectorySeparatorChar);
#endif
return name;
return name.Replace(notSeparator, separator);
}


Expand Down

2 comments on commit bb79335

@mgbot
Copy link
Member

@mgbot mgbot commented on bb79335 May 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MonoGame :: Develop (Win) Build 548 is now running

@mgbot
Copy link
Member

@mgbot mgbot commented on bb79335 May 18, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity MonoGame :: Develop (Win) Build 548 outcome was SUCCESS
Summary: Running Build time: 00:07:06

Please sign in to comment.