-
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: Remove umask test and create dotnet subfolder with Mono.…
…Unix
- Loading branch information
1 parent
ea8d52e
commit 3fabd05
Showing
6 changed files
with
119 additions
and
94 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
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
/* | ||
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved. | ||
*/ | ||
|
||
using Mono.Unix; | ||
using Mono.Unix.Native; | ||
using System.IO; | ||
|
||
namespace Snowflake.Data.Core.Tools | ||
{ | ||
internal class UnixOperations | ||
{ | ||
public static readonly UnixOperations Instance = new UnixOperations(); | ||
|
||
private UnixFileInfo _unixFileInfo; | ||
private UnixDirectoryInfo _unixDirInfo; | ||
|
||
public virtual void SetDirInfo(string path) | ||
{ | ||
_unixDirInfo = new UnixDirectoryInfo(path); | ||
} | ||
|
||
public virtual void CreateDirectoryWithPermissions(string path, FilePermissions permissions) | ||
{ | ||
string subPath = Path.GetDirectoryName(path); | ||
if (!Directory.Exists(subPath)) | ||
{ | ||
Directory.CreateDirectory(subPath); | ||
} | ||
Syscall.mkdir(path, permissions); | ||
} | ||
|
||
public virtual FileAccessPermissions GetDirPermissions() | ||
{ | ||
return _unixDirInfo.FileAccessPermissions; | ||
} | ||
|
||
public virtual void SetFileInfo(string path) | ||
{ | ||
_unixFileInfo = new UnixFileInfo(path); | ||
} | ||
|
||
public virtual bool CheckFileHasPermissions(FileAccessPermissions permissions) | ||
{ | ||
return _unixFileInfo.FileAccessPermissions.HasFlag(permissions); | ||
} | ||
} | ||
} |