Platform specific gvfs.config location

The config file location currently exists in the same directory as the GVFS
service data directory. On Mac, the GVFS Service directory is per user, and not
per machine. Even if the service is per user on Mac, we still would like the
config to be per machine.

This change enables the GVFS config file to exist at a location independent of
the GVFS Service data directory. On Windows, the location will not change, but
on macOS, it will now exist in the GVFS binary location.
This commit is contained in:
Jameson Miller 2019-05-13 14:19:32 -04:00
Родитель f6454ed456
Коммит 36a512adf3
5 изменённых файлов: 24 добавлений и 4 удалений

Просмотреть файл

@ -27,6 +27,8 @@ namespace GVFS.Common
public UnderConstructionFlags UnderConstruction { get; }
public abstract string Name { get; }
public abstract string GVFSConfigPath { get; }
public static void Register(GVFSPlatform platform)
{
if (GVFSPlatform.Instance != null)

Просмотреть файл

@ -15,10 +15,7 @@ namespace GVFS.Common
public LocalGVFSConfig()
{
string servicePath = GVFSPlatform.Instance.GetDataRootForGVFSComponent(GVFSConstants.Service.ServiceName);
string gvfsDirectory = Path.GetDirectoryName(servicePath);
this.configFile = Path.Combine(gvfsDirectory, FileName);
this.configFile = GVFSPlatform.Instance.GVFSConfigPath;
this.fileSystem = new PhysicalFileSystem();
}

Просмотреть файл

@ -24,6 +24,14 @@ namespace GVFS.Platform.Mac
public override GVFSPlatformConstants Constants { get; } = new MacPlatformConstants();
public override IPlatformFileSystem FileSystem { get; } = new MacFileSystem();
public override string GVFSConfigPath
{
get
{
return Path.Combine(this.Constants.GVFSBinDirectoryPath, LocalGVFSConfig.FileName);
}
}
public override string GetOSVersionInformation()
{
ProcessResult result = ProcessHelper.Run("sw_vers", args: string.Empty, redirectOutput: true);

Просмотреть файл

@ -36,6 +36,17 @@ namespace GVFS.Platform.Windows
public override string Name { get => "Windows"; }
public override GVFSPlatformConstants Constants { get; } = new WindowsPlatformConstants();
public override string GVFSConfigPath
{
get
{
string servicePath = GVFSPlatform.Instance.GetDataRootForGVFSComponent(GVFSConstants.Service.ServiceName);
string gvfsDirectory = Path.GetDirectoryName(servicePath);
return Path.Combine(gvfsDirectory, LocalGVFSConfig.FileName);
}
}
public static string GetStringFromRegistry(string key, string valueName)
{
object value = GetValueFromRegistry(RegistryHive.LocalMachine, key, valueName);

Просмотреть файл

@ -29,6 +29,8 @@ namespace GVFS.UnitTests.Mock.Common
public override string Name { get => "Mock"; }
public override string GVFSConfigPath { get => Path.Combine("mock:", LocalGVFSConfig.FileName); }
public override GVFSPlatformConstants Constants { get; } = new MockPlatformConstants();
public HashSet<int> ActiveProcesses { get; } = new HashSet<int>();