/// <summary> /// Resolves the given VFS URL into a ObjectId and its DatabaseFileProvider. /// </summary> /// <param name="url">The URL to resolve.</param> /// <param name="objectId">The object id.</param> /// <returns>The <see cref="DatabaseFileProvider"/> containing this object if it could be found; [null] otherwise.</returns> public static DatabaseFileProvider ResolveObjectId(string url, out ObjectId objectId) { var resolveProviderResult = VirtualFileSystem.ResolveProvider(url, false); var provider = resolveProviderResult.Provider as DatabaseFileProvider; if (provider == null) { objectId = ObjectId.Empty; return(null); } return(provider.ContentIndexMap.TryGetValue(resolveProviderResult.Path, out objectId) ? provider : null); }
/// <summary> /// Resolves the VFS URL from a given file path. /// </summary> /// <param name="filePath">The file path.</param> /// <returns></returns> /// <exception cref="System.InvalidOperationException"></exception> public string GetLocalPath(string filePath) { #if !NETFX_CORE filePath = Path.GetFullPath(filePath); #endif var resolveProviderResult = VirtualFileSystem.ResolveProvider(RootPath, true); var provider = resolveProviderResult.Provider as DriveFileProvider; if (provider == null) { throw new InvalidOperationException(); } return(provider.ConvertFullPathToUrl(filePath)); }