Beispiel #1
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all files found in a non-shadow path format.
        /// </summary>
        /// <param name="localFolderPath">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        protected override string[] ListFiles(string localFolderPath)
        {
            string[] files = null;
            var      spath = ConvertToSnapshotPath(localFolderPath);

            // First try without long UNC prefixed
            try
            {
                files = SystemIO.IO_WIN.GetFiles(spath);
            }
            catch (DirectoryNotFoundException) //TODO: Do we really need this??
            {
                spath = SystemIOWindows.PrefixWithUNC(spath);
                files = SystemIO.IO_WIN.GetFiles(spath);
            }

            // convert back to non-shadow, i.e., non-vss version
            var root       = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath));
            var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root));

            volumePath = SystemIOWindows.PrefixWithUNC(volumePath);

            for (var i = 0; i < files.Length; i++)
            {
                files[i] = root + SystemIOWindows.PrefixWithUNC(files[i]).Substring(volumePath.Length);
            }

            return(files);
        }
Beispiel #2
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all folders found in a non-shadow path format.
        /// </summary>
        /// <param name="localFolderPath">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        protected override string[] ListFolders(string localFolderPath)
        {
            string[] tmp   = null;
            var      spath = ConvertToSnapshotPath(localFolderPath);

            try
            {
                tmp = SystemIO.IO_WIN.GetDirectories(spath);
            }
            catch (DirectoryNotFoundException) //TODO: Do we really need this??
            {
                spath = SystemIOWindows.PrefixWithUNC(spath);
                tmp   = SystemIO.IO_WIN.GetDirectories(spath);
            }

            var root       = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath));
            var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root));

            volumePath = SystemIOWindows.PrefixWithUNC(volumePath);

            for (var i = 0; i < tmp.Length; i++)
            {
                tmp[i] = root + SystemIOWindows.PrefixWithUNC(tmp[i]).Substring(volumePath.Length);
            }

            return(tmp);
        }
