예제 #1
0
파일: FileEntry.cs 프로젝트: sttt/madb
        /// <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);
            }
        }
예제 #2
0
        public void WhenValueDoesNotHaveSpace_ShouldReturnValue( )
        {
            var fixture = new Fixture( );

            var val    = fixture.Create("value-");
            var result = LinuxPath.Quote(val);

            Assert.Equal(val, result);
        }
예제 #3
0
        public void WhenValueHasSpace_ShouldReturnQuotedValue()
        {
            var fixture = new Fixture( );

            var val    = fixture.Create("value ");
            var result = LinuxPath.Quote(val);

            Assert.Equal("\"{0}\"".With(val), result);
        }
예제 #4
0
        /// <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 <c>true</c> [resolve links].</param>
        protected void FillPathBuilder(StringBuilder pathBuilder, bool escapePath, bool resolveLinks)
        {
            if (IsRoot)
            {
                return;
            }

            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);
        }
예제 #5
0
        public void WhenValueIsEmpty_ShouldReturnEmpty()
        {
            var result = LinuxPath.Quote(string.Empty);

            Assert.Equal(string.Empty, result);
        }
예제 #6
0
        public void WhenValueIsNull_ShouldReturnNull( )
        {
            var result = LinuxPath.Quote(null);

            Assert.Null(result);
        }