-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathResultSet.cs
43 lines (38 loc) · 1.32 KB
/
ResultSet.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Copyright Bastian Eicher
// Licensed under the MIT License
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using IWshRuntimeLibrary;
using NanoByte.Common;
using NanoByte.Common.Native;
using NanoByte.Common.Storage;
namespace NanoByte.LightTag
{
public sealed class ResultSet
{
private readonly WshShellClass _wshShell = new WshShellClass();
private readonly DirectoryInfo _directory;
public ResultSet()
{
_directory = new DirectoryInfo(new[] {Locations.UserCacheDir, "LightTag", "Results", ((UnixTime)DateTime.UtcNow).ToString()}.Aggregate(Path.Combine));
_directory.Create();
}
public void Show()
{
Process.Start(new ProcessStartInfo(_directory.FullName) {UseShellExecute = true});
}
public void Add(FileInfo file)
{
string linkPath = Path.Combine(_directory.FullName, file.Name);
if (WindowsUtils.IsWindows)
{
var shortcut = (IWshShortcut)_wshShell.CreateShortcut(linkPath + ".lnk");
shortcut.TargetPath = file.FullName;
shortcut.Save();
}
else if (UnixUtils.IsUnix) UnixUtils.CreateSymlink(linkPath, file.FullName);
}
}
}