Beispiel #3
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all files found in a non-shadow path format.
        /// </summary>
        /// <param name="localFolderPath">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        protected override string[] ListFiles(string localFolderPath)
        {
            var root       = Utility.Utility.AppendDirSeparator(AlphaFS.Path.GetPathRoot(localFolderPath));
            var volumePath = Utility.Utility.AppendDirSeparator(ConvertToSnapshotPath(root));

            string[] tmp   = null;
            var      spath = ConvertToSnapshotPath(localFolderPath);

            if (SystemIOWindows.IsPathTooLong(spath))
            {
                try { tmp = AlphaFS.Directory.GetFiles(spath); }
                catch (PathTooLongException) { }
                catch (DirectoryNotFoundException) { }
            }
            else
            {
                try { tmp = Directory.GetFiles(spath); }
                catch (PathTooLongException) { }
            }

            if (tmp == null)
            {
                spath = SystemIOWindows.PrefixWithUNC(spath);
                tmp   = AlphaFS.Directory.GetFiles(spath);
            }

            volumePath = SystemIOWindows.PrefixWithUNC(volumePath);

            for (var i = 0; i < tmp.Length; i++)
            {
                tmp[i] = root + SystemIOWindows.PrefixWithUNC(tmp[i]).Substring(volumePath.Length);
            }

            return(tmp);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        /// <summary>
        /// Returns the symlink target if the entry is a symlink, and null otherwise
        /// </summary>
        /// <param name="file">The file or folder to examine</param>
        /// <returns>The symlink target</returns>
        public override string GetSymlinkTarget(string file)
        {
            try { return(File.GetLinkTargetInfo(SystemIOWindows.PrefixWithUNC(file)).PrintName); }
            catch (NotAReparsePointException) { }
            catch (UnrecognizedReparsePointException) { }

            return(null);
        }
Beispiel #6
0
        /// <summary>
        /// Opens a file for reading
        /// </summary>
        /// <param name="file">The full path to the file in non-snapshot format</param>
        /// <returns>An open filestream that can be read</returns>
        public override System.IO.Stream OpenRead(string file)
        {
            if (!SystemIOWindows.IsPathTooLong(file))
            {
                try { return(base.OpenRead(file)); }
                catch (System.IO.PathTooLongException) { }
            }

            return(File.OpenRead(SystemIOWindows.PrefixWithUNC(file)));
        }
Beispiel #7
0
        /// <summary>
        /// Gets the last write time of a given file in UTC
        /// </summary>
        /// <param name="file">The full path to the file in non-snapshot format</param>
        /// <returns>The last write time of the file</returns>
        public override DateTime GetLastWriteTimeUtc(string file)
        {
            if (!SystemIOWindows.IsPathTooLong(file))
            {
                try { return(base.GetLastWriteTimeUtc(file)); }
                catch (System.IO.PathTooLongException) { }
            }

            return(File.GetLastWriteTimeUtc(SystemIOWindows.PrefixWithUNC(file)));
        }
Beispiel #8
0
        /// <summary>
        /// Lists all folders in the given folder
        /// </summary>
        /// <returns>All folders found in the folder</returns>
        /// <param name='localFolderPath'>The folder to examinate</param>
        protected override string[] ListFolders(string localFolderPath)
        {
            string[] tmp = SystemIO.IO_WIN.GetDirectories(SystemIOWindows.AddExtendedDevicePathPrefix(localFolderPath));
            string[] res = new string[tmp.Length];
            for (int i = 0; i < tmp.Length; i++)
            {
                res[i] = SystemIOWindows.RemoveExtendedDevicePathPrefix(tmp[i]);
            }

            return(res);
        }
Beispiel #9
0
        /// <summary>
        /// Lists all files in the given folder
        /// </summary>
        /// <returns>All folders found in the folder</returns>
        /// <param name='localFolderPath'>The folder to examinate</param>
        protected override string[] ListFiles(string localFolderPath)
        {
            string[] tmp = SystemIO.IO_WIN.GetFiles(localFolderPath);
            string[] res = new string[tmp.Length];
            for (int i = 0; i < tmp.Length; i++)
            {
                res[i] = SystemIOWindows.StripUNCPrefix(tmp[i]);
            }

            return(res);
        }
Beispiel #10
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all folders found in a non-shadow path format.
        /// </summary>
        /// <param name="folder">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        private string[] ListFolders(string folder)
        {
            string root       = Utility.Utility.AppendDirSeparator(Alphaleonis.Win32.Filesystem.Path.GetPathRoot(folder));
            string volumePath = Utility.Utility.AppendDirSeparator(GetSnapshotPath(root));

            string[] tmp   = null;
            string   spath = GetSnapshotPath(folder);

            if (SystemIOWindows.IsPathTooLong(spath))
            {
                try { tmp = Alphaleonis.Win32.Filesystem.Directory.GetDirectories(spath); }
                catch (PathTooLongException) { }
            }
Beispiel #11
0
        /// <summary>
        /// Gets the creation of a given file in UTC
        /// </summary>
        /// <param name="localPath">The full path to the file in non-shadow format</param>
        /// <returns>The last write time of the file</returns>
        public override DateTime GetCreationTimeUtc(string localPath)
        {
            var spath = ConvertToSnapshotPath(localPath);

            if (!SystemIOWindows.IsPathTooLong(spath))
            {
                try
                {
                    return(File.GetCreationTimeUtc(spath));
                }
                catch (PathTooLongException) { }
            }

            return(AlphaFS.File.GetCreationTimeUtc(SystemIOWindows.PrefixWithUNC(spath)));
        }
Beispiel #12
0
        /// <summary>
        /// Lists all folders in the given folder
        /// </summary>
        /// <returns>All folders found in the folder</returns>
        /// <param name='folder'>The folder to examinate</param>
        protected override string[] ListFolders(string folder)
        {
            if (!SystemIOWindows.IsPathTooLong(folder))
            {
                try { return(base.ListFolders(folder)); }
                catch (System.IO.PathTooLongException) { }
            }

            string[] tmp = Directory.GetDirectories(SystemIOWindows.PrefixWithUNC(folder));
            string[] res = new string[tmp.Length];
            for (int i = 0; i < tmp.Length; i++)
            {
                res[i] = SystemIOWindows.StripUNCPrefix(tmp[i]);
            }

            return(res);
        }
Beispiel #13
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all folders found in a non-shadow path format.
        /// </summary>
        /// <param name="localFolderPath">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        protected override string[] ListFolders(string localFolderPath)
        {
            string[] tmp   = null;
            var      spath = ConvertToSnapshotPath(localFolderPath);

            tmp = SystemIO.IO_WIN.GetDirectories(spath);
            var root       = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath));
            var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root));

            volumePath = SystemIOWindows.AddExtendedDevicePathPrefix(volumePath);

            for (var i = 0; i < tmp.Length; i++)
            {
                tmp[i] = root + SystemIOWindows.AddExtendedDevicePathPrefix(tmp[i]).Substring(volumePath.Length);
            }

            return(tmp);
        }
