Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        ///   Resolves the virtual path from a given file path.
        /// </summary>
        /// <param name="filePath">The file path to resolve.</param>
        /// <returns>The virtual local path of the corresponding file.</returns>
        /// <exception cref="InvalidOperationException"></exception>
        public string GetLocalPath(string filePath)
        {
            filePath = Path.GetFullPath(filePath);

            var resolveProviderResult = VirtualFileSystem.ResolveProvider(RootPath, resolveTop: true);

            if (!(resolveProviderResult.Provider is DriveFileProvider provider))
            {
                throw new InvalidOperationException();
            }

            return(provider.ConvertFullPathToUrl(filePath));
        }
        /// <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));
        }