Files
UnrealEngine/Engine/Source/Programs/UnrealGameSync/UnrealGameSyncCmd/Utils/UserSettingsUtils.cs
Brandyn / Techy fcc1b09210 init
2026-04-04 15:40:51 -05:00

42 lines
956 B
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using UnrealGameSync;
namespace UnrealGameSyncCmd.Utils
{
public static class UserSettingsUtils
{
public static UserWorkspaceSettings? ReadOptionalUserWorkspaceSettings()
{
DirectoryReference? dir = DirectoryReference.GetCurrentDirectory();
for (; dir != null; dir = dir.ParentDirectory)
{
try
{
UserWorkspaceSettings? settings;
if (UserWorkspaceSettings.TryLoad(dir, out settings))
{
return settings;
}
}
catch
{
// Guard against directories we can't access, eg. /Users/.ugs
}
}
return null;
}
public static UserWorkspaceSettings ReadRequiredUserWorkspaceSettings()
{
UserWorkspaceSettings? settings = ReadOptionalUserWorkspaceSettings();
if (settings == null)
{
throw new UserErrorException("Unable to find UGS workspace in current directory.");
}
return settings;
}
}
}