-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Installer update - Copy mods and Uninstall actions
- Loading branch information
Showing
7 changed files
with
427 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace InstallerCore | ||
{ | ||
public class FileUnblocker | ||
{ | ||
private static readonly Logger _log = Logger.GetLogger; | ||
|
||
[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static extern bool DeleteFile(string name); | ||
|
||
public static bool UnblockFile(string fileName) | ||
{ | ||
return DeleteFile(fileName + ":Zone.Identifier"); | ||
} | ||
|
||
public static void UnblockPath(string path) | ||
{ | ||
string[] files = System.IO.Directory.GetFiles(path); | ||
string[] dirs = System.IO.Directory.GetDirectories(path); | ||
|
||
foreach (string file in files) | ||
{ | ||
_log.WriteLine($"Unblocking file: {file}"); | ||
bool result = UnblockFile(file); | ||
if ( !result ) | ||
{ | ||
int error = Marshal.GetLastWin32Error(); | ||
|
||
_log.WriteLine($"Failed to unblock file: {file} with error {error}"); | ||
} | ||
} | ||
|
||
foreach (string dir in dirs) | ||
{ | ||
UnblockPath(dir); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.