[hyena] Paths: add new SwitchRoot method
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [hyena] Paths: add new SwitchRoot method
- Date: Sun, 13 Jan 2013 02:01:13 +0000 (UTC)
commit a2f18e52e618bc7aa3f6ad3aa66072acbe89f9e2
Author: Andres G. Aragoneses <knocte gmail com>
Date: Sun Jan 13 02:01:04 2013 +0000
Paths: add new SwitchRoot method
This method will be used to switch the mount point of a path with a
different one. Example:
SwitchRoot ("/foo/bar/", "/foo", "/baz") == "/baz/bar"
First usage of it will be in Banshee, in an upcoming
patch for N95 playlists support (bgo#661507).
Hyena/Hyena/Paths.cs | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/Hyena/Hyena/Paths.cs b/Hyena/Hyena/Paths.cs
index c2368dd..1fe3472 100644
--- a/Hyena/Hyena/Paths.cs
+++ b/Hyena/Hyena/Paths.cs
@@ -116,6 +116,14 @@ namespace Hyena
return path.Split (UnixSeparator);
}
+ public static string SwitchRoot (string path, string mountPoint, string rootPath)
+ {
+ if (!path.StartsWith (mountPoint)) {
+ throw new ArgumentException ("mountPoint must be contained in first part of the path");
+ }
+ return path.Replace (mountPoint, rootPath);
+ }
+
public static string MakePathRelative (string path, string to)
{
if (String.IsNullOrEmpty (path) || String.IsNullOrEmpty (to)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]