/// <summary> /// Recursively fills the pathBuilder with the full path /// </summary> /// <param name="pathBuilder">a StringBuilder used to create the path.</param> /// <param name="escapePath">Whether the path need to be escaped for consumption by a shell command line.</param> /// <param name="resolveLinks">if set to <see langword="true"/> [resolve links].</param> protected void FillPathBuilder(StringBuilder pathBuilder, bool escapePath, bool resolveLinks) { if (IsRoot) { return; } // If the symlink is an absolute path, we don't need to recurse. if (resolveLinks && !string.IsNullOrEmpty(LinkName) && LinuxPath.IsPathRooted(LinkName)) { pathBuilder.Append(escapePath ? LinuxPath.Quote(LinkName) : LinkName); } else { // Else, get the path of the parent. if (Parent != null) { Parent.FillPathBuilder(pathBuilder, escapePath, resolveLinks); } String n = resolveLinks && !String.IsNullOrEmpty(LinkName) ? LinkName : Name; if (n[0] != LinuxPath.DirectorySeparatorChar) { pathBuilder.Append(LinuxPath.DirectorySeparatorChar); } pathBuilder.Append(escapePath ? LinuxPath.Quote(n) : n); } }
public void IsPathRooted() { Assert.True(LinuxPath.IsPathRooted("\\one\\two\\three.txt")); Assert.True(LinuxPath.IsPathRooted("/one/two/three.txt")); Assert.False(LinuxPath.IsPathRooted("one\\two\\three")); Assert.False(LinuxPath.IsPathRooted("one/two/three")); }
public void IsPathRootedTest() { bool result = LinuxPath.IsPathRooted("/system/busybox"); Assert.AreEqual <bool>(true, result); result = LinuxPath.IsPathRooted("/system/xbin/"); Assert.AreEqual <bool>(true, result); result = LinuxPath.IsPathRooted("system/xbin/"); Assert.AreEqual <bool>(false, result); }
public void IsPathRootedTest() { Assert.True(LinuxPath.IsPathRooted("/system/busybox")); Assert.True(LinuxPath.IsPathRooted("/system/xbin/")); Assert.False(LinuxPath.IsPathRooted("system/xbin/")); }