Example #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);
            }
        }
Example #2
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(root);
            var arguments = new DirectoryOrFileMoveArguments(sourcePath, destinationPath);

            handler.Handle(arguments);
        }
Example #3
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(container, owner.CurrentDirectoryManager);
            var arguments = new EntryMoveArguments(sourcePath, destinationPath);

            handler.Handle(arguments);

            if (handler.IsFileMoveRequired)
            {
                var fileMoveHandler = new FileMoveHandler(container);
                fileMoveHandler.Handle(arguments);
            }
        }
Example #4
0
        /// <summary>
        /// Creates a linker.
        /// </summary>
        /// <param name="smallTables">Use small table definitions for MSI/MSM.</param>
        public Binder(bool smallTables)
        {
            this.tableDefinitions = Common.GetTableDefinitions(smallTables);

            this.extension = new BinderExtension();
            this.extensionMessages = new ExtensionMessages(this);
            this.fileCopyHandler = new FileCopyHandler(File.Copy);
            this.fileMoveHandler = new FileMoveHandler(File.Move);
        }