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, 16 insertions, 9 deletions
diff --git a/Prebuild/src/Core/Utilities/Helper.cs b/Prebuild/src/Core/Utilities/Helper.cs
index 9a0d131..19093ce 100644
--- a/Prebuild/src/Core/Utilities/Helper.cs
+++ b/Prebuild/src/Core/Utilities/Helper.cs
@@ -23,6 +23,15 @@ 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
26using System; 35using System;
27using System.Collections; 36using System.Collections;
28using System.Diagnostics; 37using System.Diagnostics;
@@ -280,8 +289,6 @@ namespace Prebuild.Core.Utilities
280 return true; 289 return true;
281 } 290 }
282 291
283 static readonly char seperator = Path.DirectorySeparatorChar;
284
285 // This little gem was taken from the NeL source, thanks guys! 292 // This little gem was taken from the NeL source, thanks guys!
286 /// <summary> 293 /// <summary>
287 /// Makes a relative path 294 /// Makes a relative path
@@ -291,8 +298,8 @@ namespace Prebuild.Core.Utilities
291 /// <returns>Path that will get from startPath to endPath</returns> 298 /// <returns>Path that will get from startPath to endPath</returns>
292 public static string MakePathRelativeTo(string startPath, string endPath) 299 public static string MakePathRelativeTo(string startPath, string endPath)
293 { 300 {
294 string tmp = NormalizePath(startPath, seperator); 301 string tmp = NormalizePath(startPath, '/');
295 string src = NormalizePath(endPath, seperator); 302 string src = NormalizePath(endPath, '/');
296 string prefix = ""; 303 string prefix = "";
297 304
298 while(true) 305 while(true)
@@ -305,14 +312,14 @@ namespace Prebuild.Core.Utilities
305 { 312 {
306 return "./"; 313 return "./";
307 } 314 }
308 if((src.Length > tmp.Length) && src[tmp.Length - 1] != seperator) 315 if ((src.Length > tmp.Length) && src[tmp.Length-1] != '/' && src[tmp.Length-1] != '\\')
309 { 316 {
310 } 317 }
311 else 318 else
312 { 319 {
313 ret = prefix + endPath.Substring(size, endPath.Length - size); 320 ret = prefix + endPath.Substring(size, endPath.Length - size);
314 ret = ret.Trim(); 321 ret = ret.Trim();
315 if(ret[0] == seperator) 322 if(ret[0] == '/' || ret[0] == '\\')
316 { 323 {
317 ret = "." + ret; 324 ret = "." + ret;
318 } 325 }
@@ -327,8 +334,8 @@ namespace Prebuild.Core.Utilities
327 break; 334 break;
328 } 335 }
329 336
330 int lastPos = tmp.LastIndexOf(seperator, tmp.Length - 2); 337 int lastPos = tmp.LastIndexOf('/', tmp.Length - 2);
331 int prevPos = tmp.IndexOf(seperator); 338 int prevPos = tmp.IndexOf('/');
332 339
333 if((lastPos == prevPos) || (lastPos == -1)) 340 if((lastPos == prevPos) || (lastPos == -1))
334 { 341 {
@@ -336,7 +343,7 @@ namespace Prebuild.Core.Utilities
336 } 343 }
337 344
338 tmp = tmp.Substring(0, lastPos + 1); 345 tmp = tmp.Substring(0, lastPos + 1);
339 prefix += ".." + seperator.ToString(); 346 prefix += "../";
340 } 347 }
341 348
342 return endPath; 349 return endPath;