/// <summary> /// Inspect a URI and determine the correct root and display URIs /// </summary> protected SleetUriPair GetUriPair(Uri path, bool caseSensitive) { if (path == null) { throw new ArgumentNullException(nameof(path)); } var isRoot = UriUtility.HasRoot(Root, path, caseSensitive); var isDisplay = UriUtility.HasRoot(BaseURI, path, caseSensitive); if (!isRoot && !isDisplay) { throw new InvalidOperationException($"URI does not match the feed root or baseURI: {path.AbsoluteUri}"); } var pair = new SleetUriPair() { BaseURI = path, Root = path }; if (!isRoot) { pair.Root = UriUtility.ChangeRoot(BaseURI, Root, path); } if (!isDisplay) { pair.BaseURI = UriUtility.ChangeRoot(Root, BaseURI, path); } return(pair); }
private ISleetFile CreateAmazonS3File(Uri uri) { Uri rootUri = UriUtility.ChangeRoot(BaseURI, Root, uri); string key = GetPathRelativeToBucket(uri); return(new AmazonS3File(this, rootUri, uri, LocalCache.GetNewTempPath(), client, bucketName, key)); }
public ISleetFile Get(Uri path) { var relativePath = GetRelativePath(path); var blob = _container.GetBlockBlobReference(relativePath); var file = Files.GetOrAdd(path, (uri) => { var rootUri = UriUtility.ChangeRoot(_baseUri, _root, uri); return(new AzureFile( this, rootUri, uri, LocalCache.GetNewTempPath(), blob)); }); return(file); }
public ISleetFile Get(Uri path) { if (path == null) { Debug.Fail("bad path"); throw new ArgumentNullException(nameof(path)); } if (!path.AbsoluteUri.StartsWith(BaseURI.AbsoluteUri)) { throw new ArgumentException(string.Format("Base uri does not match the file system. Url: {0}, Expecting: {1}", path.AbsoluteUri, BaseURI.AbsoluteUri)); } var file = Files.GetOrAdd(path, (uri) => { var rootUri = uri; var displayUri = uri; if (!UriUtility.HasRoot(Root, rootUri)) { rootUri = UriUtility.ChangeRoot(BaseURI, Root, uri); } if (!UriUtility.HasRoot(BaseURI, displayUri)) { displayUri = UriUtility.ChangeRoot(Root, BaseURI, uri); } return(new PhysicalFile( this, rootUri, displayUri, LocalCache.GetNewTempPath(), new FileInfo(rootUri.LocalPath))); }); return(file); }