Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 3
0
 /// <summary>
 /// Sets the attributes of a file or directory.
 /// </summary>
 /// <param name="path">The file or directory to change</param>
 /// <param name="newValue">The new attributes of the file or directory</param>
 public override void SetAttributes(string path, FileAttributes newValue)
 {
     _wrapped.SetAttributes(path, newValue);
 }
Esempio n. 4
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));
        }
Esempio n. 5
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));
        }