[System.Xml] Update source file location from commit d4816ef1abcfc5b3dea41a87fe5a7a4c...
[mono-project.git] / mcs / class / Facades / System.IO.FileSystem.AccessControl / FileSystemAclExtensions.cs
blob6baeefd5dd9da7f05871f65696b697e0aa5b1d9c
1 //
2 // FileSystemAclExtensions.cs
3 //
4 // Author:
5 // Alexander Köplinger (alexander.koeplinger@xamarin.com)
6 //
7 // (C) 2016 Xamarin, Inc.
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Security.AccessControl;
33 namespace System.IO
35 public static class FileSystemAclExtensions
37 public static DirectorySecurity GetAccessControl(this DirectoryInfo directoryInfo)
39 if (directoryInfo == null)
40 throw new ArgumentNullException (nameof (directoryInfo));
42 return directoryInfo.GetAccessControl ();
45 public static DirectorySecurity GetAccessControl(this DirectoryInfo directoryInfo, AccessControlSections includeSections)
47 if (directoryInfo == null)
48 throw new ArgumentNullException (nameof (directoryInfo));
50 return directoryInfo.GetAccessControl (includeSections);
53 public static FileSecurity GetAccessControl(this FileInfo fileInfo)
55 if (fileInfo == null)
56 throw new ArgumentNullException (nameof (fileInfo));
58 return fileInfo.GetAccessControl ();
61 public static FileSecurity GetAccessControl(this FileInfo fileInfo, AccessControlSections includeSections)
63 if (fileInfo == null)
64 throw new ArgumentNullException (nameof (fileInfo));
66 return fileInfo.GetAccessControl (includeSections);
69 public static FileSecurity GetAccessControl(this FileStream fileStream)
71 if (fileStream == null)
72 throw new ArgumentNullException (nameof (fileStream));
74 return fileStream.GetAccessControl ();
77 public static void SetAccessControl(this DirectoryInfo directoryInfo, DirectorySecurity directorySecurity)
79 if (directoryInfo == null)
80 throw new ArgumentNullException (nameof (directoryInfo));
82 directoryInfo.SetAccessControl (directorySecurity);
85 public static void SetAccessControl(this FileInfo fileInfo, FileSecurity fileSecurity)
87 if (fileInfo == null)
88 throw new ArgumentNullException (nameof (fileInfo));
90 fileInfo.SetAccessControl (fileSecurity);
93 public static void SetAccessControl(this FileStream fileStream, FileSecurity fileSecurity)
95 if (fileStream == null)
96 throw new ArgumentNullException (nameof (fileStream));
98 fileStream.SetAccessControl (fileSecurity);