コード例 #1
0
ファイル: GetAbsPath.cs プロジェクト: teotikalki/tasque
 internal static string InternalGetAbsPath(string path)
 {
     if (path == null)
     {
         throw new ArgumentNullException("path");
     }
     path = System.IO.Path.GetFullPath(path);
     return(NormalizePath.InternalNormalizePath(path));
 }
コード例 #2
0
ファイル: GetRelPath.cs プロジェクト: teotikalki/tasque
        internal static string InternalGetRelPath(string fromPath, string toPath)
        {
            if (fromPath == null)
            {
                throw new ArgumentNullException("fromPath");
            }
            if (toPath == null)
            {
                throw new ArgumentNullException("toPath");
            }

            // normalize
            fromPath = NormalizePath.InternalNormalizePath(Path.GetFullPath(fromPath));
            toPath   = NormalizePath.InternalNormalizePath(Path.GetFullPath(toPath));

            var basePathPieces   = fromPath.Split(Path.DirectorySeparatorChar);
            var targetPathPieces = toPath.Split(Path.DirectorySeparatorChar);

            var max = Math.Min(basePathPieces.Length, targetPathPieces.Length);
            int i   = 0;

            for (; i < max; i++)
            {
                if (basePathPieces [i] != targetPathPieces [i])
                {
                    break;
                }
            }

            StringBuilder fromBranch = new StringBuilder(), toBranch = new StringBuilder();

            for (int j = i; j < basePathPieces.Length; j++)
            {
                fromBranch.Append(".." + Path.DirectorySeparatorChar.ToString());
            }
            for (int j = i; j < targetPathPieces.Length; j++)
            {
                toBranch.Append(targetPathPieces [j] + Path.DirectorySeparatorChar.ToString());
            }

            var toBranchString = toBranch.ToString();
            var result = fromBranch.Append(toBranchString).ToString();

            return(result.TrimEnd(Path.DirectorySeparatorChar));
        }
コード例 #3
0
ファイル: GetAbsSrcDir.cs プロジェクト: teotikalki/tasque
        public override bool Execute()
        {
            try {
                if (!Path.IsPathRooted(AbsTopSrcDir))
                {
                    throw new Exception("AbsTopSrcDir must be an absolute path.");
                }

                // normalize paths
                var topSrcPath = NormalizePath.InternalNormalizePath(AbsTopSrcDir);

                AbsSrcDir = Path.Combine(topSrcPath, SrcDirStrip);
            } catch (Exception ex) {
                Log.LogErrorFromException(ex, true);
                return(false);
            }
            return(true);
        }