示例#1
0
        public static string ExtractPath(string uri, params string[] additional)
        {
            var index = uri.IndexOf(MakeFileUri.Scheme);

            if (-1 == index)
            {
                return(MakeFileUri.Combine(uri, additional));
            }

            int skipLength  = MakeFileUri.Scheme.Length;
            int addedLength = MakeFileUri.GetLength(additional);
            var sb          = new StringBuilder(uri.Length + addedLength - skipLength);

            if (skipLength < uri.Length && '/' == uri[skipLength])
            {
                int winIndex = uri.IndexOf(MakeFileUri.WindowsScheme, skipLength + 1);
                if (-1 != winIndex && winIndex < 10)
                {
                    skipLength += 1;
                }
            }

            sb.Append(uri, skipLength, uri.Length - skipLength);
            return(MakeFileUri.Combine(sb, additional));
        }
示例#2
0
        static string Combine(string origin, string[] additional)
        {
            if (string.IsNullOrEmpty(origin))
            {
                return(origin);
            }

            if (null == additional)
            {
                return(origin);
            }

            return(MakeFileUri.Combine(new StringBuilder(origin, origin.Length + MakeFileUri.GetLength(additional)), additional));
        }