Beispiel #1
0
        public void Move(string sourceFileName, string destFileName)
        {
            Guard.NotNull(sourceFileName, nameof(sourceFileName));
            Guard.NotNull(destFileName, nameof(destFileName));

            AssertFileNameIsNotEmpty(sourceFileName);
            AssertFileNameIsNotEmpty(destFileName);

            AbsolutePath sourcePath      = owner.ToAbsolutePath(sourceFileName);
            AbsolutePath destinationPath = owner.ToAbsolutePath(destFileName);

            var handler   = new FileMoveHandler(container);
            var arguments = new EntryMoveArguments(sourcePath, destinationPath);

            handler.Handle(arguments);

            if (handler.IsCopyRequired)
            {
                InnerCopy(sourceFileName, destFileName, false, true);

                if (handler.IsSourceReadOnly)
                {
                    var setAttributesHandler  = new FileSetAttributesHandler(container);
                    var setAttributeArguments = new FileSetAttributesArguments(sourcePath, FileAttributes.Normal,
                                                                               FileAccessKinds.Attributes | FileAccessKinds.Read);

                    setAttributesHandler.Handle(setAttributeArguments);
                }

                Delete(sourceFileName);
            }
        }
Beispiel #2
0
        public void Move(string sourceDirName, string destDirName)
        {
            Guard.NotNull(sourceDirName, nameof(sourceDirName));
            AssertFileNameIsNotEmpty(sourceDirName);

            Guard.NotNull(destDirName, nameof(destDirName));
            AssertFileNameIsNotEmpty(destDirName);

            AbsolutePath sourcePath      = owner.ToAbsolutePath(sourceDirName);
            AbsolutePath destinationPath = owner.ToAbsolutePath(destDirName);

            var handler   = new DirectoryMoveHandler(root, owner.CurrentDirectoryManager);
            var arguments = new EntryMoveArguments(sourcePath, destinationPath);

            handler.Handle(arguments);
        }