Beispiel #14
0
        /// <summary>
        /// A callback function that takes a non-shadow path to a folder,
        /// and returns all files found in a non-shadow path format.
        /// </summary>
        /// <param name="localFolderPath">The non-shadow path of the folder to list</param>
        /// <returns>A list of non-shadow paths</returns>
        protected override string[] ListFiles(string localFolderPath)
        {
            string[] files = null;
            var      spath = ConvertToSnapshotPath(localFolderPath);

            files = SystemIO.IO_WIN.GetFiles(spath);

            // convert back to non-shadow, i.e., non-vss version
            var root       = Util.AppendDirSeparator(SystemIO.IO_WIN.GetPathRoot(localFolderPath));
            var volumePath = Util.AppendDirSeparator(ConvertToSnapshotPath(root));

            volumePath = SystemIOWindows.PrefixWithUNC(volumePath);

            for (var i = 0; i < files.Length; i++)
            {
                files[i] = root + SystemIOWindows.PrefixWithUNC(files[i]).Substring(volumePath.Length);
            }

            return(files);
        }
Beispiel #15
0
 /// <inheritdoc />
 public override string ConvertToSnapshotPath(string localPath)
 {
     // For Windows, ensure we don't store paths with UNC prefix
     return(SystemIOWindows.StripUNCPrefix(localPath));
 }
Beispiel #16
0
 /// <summary>
 /// Returns the symlink target if the entry is a symlink, and null otherwise
 /// </summary>
 /// <param name="file">The file or folder to examine</param>
 /// <returns>The symlink target</returns>
 public override string GetSymlinkTarget(string file)
 {
     return(File.GetLinkTargetInfo(SystemIOWindows.PrefixWithUNC(file)).PrintName);
 }
Beispiel #17
0
        /// <summary>
        /// Gets the creation of a given file in UTC
        /// </summary>
        /// <param name="localPath">The full path to the file in non-shadow format</param>
        /// <returns>The last write time of the file</returns>
        public override DateTime GetCreationTimeUtc(string localPath)
        {
            var spath = ConvertToSnapshotPath(localPath);

            return(SystemIO.IO_WIN.GetCreationTimeUtc(SystemIOWindows.PrefixWithUNC(spath)));
        }
Beispiel #18
0
 /// <inheritdoc />
 public override string ConvertToSnapshotPath(string localPath)
 {
     // For Windows, ensure we don't store paths with extended device path prefixes (i.e., @"\\?\" or @"\\?\UNC\")
     return(SystemIOWindows.RemoveExtendedDevicePathPrefix(localPath));
 }
Beispiel #19
0
        /// <summary>
        /// Gets the creation of a given file in UTC
        /// </summary>
        /// <param name="localPath">The full path to the file in non-shadow format</param>
        /// <returns>The last write time of the file</returns>
        public override DateTime GetCreationTimeUtc(string localPath)
        {
            var spath = ConvertToSnapshotPath(localPath);

            return(SystemIO.IO_WIN.GetCreationTimeUtc(SystemIOWindows.AddExtendedDevicePathPrefix(spath)));
        }