Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileLocator"></param>
        /// <param name="path"></param>
        /// <returns></returns>
        public string MakeRelativePath(IFileLocator fileLocator, string path)
        {
            if (!HasCommonRoot(fileLocator))
            {
                return(null);
            }

            string ourFullPath   = GetFullPath(string.Empty) + @"\";
            string otherFullPath = fileLocator.GetFullPath(path);

            return(Util.MakeRelativePath(otherFullPath, ourFullPath));
        }
Esempio n. 2
0
        /// <summary>
        /// Checks if this locator has a common root with another locator.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool HasCommonRoot(IFileLocator other)
        {
            LocalFileLocator otherLocal = other as LocalFileLocator;

            if (otherLocal == null)
            {
                return(false);
            }

            // if the paths have drive specifiers, then common root depends on them having a common
            // drive letter.
            string otherDir = otherLocal.dir;

            if (otherDir.Length >= 2 && dir.Length >= 2)
            {
                if (otherDir[1] == ':' && dir[1] == ':')
                {
                    return(Char.ToUpperInvariant(otherDir[0]) == Char.ToUpperInvariant(dir[0]));
                }
            }

            return(true);
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LocalFileLocator"/> class.
 /// </summary>
 /// <param name="dir"></param>
 public LocalFileLocator(IFileLocator basePath, string dir)
 {
     this.dir = basePath.GetFullPath(dir);
 }
Esempio n. 4
0
 /// <summary>
 /// Checks if this locator has a common root with another locator.
 /// </summary>
 /// <param name="other"></param>
 /// <returns></returns>
 public abstract bool HasCommonRoot(IFileLocator other);