aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Prebuild/src/Core/Utilities/Helper.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Prebuild/src/Core/Utilities/Helper.cs')
-rw-r--r--Prebuild/src/Core/Utilities/Helper.cs25
1 files changed, 9 insertions, 16 deletions
diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs
index 19093ce..9a0d131 100644
--- a/Prebuild/src/Core/Utilities/Helper.cs
+++ b/Prebuild/src/Core/Utilities/Helper.cs
@@ -23,15 +23,6 @@ IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY O
23*/ 23*/
24#endregion 24#endregion
25 25
26#region CVS Information
27/*
28 * $Source$
29 * $Author: jendave $
30 * $Date: 2007-02-14 05:58:03 +0900 (Wed, 14 Feb 2007) $
31 * $Revision: 205 $
32 */
33#endregion
34
35using System; 26using System;
36using System.Collections; 27using System.Collections;
37using System.Diagnostics; 28using System.Diagnostics;
@@ -289,6 +280,8 @@ namespace Prebuild.Core.Utilities
289 return true; 280 return true;
290 } 281 }
291 282
283 static readonly char seperator = Path.DirectorySeparatorChar;
284
292 // This little gem was taken from the NeL source, thanks guys! 285 // This little gem was taken from the NeL source, thanks guys!
293 /// <summary> 286 /// <summary>
294 /// Makes a relative path 287 /// Makes a relative path
@@ -298,8 +291,8 @@ namespace Prebuild.Core.Utilities
298 /// <returns>Path that will get from startPath to endPath</returns> 291 /// <returns>Path that will get from startPath to endPath</returns>
299 public static string MakePathRelativeTo(string startPath, string endPath) 292 public static string MakePathRelativeTo(string startPath, string endPath)
300 { 293 {
301 string tmp = NormalizePath(startPath, '/'); 294 string tmp = NormalizePath(startPath, seperator);
302 string src = NormalizePath(endPath, '/'); 295 string src = NormalizePath(endPath, seperator);
303 string prefix = ""; 296 string prefix = "";
304 297
305 while(true) 298 while(true)
@@ -312,14 +305,14 @@ namespace Prebuild.Core.Utilities
312 { 305 {
313 return "./"; 306 return "./";
314 } 307 }
315 if ((src.Length > tmp.Length) && src[tmp.Length-1] != '/' && src[tmp.Length-1] != '\\') 308 if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator)
316 { 309 {
317 } 310 }
318 else 311 else
319 { 312 {
320 ret = prefix + endPath.Substring(size, endPath.Length - size); 313 ret = prefix + endPath.Substring(size, endPath.Length - size);
321 ret = ret.Trim(); 314 ret = ret.Trim();
322 if(ret[0] == '/' || ret[0] == '\\') 315 if(ret[0] == seperator)
323 { 316 {
324 ret = "." + ret; 317 ret = "." + ret;
325 } 318 }
@@ -334,8 +327,8 @@ namespace Prebuild.Core.Utilities
334 break; 327 break;
335 } 328 }
336 329
337 int lastPos = tmp.LastIndexOf('/', tmp.Length - 2); 330 int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2);
338 int prevPos = tmp.IndexOf('/'); 331 int prevPos = tmp.IndexOf(seperator);
339 332
340 if((lastPos == prevPos) || (lastPos == -1)) 333 if((lastPos == prevPos) || (lastPos == -1))
341 { 334 {
@@ -343,7 +336,7 @@ namespace Prebuild.Core.Utilities
343 } 336 }
344 337
345 tmp = tmp.Substring(0, lastPos + 1); 338 tmp = tmp.Substring(0, lastPos + 1);
346 prefix += "../"; 339 prefix += ".." + seperator.ToString();
347 } 340 }
348 341
349 return endPath; 342 return endPath;