tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
PosixFilesystemLinkFactory.cs
Go to the documentation of this file.
1using System;
2using System.IO;
3using System.Threading;
4using System.Threading.Tasks;
5
6using Mono.Unix;
7
9{
14 {
17
19 public Task CreateHardLink(string targetPath, string linkPath, CancellationToken cancellationToken) => Task.Factory.StartNew(
20 () =>
21 {
22 ArgumentNullException.ThrowIfNull(targetPath);
23 ArgumentNullException.ThrowIfNull(linkPath);
24
25 cancellationToken.ThrowIfCancellationRequested();
26 var fsInfo = new UnixFileInfo(targetPath);
27 cancellationToken.ThrowIfCancellationRequested();
28 fsInfo.CreateLink(linkPath);
29 },
30 cancellationToken,
32 TaskScheduler.Current);
33
35 public Task CreateSymbolicLink(string targetPath, string linkPath, CancellationToken cancellationToken) => Task.Factory.StartNew(
36 () =>
37 {
38 ArgumentNullException.ThrowIfNull(targetPath);
39 ArgumentNullException.ThrowIfNull(linkPath);
40
41 UnixFileSystemInfo fsInfo;
42 var isFile = File.Exists(targetPath);
43 cancellationToken.ThrowIfCancellationRequested();
44 if (isFile)
45 fsInfo = new UnixFileInfo(targetPath);
46 else
47 fsInfo = new UnixDirectoryInfo(targetPath);
48 cancellationToken.ThrowIfCancellationRequested();
49 fsInfo.CreateSymbolicLink(linkPath);
50 },
51 cancellationToken,
53 TaskScheduler.Current);
54 }
55}
IIOManager that resolves paths to Environment.CurrentDirectory.
const TaskCreationOptions BlockingTaskCreationOptions
The TaskCreationOptions used to spawn Tasks for potentially long running, blocking operations.