public override bool HasCommonRoot(FileLocator 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); }
/// <summary> /// Opens the specified file. /// </summary> /// <param name="path">The full path of the file to open.</param> /// <param name="mode">The file mode for the created stream.</param> /// <param name="access">The access permissions for the created stream.</param> /// <returns>The new stream.</returns> public override SparseStream OpenFile(string path, FileMode mode, FileAccess access) { if (_readOnly && access != FileAccess.Read) { throw new UnauthorizedAccessException(); } if (path.StartsWith(@"\", StringComparison.OrdinalIgnoreCase)) { path = path.Substring(1); } FileShare fileShare = FileShare.None; if (access == FileAccess.Read) { fileShare = FileShare.Read; } var locator = new LocalFileLocator(BasePath); return(SparseStream.FromStream(locator.Open(path, mode, access, fileShare), Ownership.Dispose)); }