forked from microsoft/VFSForGit
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMacPlatform.cs
More file actions
146 lines (121 loc) · 5.35 KB
/
MacPlatform.cs
File metadata and controls
146 lines (121 loc) · 5.35 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
using GVFS.Common;
using GVFS.Common.FileSystem;
using GVFS.Common.Git;
using GVFS.Common.Tracing;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
namespace GVFS.Platform.Mac
{
public partial class MacPlatform : GVFSPlatform
{
public MacPlatform()
: base(executableExtension: string.Empty, installerExtension: ".dmg")
{
}
public override IKernelDriver KernelDriver { get; } = new ProjFSKext();
public override IGitInstallation GitInstallation { get; } = new MacGitInstallation();
public override IDiskLayoutUpgradeData DiskLayoutUpgrade { get; } = new MacDiskLayoutUpgradeData();
public override IPlatformFileSystem FileSystem { get; } = new MacFileSystem();
public override bool IsUnderConstruction { get; } = true;
public override bool SupportsGVFSService { get; } = false;
public override bool SupportsGVFSUpgrade { get; } = false;
public override void ConfigureVisualStudio(string gitBinPath, ITracer tracer)
{
}
public override bool TryGetGVFSHooksPathAndVersion(out string hooksPaths, out string hooksVersion, out string error)
{
hooksPaths = string.Empty;
// TODO(Mac): Get the hooks version rather than the GVFS version (and share that code with the Windows platform)
hooksVersion = ProcessHelper.GetCurrentProcessVersion();
error = null;
return true;
}
public override bool TryInstallGitCommandHooks(GVFSContext context, string executingDirectory, string hookName, string commandHookPath, out string errorMessage)
{
errorMessage = null;
string gvfsHooksPath = Path.Combine(executingDirectory, GVFSPlatform.Instance.Constants.GVFSHooksExecutableName);
File.WriteAllText(
commandHookPath,
$"#!/bin/sh\n{gvfsHooksPath} {hookName} \"$@\"");
GVFSPlatform.Instance.FileSystem.ChangeMode(commandHookPath, Convert.ToInt32("755", 8));
return true;
}
public override bool IsProcessActive(int processId)
{
return MacPlatform.IsProcessActiveImplementation(processId);
}
public override void IsServiceInstalledAndRunning(string name, out bool installed, out bool running)
{
throw new NotImplementedException();
}
public override void StartBackgroundProcess(string programName, string[] args)
{
ProcessLauncher.StartBackgroundProcess(programName, args);
}
public override NamedPipeServerStream CreatePipeByName(string pipeName)
{
NamedPipeServerStream pipe = new NamedPipeServerStream(
pipeName,
PipeDirection.InOut,
NamedPipeServerStream.MaxAllowedServerInstances,
PipeTransmissionMode.Byte,
PipeOptions.WriteThrough | PipeOptions.Asynchronous,
0, // default inBufferSize
0); // default outBufferSize)
return pipe;
}
public override InProcEventListener CreateTelemetryListenerIfEnabled(string providerName, string enlistmentId, string mountId)
{
return null;
}
public override string GetCurrentUser()
{
throw new NotImplementedException();
}
public override string GetOSVersionInformation()
{
ProcessResult result = ProcessHelper.Run("sw_vers", args: string.Empty, redirectOutput: true);
return string.IsNullOrWhiteSpace(result.Output) ? result.Errors : result.Output;
}
public override Dictionary<string, string> GetPhysicalDiskInfo(string path, bool sizeStatsOnly)
{
// TODO(Mac): Collect disk information
Dictionary<string, string> result = new Dictionary<string, string>();
result.Add("GetPhysicalDiskInfo", "Not yet implemented on Mac");
return result;
}
public override void InitializeEnlistmentACLs(string enlistmentPath)
{
}
public override string GetNamedPipeName(string enlistmentRoot)
{
return MacPlatform.GetNamedPipeNameImplementation(enlistmentRoot);
}
public override bool IsConsoleOutputRedirectedToFile()
{
return MacPlatform.IsConsoleOutputRedirectedToFileImplementation();
}
public override bool IsElevated()
{
return MacPlatform.IsElevatedImplementation();
}
public override bool TryGetGVFSEnlistmentRoot(string directory, out string enlistmentRoot, out string errorMessage)
{
return MacPlatform.TryGetGVFSEnlistmentRootImplementation(directory, out enlistmentRoot, out errorMessage);
}
public override bool IsGitStatusCacheSupported()
{
// TODO(Mac): support git status cache
return false;
}
public override FileBasedLock CreateFileBasedLock(
PhysicalFileSystem fileSystem,
ITracer tracer,
string lockPath)
{
return new MacFileBasedLock(fileSystem, tracer, lockPath);
}
}
}