Example #1
0
        private void DoCopyFile(DiscFileSystem srcFs, string srcPath, DiscFileSystem destFs, string destPath)
        {
            IWindowsFileSystem destWindowsFs = destFs as IWindowsFileSystem;
            IWindowsFileSystem srcWindowsFs  = srcFs as IWindowsFileSystem;

            using (Stream src = srcFs.OpenFile(srcPath, FileMode.Open, FileAccess.Read))
                using (Stream dest = destFs.OpenFile(destPath, FileMode.Create, FileAccess.ReadWrite))
                {
                    dest.SetLength(src.Length);
                    byte[] buffer  = new byte[1024 * 1024];
                    int    numRead = src.Read(buffer, 0, buffer.Length);
                    while (numRead > 0)
                    {
                        dest.Write(buffer, 0, numRead);
                        numRead = src.Read(buffer, 0, buffer.Length);
                    }
                }

            if (srcWindowsFs != null && destWindowsFs != null)
            {
                if ((srcWindowsFs.GetAttributes(srcPath) & FileAttributes.ReparsePoint) != 0)
                {
                    destWindowsFs.SetReparsePoint(destPath, srcWindowsFs.GetReparsePoint(srcPath));
                }

                var sd = srcWindowsFs.GetSecurity(srcPath);
                if (sd != null)
                {
                    destWindowsFs.SetSecurity(destPath, sd);
                }
            }

            destFs.SetAttributes(destPath, srcFs.GetAttributes(srcPath));
            destFs.SetCreationTimeUtc(destPath, srcFs.GetCreationTimeUtc(srcPath));
        }
Example #2
0
        private void DoCopyDirectory(DiscFileSystem srcFs, string srcPath, DiscFileSystem destFs, string destPath)
        {
            IWindowsFileSystem destWindowsFs = destFs as IWindowsFileSystem;
            IWindowsFileSystem srcWindowsFs  = srcFs as IWindowsFileSystem;

            destFs.CreateDirectory(destPath);

            if (srcWindowsFs != null && destWindowsFs != null)
            {
                if ((srcWindowsFs.GetAttributes(srcPath) & FileAttributes.ReparsePoint) != 0)
                {
                    destWindowsFs.SetReparsePoint(destPath, srcWindowsFs.GetReparsePoint(srcPath));
                }
                destWindowsFs.SetSecurity(destPath, srcWindowsFs.GetSecurity(srcPath));
            }

            destFs.SetAttributes(destPath, srcFs.GetAttributes(srcPath));
        }