示例#1
0
 public static void CopyTimestamps(string sourcePath, string destinationPath, PathFormat pathFormat)
 {
     File.CopyTimestampsCore(null, sourcePath, destinationPath, false, pathFormat);
 }
        internal static string CreateJunctionCore(KernelTransaction transaction, string junctionPath, string directoryPath, bool overwrite, bool copyTargetTimestamps, PathFormat pathFormat)
        {
            if (pathFormat != PathFormat.LongFullPath)
            {
                Path.CheckSupportedPathFormat(directoryPath, true, true);
                Path.CheckSupportedPathFormat(junctionPath, true, true);

                directoryPath = Path.GetExtendedLengthPathCore(transaction, directoryPath, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator);
                junctionPath  = Path.GetExtendedLengthPathCore(transaction, junctionPath, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator);

                pathFormat = PathFormat.LongFullPath;
            }


            // Directory Junction logic.


            // Check if drive letter is a mapped network drive.
            if (new DriveInfo(directoryPath).IsUnc)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.Network_Path_Not_Allowed, directoryPath), "directoryPath");
            }

            if (new DriveInfo(junctionPath).IsUnc)
            {
                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.Network_Path_Not_Allowed, junctionPath), "junctionPath");
            }


            // Check for existing file.
            File.ThrowIOExceptionIfFsoExist(transaction, false, directoryPath, pathFormat);
            File.ThrowIOExceptionIfFsoExist(transaction, false, junctionPath, pathFormat);


            // Check for existing directory junction folder.
            if (File.ExistsCore(transaction, true, junctionPath, pathFormat))
            {
                if (overwrite)
                {
                    DeleteDirectoryCore(transaction, null, junctionPath, true, true, true, pathFormat);
                    CreateDirectoryCore(transaction, junctionPath, null, null, false, pathFormat);
                }

                else
                {
                    // Ensure the folder is empty.
                    if (!IsEmptyCore(transaction, junctionPath, pathFormat))
                    {
                        throw new DirectoryNotEmptyException(junctionPath, true);
                    }

                    throw new AlreadyExistsException(junctionPath, true);
                }
            }


            // Create the folder and convert it to a directory junction.
            CreateDirectoryCore(transaction, junctionPath, null, null, false, pathFormat);

            using (var safeHandle = OpenDirectoryJunction(transaction, junctionPath, pathFormat))
                Device.CreateDirectoryJunction(safeHandle, directoryPath);


            // Copy the target date and time stamps to the directory junction.
            if (copyTargetTimestamps)
            {
                File.CopyTimestampsCore(transaction, directoryPath, junctionPath, true, pathFormat);
            }


            return(junctionPath);
        }
示例#3
0
 public static void CopyTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, bool modifyReparsePoint, PathFormat pathFormat)
 {
     File.CopyTimestampsCore(transaction, sourcePath, destinationPath, modifyReparsePoint, pathFormat);
 }
示例#4
0
 public static void CopyTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat)
 {
     File.CopyTimestampsCore(transaction, sourcePath, destinationPath, false, pathFormat);
 }
示例#5
0
 public static void CopyTimestamps(string sourcePath, string destinationPath, bool modifyReparsePoint, PathFormat pathFormat)
 {
     File.CopyTimestampsCore(null, sourcePath, destinationPath, modifyReparsePoint, pathFormat);
 }
 public static void CopyTimestamps(string sourcePath, string destinationPath)
 {
     File.CopyTimestampsCore(null, true, sourcePath, destinationPath, false, PathFormat.RelativePath);
 }
 public static void CopyTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath)
 {
     File.CopyTimestampsCore(transaction, true, sourcePath, destinationPath, false, PathFormat.RelativePath);
 }