Example #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)
        {
            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);
        }
Example #2
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)));
        }
Example #3
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)));
        }
Example #4
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) { }
            }
Example #5
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)));
        }
Example #6
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);
        }