Пример #1
0
        /// <inheritdoc />
        public override string ConvertToSnapshotPath(string localPath)
        {
            // For Windows, ensure we don't store paths with UNC prefix
            localPath = SystemIOWindows.StripUNCPrefix(localPath);

            if (!Path.IsPathRooted(localPath))
            {
                throw new InvalidOperationException();
            }

            var root       = SystemIO.IO_WIN.GetPathRoot(localPath);
            var volumePath = _vssBackupComponents.GetVolumeFromCache(root);

            // Note that using a simple Path.Combine() for the following code
            // can result in invalid snapshot paths; e.g., if localPath is
            // @"C:\", mappedPath would not have the required trailing
            // directory separator.
            var subPath = localPath.Substring(root.Length);

            if (!subPath.StartsWith(Util.DirectorySeparatorString, StringComparison.Ordinal))
            {
                volumePath = Util.AppendDirSeparator(volumePath, Util.DirectorySeparatorString);
            }

            var mappedPath = volumePath + subPath;

            return(mappedPath);
        }
Пример #2
0
        /// <inheritdoc />
        public override string ConvertToSnapshotPath(string localPath)
        {
            if (!Path.IsPathRooted(localPath))
            {
                throw new InvalidOperationException();
            }

            var root       = SystemIO.IO_WIN.GetPathRoot(localPath);
            var volumePath = _vssBackupComponents.GetVolumeFromCache(root);
            var subPath    = localPath.Substring(root.Length);
            var mappedPath = SystemIO.IO_WIN.PathCombine(volumePath, subPath);

            return(mappedPath);
        }
Пример #3
0
        /// <inheritdoc />
        public override string ConvertToSnapshotPath(string localPath)
        {
            if (!Path.IsPathRooted(localPath))
            {
                throw new InvalidOperationException();
            }

            var root       = SystemIO.IO_WIN.GetPathRoot(localPath);
            var volumePath = _vssBackupComponents.GetVolumeFromCache(root);

            // Note: Do NOT use Path.Combine as it strips the UNC path prefix
            var subPath = localPath.Substring(root.Length);

            if (!subPath.StartsWith(Util.DirectorySeparatorString, StringComparison.Ordinal))
            {
                volumePath = Util.AppendDirSeparator(volumePath, Util.DirectorySeparatorString);
            }

            var mappedPath = volumePath + subPath;

            return(mappedPath);
        }