[banshee] IO: More reuse of FolderSeparator constants
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] IO: More reuse of FolderSeparator constants
- Date: Sun, 22 Jan 2012 16:35:12 +0000 (UTC)
commit c70e7bd280eb45d46e6bda0d3bf77ee2c107068d
Author: Andres G. Aragoneses <knocte gmail com>
Date: Sun Jan 22 16:33:14 2012 +0000
IO: More reuse of FolderSeparator constants
DosSeparator and UnixSeparator constants can be moved
even higher in the dependency tree because MassStorageDevice
and DeviceMediaCapabilities classes also use them.
.../DeviceMediaCapabilities.cs | 4 ++--
src/Core/Banshee.Core/Banshee.IO/Directory.cs | 3 +++
.../Banshee.Playlists.Formats/M3uPlaylistFormat.cs | 5 +++--
.../PlaylistFormatBase.cs | 8 +++-----
.../Banshee.Dap.MassStorage/MassStorageDevice.cs | 7 ++++---
5 files changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/DeviceMediaCapabilities.cs b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/DeviceMediaCapabilities.cs
index 43d744f..5b84be1 100644
--- a/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/DeviceMediaCapabilities.cs
+++ b/src/Backends/Banshee.Gio/Banshee.Hardware.Gio/DeviceMediaCapabilities.cs
@@ -232,7 +232,7 @@ namespace Banshee.Hardware.Gio
if (mpi_file.HasKey (PlaylistGroup, "FolderSeparator")) {
string folder_separator = mpi_file.GetString (PlaylistGroup, "FolderSeparator");
if (folder_separator == "DOS") {
- FolderSeparator = '\\';
+ FolderSeparator = Directory.DosSeparator;
}
}
}
@@ -251,7 +251,7 @@ namespace Banshee.Hardware.Gio
OutputFormats = new string[] {};
PlaylistFormats = new string[] {};
AccessProtocols = new string[] {};
- FolderSeparator = '/';
+ FolderSeparator = Directory.UnixSeparator;
}
}
}
diff --git a/src/Core/Banshee.Core/Banshee.IO/Directory.cs b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
index 0fb479c..a44673a 100644
--- a/src/Core/Banshee.Core/Banshee.IO/Directory.cs
+++ b/src/Core/Banshee.Core/Banshee.IO/Directory.cs
@@ -35,6 +35,9 @@ namespace Banshee.IO
{
public static class Directory
{
+ public const char DosSeparator = '\\';
+ public const char UnixSeparator = '/';
+
public static bool Exists (string directory)
{
return Provider.Directory.Exists (Provider.GetPath (directory));
diff --git a/src/Core/Banshee.Services/Banshee.Playlists.Formats/M3uPlaylistFormat.cs b/src/Core/Banshee.Services/Banshee.Playlists.Formats/M3uPlaylistFormat.cs
index eaf3759..031bbb9 100644
--- a/src/Core/Banshee.Services/Banshee.Playlists.Formats/M3uPlaylistFormat.cs
+++ b/src/Core/Banshee.Services/Banshee.Playlists.Formats/M3uPlaylistFormat.cs
@@ -35,6 +35,7 @@ using Mono.Unix;
using Banshee.Base;
using Banshee.Collection;
using Banshee.Sources;
+using Folder = Banshee.IO.Directory;
namespace Banshee.Playlists.Formats
{
@@ -123,8 +124,8 @@ namespace Banshee.Playlists.Formats
writer.WriteLine("#EXTINF:{0},{1} - {2}", duration, track.DisplayArtistName, track.DisplayTrackTitle);
string trackpath = ExportUri (track.Uri);
- if (FolderSeparator == DosFolderSeparator) {
- trackpath = trackpath.Replace (UnixFolderSeparator, DosFolderSeparator);
+ if (FolderSeparator == Folder.DosSeparator) {
+ trackpath = trackpath.Replace (Folder.UnixSeparator, Folder.DosSeparator);
}
writer.WriteLine( trackpath );
}
diff --git a/src/Core/Banshee.Services/Banshee.Playlists.Formats/PlaylistFormatBase.cs b/src/Core/Banshee.Services/Banshee.Playlists.Formats/PlaylistFormatBase.cs
index c07469a..2889100 100644
--- a/src/Core/Banshee.Services/Banshee.Playlists.Formats/PlaylistFormatBase.cs
+++ b/src/Core/Banshee.Services/Banshee.Playlists.Formats/PlaylistFormatBase.cs
@@ -34,14 +34,12 @@ using Hyena;
using Banshee.Base;
using Banshee.Sources;
+using Folder = Banshee.IO.Directory;
namespace Banshee.Playlists.Formats
{
public abstract class PlaylistFormatBase : IPlaylistFormat
{
- protected const char DosFolderSeparator = '\\';
- protected const char UnixFolderSeparator = '/';
-
private Dictionary<string, object> attributes = new Dictionary<string, object>();
private List<Dictionary<string, object>> elements = new List<Dictionary<string, object>>();
private Uri base_uri = null;
@@ -81,8 +79,8 @@ namespace Banshee.Playlists.Formats
protected virtual Uri ResolveUri(string uri)
{
- if (!uri.Contains (UnixFolderSeparator.ToString ()) && uri.Contains (DosFolderSeparator.ToString ())) {
- uri = uri.Replace (DosFolderSeparator, UnixFolderSeparator);
+ if (!uri.Contains (Folder.UnixSeparator.ToString ()) && uri.Contains (Folder.DosSeparator.ToString ())) {
+ uri = uri.Replace (Folder.DosSeparator, Folder.UnixSeparator);
}
return BaseUri == null ? new Uri(uri) : new Uri(BaseUri, uri);
}
diff --git a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
index 2da4448..9ac3fc3 100644
--- a/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
+++ b/src/Dap/Banshee.Dap.MassStorage/Banshee.Dap.MassStorage/MassStorageDevice.cs
@@ -39,6 +39,7 @@ using Banshee.Base;
using Banshee.Hardware;
using Banshee.Collection;
using Banshee.Collection.Database;
+using Folder = Banshee.IO.Directory;
namespace Banshee.Dap.MassStorage
{
@@ -124,10 +125,10 @@ namespace Banshee.Dap.MassStorage
folder_depth = GetPreferredValue ("folder_depth", config, DefaultFolderDepth);
string preferred_folder_separator = GetPreferredValue ("folder_separator", config, DefaultFolderSeparator);
- if (preferred_folder_separator == "\\" || preferred_folder_separator == "DOS") {
- folder_separator = '\\';
+ if (preferred_folder_separator == Folder.DosSeparator.ToString () || preferred_folder_separator == "DOS") {
+ folder_separator = Folder.DosSeparator;
} else {
- folder_separator = '/';
+ folder_separator = Folder.UnixSeparator;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]