From 60f75abcd1fe49052c118a2597ac59a82c372b64 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Tue, 16 Mar 2021 10:49:09 -0700 Subject: Migrate PInvoke out of Core to Core.Native --- src/WixToolset.Core/Bind/FileSystem.cs | 86 ---------------------------------- 1 file changed, 86 deletions(-) delete mode 100644 src/WixToolset.Core/Bind/FileSystem.cs (limited to 'src/WixToolset.Core/Bind/FileSystem.cs') diff --git a/src/WixToolset.Core/Bind/FileSystem.cs b/src/WixToolset.Core/Bind/FileSystem.cs deleted file mode 100644 index bdd65503..00000000 --- a/src/WixToolset.Core/Bind/FileSystem.cs +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Core.Bind -{ - using System; - using System.Collections.Generic; - using System.IO; - using System.Runtime.InteropServices; - using WixToolset.Extensibility; - - internal class FileSystem - { - public FileSystem(IEnumerable extensions) - { - this.Extensions = extensions ?? Array.Empty(); - } - - private IEnumerable Extensions { get; } - - /// - /// Copies a file. - /// - /// The file to copy. - /// The destination file. - public bool CopyFile(string source, string destination) - { - foreach (var extension in this.Extensions) - { - if (extension.CopyFile(source, destination)) - { - return true; - } - } - - if (File.Exists(destination)) - { - File.Delete(destination); - } - - if (!CreateHardLink(destination, source, IntPtr.Zero)) - { -#if DEBUG - int er = Marshal.GetLastWin32Error(); -#endif - - File.Copy(source, destination, true); - } - - return true; - } - - /// - /// Moves a file. - /// - /// The file to move. - /// The destination file. - public bool MoveFile(string source, string destination) - { - foreach (var extension in this.Extensions) - { - if (extension.MoveFile(source, destination)) - { - return true; - } - } - - if (File.Exists(destination)) - { - File.Delete(destination); - } - - var directory = Path.GetDirectoryName(destination); - if (!String.IsNullOrEmpty(directory)) - { - Directory.CreateDirectory(directory); - } - - File.Move(source, destination); - - return true; - } - - [DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] - private static extern bool CreateHardLink(string lpFileName, string lpExistingFileName, IntPtr lpSecurityAttributes); - } -} -- cgit v1.2.3-55-g6feb