Ejemplo n.º 1
0
        public static string GetCompleteRealPath(string path)
        {
            string[] strArrays;
            int      num;

            if (path == null)
            {
                throw new ArgumentNullException("path");
            }
            UnixPath.GetPathComponents(path, out strArrays, out num);
            StringBuilder stringBuilder = new StringBuilder();

            if ((int)strArrays.Length > 0)
            {
                string str = string.Concat((!UnixPath.IsPathRooted(path) ? string.Empty : "/"), strArrays[0]);
                stringBuilder.Append(UnixPath.GetRealPath(str));
            }
            for (int i = 1; i < num; i++)
            {
                stringBuilder.Append("/").Append(strArrays[i]);
                string realPath = UnixPath.GetRealPath(stringBuilder.ToString());
                stringBuilder.Remove(0, stringBuilder.Length);
                stringBuilder.Append(realPath);
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 2
0
        public static string GetCanonicalPath(string path)
        {
            string[] strArrays;
            int      num;

            UnixPath.GetPathComponents(path, out strArrays, out num);
            string str = string.Join("/", strArrays, 0, num);

            return(!UnixPath.IsPathRooted(path) ? str : string.Concat("/", str));
        }
Ejemplo n.º 3
0
 private static string _GetFullPath(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     if (!UnixPath.IsPathRooted(path))
     {
         path = string.Concat(UnixDirectoryInfo.GetCurrentDirectory(), UnixPath.DirectorySeparatorChar, path);
     }
     return(path);
 }
Ejemplo n.º 4
0
 public static string GetPathRoot(string path)
 {
     if (path == null)
     {
         return(null);
     }
     if (!UnixPath.IsPathRooted(path))
     {
         return(string.Empty);
     }
     return("/");
 }
Ejemplo n.º 5
0
        public static string Combine(string path1, params string[] paths)
        {
            if (path1 == null)
            {
                throw new ArgumentNullException("path1");
            }
            if (paths == null)
            {
                throw new ArgumentNullException("paths");
            }
            if (path1.IndexOfAny(UnixPath._InvalidPathChars) != -1)
            {
                throw new ArgumentException("Illegal characters in path", "path1");
            }
            int length = path1.Length;
            int num    = -1;

            for (int i = 0; i < (int)paths.Length; i++)
            {
                if (paths[i] == null)
                {
                    throw new ArgumentNullException(string.Concat("paths[", i, "]"));
                }
                if (paths[i].IndexOfAny(UnixPath._InvalidPathChars) != -1)
                {
                    throw new ArgumentException("Illegal characters in path", string.Concat("paths[", i, "]"));
                }
                if (UnixPath.IsPathRooted(paths[i]))
                {
                    length = 0;
                    num    = i;
                }
                length = length + paths[i].Length + 1;
            }
            StringBuilder stringBuilder = new StringBuilder(length);

            if (num == -1)
            {
                stringBuilder.Append(path1);
                num = 0;
            }
            for (int j = num; j < (int)paths.Length; j++)
            {
                UnixPath.Combine(stringBuilder, paths[j]);
            }
            return(stringBuilder.ToString());
        }
Ejemplo n.º 6
0
 public static string GetRealPath(string path)
 {
     while (true)
     {
         string str = UnixPath.ReadSymbolicLink(path);
         if (str == null)
         {
             break;
         }
         if (!UnixPath.IsPathRooted(str))
         {
             path = string.Concat(UnixPath.GetDirectoryName(path), UnixPath.DirectorySeparatorChar, str);
             path = UnixPath.GetCanonicalPath(path);
         }
         else
         {
             path = str;
         }
     }
     return(path);
 }