-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SNOW-990111: Refactor getting home directory
- Loading branch information
1 parent
16335ab
commit 0f266fc
Showing
4 changed files
with
37 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
using Snowflake.Data.Log; | ||
using System; | ||
|
||
namespace Snowflake.Data.Core.Tools | ||
{ | ||
internal class HomeDirectoryProvider | ||
{ | ||
private static readonly SFLogger s_logger = SFLoggerFactory.GetLogger<HomeDirectoryProvider>(); | ||
|
||
public static string HomeDirectory(EnvironmentOperations _environmentOperations) { | ||
try | ||
{ | ||
var homeDirectory = _environmentOperations.GetFolderPath(Environment.SpecialFolder.UserProfile); | ||
if (string.IsNullOrEmpty(homeDirectory) || homeDirectory.Equals("/")) | ||
{ | ||
return null; | ||
} | ||
return homeDirectory; | ||
} | ||
catch (Exception e) | ||
{ | ||
s_logger.Error($"Error while trying to retrieve the home directory: {e}"); | ||
return null; | ||
} | ||
} | ||
} | ||
} |