diff --git a/FolderMonitor.UI/ConfigService.cs b/FolderMonitor.UI/ConfigService.cs index 2f9a133..4673e82 100644 --- a/FolderMonitor.UI/ConfigService.cs +++ b/FolderMonitor.UI/ConfigService.cs @@ -132,7 +132,8 @@ void SetUserAccount(string username,string password) cmd += "password= " + password; var i = new Tools.Impersonator(username, null, password); i.Dispose(); - }else + } + else cmd += "obj= " + drpAccount.Text.Trim().Replace (" ","") ; var process = new Process(); // process.StartInfo.WorkingDirectory = AppDomain.CurrentDomain.BaseDirectory; diff --git a/FolderMonitor.UI/ExcludedItemsControl.Designer.cs b/FolderMonitor.UI/ExcludedItemsControl.Designer.cs index 23fca72..fa3d4de 100644 --- a/FolderMonitor.UI/ExcludedItemsControl.Designer.cs +++ b/FolderMonitor.UI/ExcludedItemsControl.Designer.cs @@ -1,4 +1,4 @@ -namespace RoboMirror.GUI +namespace FolderMonitor.UI { partial class ExcludedItemsControl { diff --git a/FolderMonitor.UI/ExcludedItemsControl.cs b/FolderMonitor.UI/ExcludedItemsControl.cs index 1e4d9e7..baf4e70 100644 --- a/FolderMonitor.UI/ExcludedItemsControl.cs +++ b/FolderMonitor.UI/ExcludedItemsControl.cs @@ -11,7 +11,7 @@ using System.IO; using System.Windows.Forms; -namespace RoboMirror.GUI +namespace FolderMonitor.UI { public partial class ExcludedItemsControl : UserControl { diff --git a/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs b/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs index 844d57e..17954ad 100644 --- a/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs +++ b/FolderMonitor.UI/ExcludedItemsDialog.Designer.cs @@ -34,9 +34,9 @@ private void InitializeComponent() this.button1 = new System.Windows.Forms.Button(); this.splitContainer = new System.Windows.Forms.SplitContainer(); this.filesGroupBox = new System.Windows.Forms.GroupBox(); - this.excludedFilesControl = new RoboMirror.GUI.ExcludedItemsControl(); + this.excludedFilesControl = new FolderMonitor.UI.ExcludedItemsControl(); this.foldersGroupBox = new System.Windows.Forms.GroupBox(); - this.excludedFoldersControl = new RoboMirror.GUI.ExcludedItemsControl(); + this.excludedFoldersControl = new FolderMonitor.UI.ExcludedItemsControl(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); this.splitContainer.Panel1.SuspendLayout(); @@ -153,7 +153,7 @@ private void InitializeComponent() this.excludedFilesControl.BaseFolder = null; this.excludedFilesControl.Font = this.Font; this.excludedFilesControl.Location = new System.Drawing.Point(14, 22); - this.excludedFilesControl.Mode = RoboMirror.GUI.ExcludedItemsMode.Files; + this.excludedFilesControl.Mode = FolderMonitor.UI.ExcludedItemsMode.Files; this.excludedFilesControl.Name = "excludedFilesControl"; this.excludedFilesControl.Size = new System.Drawing.Size(491, 145); this.excludedFilesControl.TabIndex = 0; @@ -181,7 +181,7 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.excludedFoldersControl.BaseFolder = null; this.excludedFoldersControl.Location = new System.Drawing.Point(14, 22); - this.excludedFoldersControl.Mode = RoboMirror.GUI.ExcludedItemsMode.Folders; + this.excludedFoldersControl.Mode = FolderMonitor.UI.ExcludedItemsMode.Folders; this.excludedFoldersControl.Name = "excludedFoldersControl"; this.excludedFoldersControl.Size = new System.Drawing.Size(482, 150); this.excludedFoldersControl.TabIndex = 0; @@ -226,8 +226,8 @@ private void InitializeComponent() private System.Windows.Forms.Button button1; private System.Windows.Forms.SplitContainer splitContainer; private System.Windows.Forms.GroupBox filesGroupBox; - private RoboMirror.GUI.ExcludedItemsControl excludedFilesControl; + private FolderMonitor.UI.ExcludedItemsControl excludedFilesControl; private System.Windows.Forms.GroupBox foldersGroupBox; - private RoboMirror.GUI.ExcludedItemsControl excludedFoldersControl; + private FolderMonitor.UI.ExcludedItemsControl excludedFoldersControl; } } \ No newline at end of file diff --git a/FolderMonitor.UI/FileDropTargetWrapper.cs b/FolderMonitor.UI/FileDropTargetWrapper.cs index 376897a..a1f698d 100644 --- a/FolderMonitor.UI/FileDropTargetWrapper.cs +++ b/FolderMonitor.UI/FileDropTargetWrapper.cs @@ -10,7 +10,7 @@ using System.Text; using System.Windows.Forms; -namespace RoboMirror +namespace FolderMonitor { [Flags] public enum FileDropMode diff --git a/FolderMonitor.UI/FolderMonitor.UI.csproj b/FolderMonitor.UI/FolderMonitor.UI.csproj index ff0e303..10cef53 100644 --- a/FolderMonitor.UI/FolderMonitor.UI.csproj +++ b/FolderMonitor.UI/FolderMonitor.UI.csproj @@ -79,162 +79,57 @@ - - AlphaFS\NativeError.cs - - - AlphaFS\Network\DfsInfo.cs - - - AlphaFS\Network\DfsStorageInfo.cs - - - AlphaFS\Network\Enumerations\AccessPermissions.cs - - - AlphaFS\Network\Enumerations\Connect.cs - - - AlphaFS\Network\Enumerations\DfsNamespaceFlavors.cs - - - AlphaFS\Network\Enumerations\DfsPropertyFlags.cs - - - AlphaFS\Network\Enumerations\DfsStorageStates.cs - - - AlphaFS\Network\Enumerations\DfsTargetPriorityClass.cs - - - AlphaFS\Network\Enumerations\DfsVolumeStates.cs - - - AlphaFS\Network\Enumerations\ResourceDisplayType.cs - - - AlphaFS\Network\Enumerations\ResourceScope.cs - - - AlphaFS\Network\Enumerations\ResourceType.cs - - - AlphaFS\Network\Enumerations\ResourceUsage.cs - - - AlphaFS\Network\Enumerations\ShareInfoLevel.cs - - - AlphaFS\Network\Enumerations\ShareResourceTypes.cs - - - AlphaFS\Network\Enumerations\ShareType.cs - - - AlphaFS\Network\Host Class\Connect.cs - - - AlphaFS\Network\Host Class\DriveConnection.cs - - - AlphaFS\Network\Host Class\EnumerateDrives.cs - - - AlphaFS\Network\Host Class\EnumerateOpenResources.cs - - - AlphaFS\Network\Host Class\Host.cs - - - AlphaFS\Network\Host Class\ServerMessageBlock.cs - - - AlphaFS\Network\Native Methods\NativeMethods.cs - - - AlphaFS\Network\Native Methods\NativeMethods.WindowsNetworking.cs - - - AlphaFS\Network\Native Structures\CONNECTION_INFO_1.cs - - - AlphaFS\Network\Native Structures\DFS_INFO_200.cs - - - AlphaFS\Network\Native Structures\DFS_INFO_300.cs - - - AlphaFS\Network\Native Structures\DFS_INFO_9.cs - - - AlphaFS\Network\Native Structures\DFS_STORAGE_INFO_1.cs - - - AlphaFS\Network\Native Structures\DFS_TARGET_PRIORITY.cs - - - AlphaFS\Network\Native Structures\FILE_INFO_3.cs - - - AlphaFS\Network\Native Structures\NETRESOURCE.cs - - - AlphaFS\Network\Native Structures\REMOTE_NAME_INFO.cs - - - AlphaFS\Network\Native Structures\SHARE_INFO_1.cs - - - AlphaFS\Network\Native Structures\SHARE_INFO_1005.cs + + clsEncrypt.cs - - AlphaFS\Network\Native Structures\SHARE_INFO_2.cs + + Impersonator.cs - - AlphaFS\Network\Native Structures\SHARE_INFO_503.cs + + MyExtensions.cs - - AlphaFS\Network\OpenConnectionInfo.cs + + Network\Connect.cs - - AlphaFS\Network\OpenResourceInfo.cs + + Network\Enums\Connect.cs - - AlphaFS\Network\ShareInfo.cs + + Network\Enums\ResourceDisplayType.cs - - AlphaFS\OperatingSystem.cs + + Network\Enums\ResourceScope.cs - - AlphaFS\Resources.Designer.cs + + Network\Enums\ResourceType.cs - - AlphaFS\SafeGlobalMemoryBufferHandle.cs + + Network\Enums\ResourceUsage.cs - - AlphaFS\SafeNativeMemoryBufferHandle.cs + + Network\Native Structures\NETRESOURCE.cs - - AlphaFS\Utils.cs + + Network\NativeMethods.WindowsNetworking.cs - - AlphaFS\Win32Errors.cs + + Network\Resources.Designer.cs + True + True + Resources.resx - - clsEncrypt.cs + + Network\SafeGlobalMemoryBufferHandle.cs - - Impersonator.cs + + Network\SafeNativeMemoryBufferHandle.cs - - MyExtensions.cs + + Network\Win32Errors.cs PathCredentials.cs - - UNCAccessWithCredentials.cs - Form @@ -254,6 +149,7 @@ ExcludedItemsDialog.cs + Form @@ -277,13 +173,20 @@ + + True + True + Resources.resx + Component - - AlphaFS\Resources.resx + + Network\Resources.resx + ResXFileCodeGenerator + Resources.Designer.cs ConfigService.cs @@ -305,14 +208,9 @@ ResXFileCodeGenerator - Resources.Designer.cs Designer + Resources.Designer.cs - - True - Resources.resx - True - @@ -361,8 +259,8 @@ - + diff --git a/FolderMonitor.UI/GlobalSuppressions.cs b/FolderMonitor.UI/GlobalSuppressions.cs new file mode 100644 index 0000000..2d3f3f2 Binary files /dev/null and b/FolderMonitor.UI/GlobalSuppressions.cs differ diff --git a/FolderMonitor.UI/MainForm.cs b/FolderMonitor.UI/MainForm.cs index f9a627c..c850a89 100644 --- a/FolderMonitor.UI/MainForm.cs +++ b/FolderMonitor.UI/MainForm.cs @@ -363,7 +363,9 @@ private void stopservice_Click(object sender, EventArgs e) { _service.Stop(); } +#pragma warning disable CS0168 // The variable 'er' is declared but never used catch (Exception er) +#pragma warning restore CS0168 // The variable 'er' is declared but never used { _service.Refresh(); if (_service.Status != ServiceControllerStatus.Stopped && _service.Status != ServiceControllerStatus.StopPending) diff --git a/FolderMonitor.UI/Properties/Resources.resx b/FolderMonitor.UI/Properties/Resources.resx index da0c98c..9898e5a 100644 --- a/FolderMonitor.UI/Properties/Resources.resx +++ b/FolderMonitor.UI/Properties/Resources.resx @@ -218,6 +218,6 @@ ..\Resources\Robocopy.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - ..\bin\Release\FolderMonitor.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\FolderMonitor.exe;System.Byte[], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 \ No newline at end of file diff --git a/FolderMonitor.UI/Resources/FolderMonitor.exe b/FolderMonitor.UI/Resources/FolderMonitor.exe index f87de41..0b85965 100644 Binary files a/FolderMonitor.UI/Resources/FolderMonitor.exe and b/FolderMonitor.UI/Resources/FolderMonitor.exe differ diff --git a/FolderMonitor.UI/ServiceConfig.cs b/FolderMonitor.UI/ServiceConfig.cs index a7cdbdf..e31ad63 100644 --- a/FolderMonitor.UI/ServiceConfig.cs +++ b/FolderMonitor.UI/ServiceConfig.cs @@ -9,95 +9,96 @@ using System.Xml.Serialization; - -internal sealed partial class ServiceConfig +namespace FolderMonitor { - public static string _configFile = ""; - private static ServiceConfig defaultInstance = (new ServiceConfig()); - - public static ServiceConfig Default + internal sealed partial class ServiceConfig { - get + public static string _configFile = ""; + private static ServiceConfig defaultInstance = (new ServiceConfig()); + + public static ServiceConfig Default { + get + { - return defaultInstance; + return defaultInstance; + } } - } - public ServiceConfig() - { + public ServiceConfig() + { - } + } - public static string RoboCopyOptions = "/E /FFT /Z /W:20 /R:100 /ETA /MON:1"; // /MT causes issues - public static string ServiceFilename = "FolderMonitor.exe"; - public static string ServiceConfigFilename = "FolderMonitor.exe.conf"; + public static string RoboCopyOptions = "/E /FFT /Z /W:20 /R:100 /ETA /MON:1"; // /MT causes issues + public static string ServiceFilename = "FolderMonitor.exe"; + public static string ServiceConfigFilename = "FolderMonitor.exe.conf"; - public static string FolderMonitorLogFilename = "FolderMonitor.log"; + public static string FolderMonitorLogFilename = "FolderMonitor.log"; - public void SaveChanges(List paths) - { - var items = new List(paths.Select(x => (PathFromAndTo)x.Clone())); - foreach (var item in items) + public void SaveChanges(List paths) { - if (!string.IsNullOrWhiteSpace(item.From.Password)) - item.From.Password = item.From.Password.Encrypts(); + var items = new List(paths.Select(x => (PathFromAndTo)x.Clone())); + foreach (var item in items) + { + if (!string.IsNullOrWhiteSpace(item.From.Password)) + item.From.Password = item.From.Password.Encrypts(); - if (!string.IsNullOrWhiteSpace(item.To.Password)) - item.To.Password = item.To.Password.Encrypts(); + if (!string.IsNullOrWhiteSpace(item.To.Password)) + item.To.Password = item.To.Password.Encrypts(); + } + XmlSerializer xs = new XmlSerializer(typeof(List)); + TextWriter tw = new StreamWriter(_configFile); + xs.Serialize(tw, items); + tw.Close(); + tw.Dispose(); } - XmlSerializer xs = new XmlSerializer(typeof(List)); - TextWriter tw = new StreamWriter(_configFile); - xs.Serialize(tw, items); - tw.Close(); - tw.Dispose(); - } - public static string RobocopyPath - { - get + public static string RobocopyPath { - var r = Environment.GetFolderPath(Environment.SpecialFolder.System); - r = Path.Combine(r, "robocopy.exe"); - return r; + get + { + var r = Environment.GetFolderPath(Environment.SpecialFolder.System); + r = Path.Combine(r, "robocopy.exe"); + return r; + } } - } - public static bool DoesRoboCopExist() - { - - return File.Exists(RobocopyPath); - - - } + public static bool DoesRoboCopExist() + { - public List GetAllTasks(bool EnabaledOnly) - { + return File.Exists(RobocopyPath); + + + } - List items = new List(); - if (!File.Exists(_configFile)) - return items; - using (var sr = new FileStream(_configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) + public List GetAllTasks(bool EnabaledOnly) { - XmlSerializer xs = new XmlSerializer(typeof(List)); - var xitems = (List)xs.Deserialize(sr); - foreach (var item in xitems) + List items = new List(); + if (!File.Exists(_configFile)) + return items; + using (var sr = new FileStream(_configFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { - if (EnabaledOnly && !item.IsEnabled) continue; - if (!string.IsNullOrWhiteSpace(item.From.Password)) - item.From.Password = item.From.Password.Decrypts(); - - if (!string.IsNullOrWhiteSpace(item.To.Password)) - item.To.Password = item.To.Password.Decrypts(); - items.Add(item); + XmlSerializer xs = new XmlSerializer(typeof(List)); + var xitems = (List)xs.Deserialize(sr); + + foreach (var item in xitems) + { + if (EnabaledOnly && !item.IsEnabled) continue; + if (!string.IsNullOrWhiteSpace(item.From.Password)) + item.From.Password = item.From.Password.Decrypts(); + + if (!string.IsNullOrWhiteSpace(item.To.Password)) + item.To.Password = item.To.Password.Decrypts(); + items.Add(item); + } + sr.Close(); + + return items; } - sr.Close(); - - return items; } - } + } } - diff --git a/FolderMonitor.UI/ServiceManager.cs b/FolderMonitor.UI/ServiceManager.cs index 2d5d4b2..fcf1c7e 100644 --- a/FolderMonitor.UI/ServiceManager.cs +++ b/FolderMonitor.UI/ServiceManager.cs @@ -17,9 +17,15 @@ public class ServiceManager : ServiceController public static string _FolderMonitorServiceName = "DirectoryMonitor"; #region Private : Fields +#pragma warning disable CS0169 // The field 'ServiceManager.m_bExists' is never used private bool m_bExists; +#pragma warning restore CS0169 // The field 'ServiceManager.m_bExists' is never used +#pragma warning disable CS0169 // The field 'ServiceManager.m_bExistsAvailable' is never used private bool m_bExistsAvailable; +#pragma warning restore CS0169 // The field 'ServiceManager.m_bExistsAvailable' is never used +#pragma warning disable CS0169 // The field 'ServiceManager.m_sRemoteResource' is never used private string m_sRemoteResource; +#pragma warning restore CS0169 // The field 'ServiceManager.m_sRemoteResource' is never used private ServiceStartMode m_eStartMode; private bool m_bStartModeAvailable; diff --git a/FolderMonitor.sln b/FolderMonitor.sln index 35e5169..f057c4a 100644 --- a/FolderMonitor.sln +++ b/FolderMonitor.sln @@ -8,6 +8,9 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FolderMonitor.UI", "FolderMonitor.UI\FolderMonitor.UI.csproj", "{9BBDFE62-CB4C-48CC-BCF0-858D22C311E2}" EndProject Global + GlobalSection(Performance) = preSolution + HasPerformanceSessions = true + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU @@ -25,16 +28,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(TeamFoundationVersionControl) = preSolution - SccNumberOfProjects = 3 - SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} - SccTeamFoundationServer = https://ucas-code.visualstudio.com/ - SccLocalPath0 = . - SccProjectUniqueName1 = FolderMonitor\\FolderMonitor.csproj - SccProjectName1 = FolderMonitor - SccLocalPath1 = FolderMonitor - SccProjectUniqueName2 = FolderMonitor.UI\\FolderMonitor.UI.csproj - SccProjectName2 = FolderMonitor.UI - SccLocalPath2 = FolderMonitor.UI - EndGlobalSection EndGlobal diff --git a/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs b/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs deleted file mode 100644 index d4416c5..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/AlternateDataStreamInfo.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Information about an alternate data stream. - /// - public struct AlternateDataStreamInfo - { - #region Constructor - - internal AlternateDataStreamInfo(string fullPath, NativeMethods.WIN32_FIND_STREAM_DATA findData) : this() - { - StreamName = ParseStreamName(findData.cStreamName); - Size = findData.StreamSize; - _fullPath = fullPath; - } - - #endregion // Constructor - - #region Public Properties - - /// Gets the name of the alternate data stream. - /// This value is an empty string for the default stream (:$DATA), and for any other data stream it contains the name of the stream. - /// The name of the stream. - public string StreamName { get; private set; } - - /// Gets the size of the stream. - public long Size { get; private set; } - - - private readonly string _fullPath; - - /// Gets the full path to the stream. - /// - /// This is a path in long path format that can be passed to to open the stream if - /// or - /// is specified. - /// - /// The full path to the stream in long path format. - public string FullPath - { - get { return _fullPath + Path.StreamSeparator + StreamName + Path.StreamDataLabel; } - } - - #endregion // Public Properties - - #region Public Methods - - /// Returns the hash code for this instance. - /// A 32-bit signed integer that is the hash code for this instance. - public override int GetHashCode() - { - return StreamName.GetHashCode(); - } - - /// Indicates whether this instance and a specified object are equal. - /// The object to compare with the current instance. - /// - /// true if and this instance are the same type and represent the same value; otherwise, false. - /// - public override bool Equals(object obj) - { - if (obj is AlternateDataStreamInfo) - { - AlternateDataStreamInfo other = (AlternateDataStreamInfo) obj; - return StreamName.Equals(other.StreamName, StringComparison.OrdinalIgnoreCase) && Size.Equals(other.Size); - } - - return false; - } - - /// Equality operator. - /// The first operand. - /// The second operand. - /// The result of the operation. - public static bool operator ==(AlternateDataStreamInfo first, AlternateDataStreamInfo second) - { - return first.Equals(second); - } - - /// Inequality operator. - /// The first operand. - /// The second operand. - /// The result of the operation. - public static bool operator !=(AlternateDataStreamInfo first, AlternateDataStreamInfo second) - { - return !first.Equals(second); - } - - #endregion // Public Methods - - #region Private Methods - - private static string ParseStreamName(string input) - { - if (input == null || input.Length < 2) - return string.Empty; - - if (input[0] != Path.StreamSeparatorChar) - throw new ArgumentException(Resources.Invalid_Stream_Name); - - var sb = new StringBuilder(); - for (int i = 1; i < input.Length; i++) - { - if (input[i] == Path.StreamSeparatorChar) - break; - - sb.Append(input[i]); - } - - return sb.ToString(); - } - - #endregion // Private Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs b/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs deleted file mode 100644 index 3a03001..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/BackupFileStream.cs +++ /dev/null @@ -1,650 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using SecurityNativeMethods = Alphaleonis.Win32.Security.NativeMethods; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The provides access to data associated with a specific file or directory, including security information and alternative data streams, for backup and restore operations. - /// This class uses the BackupRead, - /// BackupSeek and - /// BackupWrite functions from the Win32 API to provide access to the file or directory. - /// - public sealed class BackupFileStream : Stream - { - #region Private Fields - - private readonly bool _canRead; - private readonly bool _canWrite; - private readonly bool _processSecurity; - - [SuppressMessage("Microsoft.Reliability", "CA2006:UseSafeHandleToEncapsulateNativeResources")] - private IntPtr _context = IntPtr.Zero; - - #endregion // Private Fields - - #region Construction and Destruction - - /// Initializes a new instance of the class with the specified path and creation mode. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// The file will be opened for exclusive access for both reading and writing. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(string path, FileMode mode) - : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, FileSystemRights.Read | FileSystemRights.Write, FileShare.None, true, PathFormat.RelativePath), FileSystemRights.Read | FileSystemRights.Write) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode and access rights. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// The file will be opened for exclusive access. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(string path, FileMode mode, FileSystemRights access) - : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, access, FileShare.None, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share) - : this(File.CreateFileCore(null, path, ExtendedFileAttributes.Normal, null, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, and additional file attributes. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - /// A constant that specifies additional file attributes. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes) - : this(File.CreateFileCore(null, path, attributes, null, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, additional file attributes, access control and audit security. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - /// A constant that specifies additional file attributes. - /// A constant that determines the access control and audit security for the file. This parameter This parameter may be . - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes, FileSecurity security) - : this(File.CreateFileCore(null, path, attributes, security, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - #region Transactional - - /// Initializes a new instance of the class with the specified path and creation mode. - /// The transaction. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// The file will be opened for exclusive access for both reading and writing. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(KernelTransaction transaction, string path, FileMode mode) - : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, FileSystemRights.Read | FileSystemRights.Write, FileShare.None, true, PathFormat.RelativePath), FileSystemRights.Read | FileSystemRights.Write) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode and access rights. - /// The transaction. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// The file will be opened for exclusive access. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access) - : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, access, FileShare.None, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission. - /// The transaction. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share) - : this(File.CreateFileCore(transaction, path, ExtendedFileAttributes.Normal, null, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, and additional file attributes. - /// The transaction. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - /// A constant that specifies additional file attributes. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes) - : this(File.CreateFileCore(transaction, path, attributes, null, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - /// Initializes a new instance of the class with the specified path, creation mode, access rights and sharing permission, additional file attributes, access control and audit security. - /// The transaction. - /// A relative or absolute path for the file that the current object will encapsulate. - /// A constant that determines how to open or create the file. - /// A constant that determines the access rights to use when creating access and audit rules for the file. - /// A constant that determines how the file will be shared by processes. - /// A constant that specifies additional file attributes. - /// A constant that determines the access control and audit security for the file. This parameter This parameter may be . - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public BackupFileStream(KernelTransaction transaction, string path, FileMode mode, FileSystemRights access, FileShare share, ExtendedFileAttributes attributes, FileSecurity security) - : this(File.CreateFileCore(transaction, path, attributes, security, mode, access, share, true, PathFormat.RelativePath), access) - { - } - - #endregion // Transacted - - - #region Stream - - /// Initializes a new instance of the class for the specified file handle, with the specified read/write permission. - /// A file handle for the file that this object will encapsulate. - /// A constant that gets the and properties of the object. - - [SecurityCritical] - public BackupFileStream(SafeFileHandle handle, FileSystemRights access) - { - if (handle == null) - throw new ArgumentNullException("handle", Resources.Handle_Is_Invalid); - - if (handle.IsInvalid) - { - handle.Close(); - throw new ArgumentException(Resources.Handle_Is_Invalid); - } - - if (handle.IsClosed) - throw new ArgumentException(Resources.Handle_Is_Closed); - - - SafeFileHandle = handle; - - _canRead = (access & FileSystemRights.ReadData) != 0; - _canWrite = (access & FileSystemRights.WriteData) != 0; - _processSecurity = true; - } - - #endregion // Stream - - #endregion // Construction and Destruction - - #region NotSupportedException - - /// When overridden in a derived class, gets the length in bytes of the stream. - /// This method always throws an exception. - /// - public override long Length - { - get { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); } - } - - /// When overridden in a derived class, gets or sets the position within the current stream. - /// This method always throws an exception. - /// - public override long Position - { - get { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); } - set { throw new NotSupportedException(Resources.No_Stream_Seeking_Support); } - } - - - /// When overridden in a derived class, sets the position within the current stream. - /// A byte offset relative to the parameter. - /// A value of type indicating the reference point used to obtain the new position. - /// The new position within the current stream. - /// This stream does not support seeking using this method, and calling this method will always throw . See for an alternative way of seeking forward. - /// - public override long Seek(long offset, SeekOrigin origin) - { - throw new NotSupportedException(Resources.No_Stream_Seeking_Support); - } - - - /// When overridden in a derived class, sets the length of the current stream. - /// The desired length of the current stream in bytes. - /// This method is not supported by the class, and calling it will always generate a . - /// - public override void SetLength(long value) - { - throw new NotSupportedException(Resources.No_Stream_Seeking_Support); - } - - #endregion // NotSupportedException - - #region Properties - - /// Gets a value indicating whether the current stream supports reading. - /// if the stream supports reading, otherwise. - public override bool CanRead - { - get { return _canRead; } - } - - /// Gets a value indicating whether the current stream supports seeking. - /// This method always returns . - public override bool CanSeek - { - get { return false; } - } - - /// Gets a value indicating whether the current stream supports writing. - /// if the stream supports writing, otherwise. - public override bool CanWrite - { - get { return _canWrite; } - } - - /// Gets a object that represents the operating system file handle for the file that the current object encapsulates. - /// A object that represents the operating system file handle for the file that - /// the current object encapsulates. - private SafeFileHandle SafeFileHandle { get; set; } - - #endregion // Properties - - #region Methods - - /// Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. - /// This method will not backup the access-control list (ACL) data for the file or directory. - /// - /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values between - /// and ( + - 1) replaced by the bytes read from the - /// current source. - /// - /// - /// The zero-based byte offset in at which to begin storing the data read from the current stream. - /// - /// The maximum number of bytes to be read from the current stream. - /// - /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not - /// currently available, or zero (0) if the end of the stream has been reached. - /// - /// - /// - /// - /// - /// - /// - public override int Read(byte[] buffer, int offset, int count) - { - return Read(buffer, offset, count, false); - } - - /// When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read. - /// An array of bytes. When this method returns, the buffer contains the specified byte array with the values - /// between and ( + - 1) replaced by the bytes read from the current source. - /// The zero-based byte offset in at which to begin storing the data read from the current stream. - /// The maximum number of bytes to be read from the current stream. - /// Indicates whether the function will backup the access-control list (ACL) data for the file or directory. - /// - /// The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not - /// currently available, or zero (0) if the end of the stream has been reached. - /// - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] - [SecurityCritical] - public int Read(byte[] buffer, int offset, int count, bool processSecurity) - { - if (buffer == null) - throw new ArgumentNullException("buffer"); - - if (!CanRead) - throw new NotSupportedException("Stream does not support reading"); - - if (offset + count > buffer.Length) - throw new ArgumentException("The sum of offset and count is larger than the size of the buffer."); - - if (offset < 0) - throw new ArgumentOutOfRangeException("offset", offset, Resources.Negative_Offset); - - if (count < 0) - throw new ArgumentOutOfRangeException("count", count, Resources.Negative_Count); - - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(count)) - { - uint numberOfBytesRead; - - if (!NativeMethods.BackupRead(SafeFileHandle, safeBuffer, (uint)safeBuffer.Capacity, out numberOfBytesRead, false, processSecurity, ref _context)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - // See File.GetAccessControlCore(): .CopyTo() does not work there? - safeBuffer.CopyTo(buffer, offset, count); - - return (int)numberOfBytesRead; - } - } - - - /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// Writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// - /// An array of bytes. This method copies bytes from to the current stream. - /// The zero-based byte offset in at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - /// - /// - /// - /// - /// - /// This method will not process the access-control list (ACL) data for the file or directory. - public override void Write(byte[] buffer, int offset, int count) - { - Write(buffer, offset, count, false); - } - - /// When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written. - /// An array of bytes. This method copies bytes from to the current stream. - /// The zero-based byte offset in at which to begin copying bytes to the current stream. - /// The number of bytes to be written to the current stream. - /// Specifies whether the function will restore the access-control list (ACL) data for the file or directory. - /// If this is you need to specify and access when - /// opening the file or directory handle. If the handle does not have those access rights, the operating system denies - /// access to the ACL data, and ACL data restoration will not occur. - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] - [SecurityCritical] - public void Write(byte[] buffer, int offset, int count, bool processSecurity) - { - if (buffer == null) - throw new ArgumentNullException("buffer"); - - if (offset < 0) - throw new ArgumentOutOfRangeException("offset", offset, Resources.Negative_Offset); - - if (count < 0) - throw new ArgumentOutOfRangeException("count", count, Resources.Negative_Count); - - if (offset + count > buffer.Length) - throw new ArgumentException(Resources.Buffer_Not_Large_Enough); - - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(count)) - { - safeBuffer.CopyFrom(buffer, offset, count); - - uint bytesWritten; - - if (!NativeMethods.BackupWrite(SafeFileHandle, safeBuffer, (uint)safeBuffer.Capacity, out bytesWritten, false, processSecurity, ref _context)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - } - - - /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device. - public override void Flush() - { - if (!NativeMethods.FlushFileBuffers(SafeFileHandle)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - - - /// Skips ahead the specified number of bytes from the current stream. - /// This method represents the Win32 API implementation of BackupSeek. - /// - /// Applications use the method to skip portions of a data stream that cause errors. This function does not - /// seek across stream headers. For example, this function cannot be used to skip the stream name. If an application - /// attempts to seek past the end of a substream, the function fails, the return value indicates the actual number of bytes - /// the function seeks, and the file position is placed at the start of the next stream header. - /// - /// - /// The number of bytes to skip. - /// The number of bytes actually skipped. - [SecurityCritical] - public long Skip(long bytes) - { - uint lowSought, highSought; - if (!NativeMethods.BackupSeek(SafeFileHandle, NativeMethods.GetLowOrderDword(bytes), NativeMethods.GetHighOrderDword(bytes), out lowSought, out highSought, ref _context)) - { - int lastError = Marshal.GetLastWin32Error(); - - // Error Code 25 indicates a seek error, we just skip that here. - if (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_SEEK) - NativeError.ThrowException(lastError); - } - - return NativeMethods.ToLong(highSought, lowSought); - } - - - /// Gets a object that encapsulates the access control list (ACL) entries for the file described by the current object. - /// - /// - /// A object that encapsulates the access control list (ACL) entries for the file described by the current - /// object. - /// - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public FileSecurity GetAccessControl() - { - IntPtr pSidOwner, pSidGroup, pDacl, pSacl; - SafeGlobalMemoryBufferHandle pSecurityDescriptor; - - uint lastError = SecurityNativeMethods.GetSecurityInfo(SafeFileHandle, ObjectType.FileObject, - SecurityInformation.Group | SecurityInformation.Owner | SecurityInformation.Label | SecurityInformation.Dacl | SecurityInformation.Sacl, - out pSidOwner, out pSidGroup, out pDacl, out pSacl, out pSecurityDescriptor); - - try - { - if (lastError != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException((int)lastError); - - if (pSecurityDescriptor != null && pSecurityDescriptor.IsInvalid) - { - pSecurityDescriptor.Close(); - throw new IOException(Resources.Returned_Invalid_Security_Descriptor); - } - - uint length = SecurityNativeMethods.GetSecurityDescriptorLength(pSecurityDescriptor); - - byte[] managedBuffer = new byte[length]; - - - // .CopyTo() does not work there? - if (pSecurityDescriptor != null) - pSecurityDescriptor.CopyTo(managedBuffer, 0, (int) length); - - - var fs = new FileSecurity(); - fs.SetSecurityDescriptorBinaryForm(managedBuffer); - - return fs; - } - finally - { - if (pSecurityDescriptor != null) - pSecurityDescriptor.Close(); - } - } - - - /// Applies access control list (ACL) entries described by a object to the file described by the current object. - /// A object that describes an ACL entry to apply to the current file. - [SecurityCritical] - public void SetAccessControl(ObjectSecurity fileSecurity) - { - File.SetAccessControlCore(null, SafeFileHandle, fileSecurity, AccessControlSections.All, PathFormat.LongFullPath); - } - - - /// Prevents other processes from changing the while permitting read access. - /// The beginning of the range to lock. The value of this parameter must be equal to or greater than zero (0). - /// The range to be locked. - /// - /// - [SecurityCritical] - public void Lock(long position, long length) - { - if (position < 0) - throw new ArgumentOutOfRangeException("position", position, Resources.Unlock_Position_Negative); - - if (length < 0) - throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length); - - if (!NativeMethods.LockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length))) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - - - /// Allows access by other processes to all or part of a file that was previously locked. - /// The beginning of the range to unlock. - /// The range to be unlocked. - /// - /// - /// - [SecurityCritical] - public void Unlock(long position, long length) - { - if (position < 0) - throw new ArgumentOutOfRangeException("position", position, Resources.Unlock_Position_Negative); - - if (length < 0) - throw new ArgumentOutOfRangeException("length", length, Resources.Negative_Lock_Length); - - if (!NativeMethods.UnlockFile(SafeFileHandle, NativeMethods.GetLowOrderDword(position), NativeMethods.GetHighOrderDword(position), NativeMethods.GetLowOrderDword(length), NativeMethods.GetHighOrderDword(length))) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - - - /// Reads a stream header from the current . - /// The stream header read from the current , or if the end-of-file - /// was reached before the required number of bytes of a header could be read. - /// - /// The stream must be positioned at where an actual header starts for the returned object to represent valid - /// information. - [SecurityCritical] - public BackupStreamInfo ReadStreamInfo() - { - var sizeOf = Marshal.SizeOf(typeof(NativeMethods.WIN32_STREAM_ID)); - - using (var hBuf = new SafeGlobalMemoryBufferHandle(sizeOf)) - { - uint numberOfBytesRead; - - if (!NativeMethods.BackupRead(SafeFileHandle, hBuf, (uint) sizeOf, out numberOfBytesRead, false, _processSecurity, ref _context)) - NativeError.ThrowException(); - - - if (numberOfBytesRead == 0) - return null; - - - if (numberOfBytesRead < sizeOf) - throw new IOException(Resources.Read_Incomplete_Header); - - var streamID = hBuf.PtrToStructure(0); - - uint nameLength = (uint) Math.Min(streamID.dwStreamNameSize, hBuf.Capacity); - - - if (!NativeMethods.BackupRead(SafeFileHandle, hBuf, nameLength, out numberOfBytesRead, false, _processSecurity, ref _context)) - NativeError.ThrowException(); - - string name = hBuf.PtrToStringUni(0, (int) nameLength/2); - - return new BackupStreamInfo(streamID, name); - } - } - - #endregion // Methods - - #region Disposable Members - - /// Releases the unmanaged resources used by the and optionally releases the managed resources. - /// to release both managed and unmanaged resources; to release only unmanaged resources. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - protected override void Dispose(bool disposing) - { - // If one of the constructors previously threw an exception, - // than the object hasn't been initialized properly and call from finalize will fail. - - if (SafeFileHandle != null && !SafeFileHandle.IsInvalid) - { - if (_context != IntPtr.Zero) - { - try - { - uint temp; - - // MSDN: To release the memory used by the data structure, call BackupRead with the bAbort parameter set to TRUE when the backup operation is complete. - if (!NativeMethods.BackupRead(SafeFileHandle, new SafeGlobalMemoryBufferHandle(), 0, out temp, true, false, ref _context)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - finally - { - _context = IntPtr.Zero; - SafeFileHandle.Close(); - } - } - } - - base.Dispose(disposing); - } - - /// Releases unmanaged resources and performs other cleanup operations before the is reclaimed by garbage collection. - ~BackupFileStream() - { - Dispose(false); - } - - #endregion // Disposable Members - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs b/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs deleted file mode 100644 index 2bc85a5..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/BackupStreamInfo.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// The structure contains stream header data. - /// - public sealed class BackupStreamInfo - { - #region Private Fields - - private readonly long m_size; - private readonly string m_name; - private readonly BackupStreamType m_streamType; - private readonly StreamAttributes m_attributes; - - #endregion - - #region Constructor - - /// Initializes a new instance of the class. - /// The stream ID. - /// The name. - internal BackupStreamInfo(NativeMethods.WIN32_STREAM_ID streamID, string name) - { - m_name = name; - m_size = (long) streamID.Size; - m_attributes = streamID.dwStreamAttributes; - m_streamType = streamID.dwStreamId; - } - - #endregion - - #region Public Properties - - /// Gets the size of the data in the substream, in bytes. - /// The size of the data in the substream, in bytes. - public long Size - { - get { return m_size; } - } - - /// Gets a string that specifies the name of the alternative data stream. - /// A string that specifies the name of the alternative data stream. - public string Name - { - get { return m_name; } - } - - /// Gets the type of the data in the stream. - /// The type of the data in the stream. - public BackupStreamType StreamType - { - get { return m_streamType; } - } - - /// Gets the attributes of the data to facilitate cross-operating system transfer. - /// Attributes of the data to facilitate cross-operating system transfer. - public StreamAttributes Attributes - { - get { return m_attributes; } - } - - #endregion // Public Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs b/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs deleted file mode 100644 index e46dbcd..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/ByHandleFileInfo.cs +++ /dev/null @@ -1,177 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - #region ByHandleFileInfo - - /// Contains information that the GetFileInformationByHandle function retrieves. - [SerializableAttribute] - [SecurityCritical] - public sealed class ByHandleFileInfo - { - #region Constructor - - internal ByHandleFileInfo(NativeMethods.BY_HANDLE_FILE_INFORMATION fibh) - { - CreationTimeUtc = DateTime.FromFileTimeUtc(fibh.ftCreationTime); - LastAccessTimeUtc = DateTime.FromFileTimeUtc(fibh.ftLastAccessTime); - LastWriteTimeUtc = DateTime.FromFileTimeUtc(fibh.ftLastWriteTime); - - Attributes = fibh.dwFileAttributes; - FileIndex = NativeMethods.ToLong(fibh.nFileIndexHigh, fibh.nFileIndexLow); - FileSize = NativeMethods.ToLong(fibh.nFileSizeHigh, fibh.nFileSizeLow); - NumberOfLinks = fibh.nNumberOfLinks; - VolumeSerialNumber = fibh.dwVolumeSerialNumber; - } - - #endregion // Constructor - - #region Properties - - #region Attributes - - /// Gets the file attributes. - /// The file attributes. - public FileAttributes Attributes { get; private set; } - - #endregion // Attributes - - #region CreationTime - - /// Gets the time this entry was created. - /// The time this entry was created. - public DateTime CreationTime - { - get { return CreationTimeUtc.ToLocalTime(); } - } - - #endregion // CreationTime - - #region CreationTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was created. - /// The time, in coordinated universal time (UTC), this entry was created. - public DateTime CreationTimeUtc { get; private set; } - - #endregion // CreationTimeUtc - - #region LastAccessTime - - /// Gets the time this entry was last accessed. - /// For a file, the structure specifies the last time that a file is read from or written to. - /// For a directory, the structure specifies when the directory is created. - /// For both files and directories, the specified date is correct, but the time of day is always set to midnight. - /// If the underlying file system does not support the last access time, this member is zero (0). - /// - /// The time this entry was last accessed. - public DateTime LastAccessTime - { - get { return LastAccessTimeUtc.ToLocalTime(); } - } - - #endregion // LastAccessTime - - #region LastAccessTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was last accessed. - /// For a file, the structure specifies the last time that a file is read from or written to. - /// For a directory, the structure specifies when the directory is created. - /// For both files and directories, the specified date is correct, but the time of day is always set to midnight. - /// If the underlying file system does not support the last access time, this member is zero (0). - /// - /// The time, in coordinated universal time (UTC), this entry was last accessed. - public DateTime LastAccessTimeUtc { get; private set; } - - #endregion // LastAccessTimeUtc - - #region LastWriteTime - - /// Gets the time this entry was last modified. - /// For a file, the structure specifies the last time that a file is written to. - /// For a directory, the structure specifies when the directory is created. - /// If the underlying file system does not support the last access time, this member is zero (0). - /// - /// The time this entry was last modified. - public DateTime LastWriteTime - { - get { return LastWriteTimeUtc.ToLocalTime(); } - } - - #endregion // LastWriteTime - - #region LastWriteTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was last modified. - /// For a file, the structure specifies the last time that a file is written to. - /// For a directory, the structure specifies when the directory is created. - /// If the underlying file system does not support the last access time, this member is zero (0). - /// - /// The time, in coordinated universal time (UTC), this entry was last modified. - public DateTime LastWriteTimeUtc { get; private set; } - - #endregion // LastWriteTimeUtc - - #region VolumeSerialNumber - - /// Gets the serial number of the volume that contains a file. - /// The serial number of the volume that contains a file. - public int VolumeSerialNumber { get; private set; } - - #endregion // VolumeSerialNumber - - #region FileSize - - /// Gets the size of the file. - /// The size of the file. - public long FileSize { get; private set; } - - #endregion // FileSize - - #region NumberOfLinks - - /// Gets the number of links to this file. For the FAT file system this member is always 1. For the NTFS file system, it can be more than 1. - /// The number of links to this file. - public int NumberOfLinks { get; private set; } - - #endregion // NumberOfLinks - - #region FileIndex - - /// - /// Gets the unique identifier associated with the file. The identifier and the volume serial number uniquely identify a - /// file on a single computer. To determine whether two open handles represent the same file, combine the identifier - /// and the volume serial number for each file and compare them. - /// - /// The unique identifier of the file. - public long FileIndex { get; private set; } - - #endregion // FileIndex - - #endregion // Properties - } - - #endregion // ByHandleFileInfo -} diff --git a/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs b/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs deleted file mode 100644 index 035d52b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/ChangeErrorMode.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Controls whether the system will handle the specified types of serious errors or whether the process will handle them. - /// Minimum supported client: Windows 2000 Professional - /// Minimum supported server: Windows 2000 Server - public sealed class ChangeErrorMode : IDisposable - { - private readonly ErrorMode _oldMode; - - /// ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups. - /// One of the values. - public ChangeErrorMode(ErrorMode mode) - { - if (IsAtLeastWindows7) - SetThreadErrorMode(mode, out _oldMode); - else - _oldMode = SetErrorMode(mode); - } - - void IDisposable.Dispose() - { - ErrorMode oldMode; - - if (IsAtLeastWindows7) - SetThreadErrorMode(_oldMode, out oldMode); - else - SetErrorMode(_oldMode); - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs b/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs deleted file mode 100644 index 4e62e64..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Callback used by CopyFileXxx and MoveFileXxx to report progress about the copy/move operation. - public delegate CopyMoveProgressResult CopyMoveProgressRoutine(long totalFileSize, long totalBytesTransferred, long streamSize, long streamBytesTransferred, int streamNumber, CopyMoveProgressCallbackReason callbackReason, object userData); -} diff --git a/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs b/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs deleted file mode 100644 index db216e1..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/CopyMoveResult.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Class for CopyMoveResult that contains the results for the Copy or Move action. - public sealed class CopyMoveResult - { - /// Create a CopyMoveResult class instance for the Copy or Move action. - /// Indicates the source file or directory. - /// Indicates the destination file or directory. - /// Indicates if the action was canceled. - /// The error code encountered during the Copy or Move action. - public CopyMoveResult(string source, string destination, bool isCanceled, int errorCode) - { - Source = source; - Destination = destination; - IsCanceled = isCanceled; - ErrorCode = errorCode; - } - - - /// The error code encountered during the Copy or Move action. - /// 0 (zero) indicates success. - public int ErrorCode { get; internal set; } - - - /// When true indicates that the Copy or Move action was canceled. - /// when the Copy/Move action was canceled. Otherwise . - public bool IsCanceled { get; internal set; } - - - /// Indicates the source file or directory. - public string Source { get; private set; } - - - /// Indicates the destination file or directory. - public string Destination { get; private set; } - - - /// The total number of folders copied. - public long TotalFolders { get; internal set; } - - - /// The total number of files copied. - public long TotalFiles { get; internal set; } - - - /// The total number of bytes copied. - public long TotalBytes { get; internal set; } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Device.cs b/FolderMonitor/AlphaFS/Filesystem/Device.cs deleted file mode 100644 index 0d3318b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Device.cs +++ /dev/null @@ -1,459 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Network; -using Microsoft.Win32.SafeHandles; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides static methods to retrieve device resource information from a local or remote host. - public static class Device - { - #region EnumerateDevices - - /// Enumerates all available devices on the local host. - /// instances of type from the local host. - /// One of the devices. - [SecurityCritical] - public static IEnumerable EnumerateDevices(DeviceGuid deviceGuid) - { - return EnumerateDevices(null, deviceGuid); - } - - /// Enumerates all available devices of type on the local or remote host. - /// instances of type for the specified . - /// The name of the local or remote host on which the device resides. refers to the local host. - /// One of the devices. - [SecurityCritical] - public static IEnumerable EnumerateDevices(string hostName, DeviceGuid deviceGuid) - { - return EnumerateDevicesCore(null, hostName, deviceGuid); - } - - #endregion // EnumerateDevices - - #region Internal Methods - - #region EnumerateDevicesCore - - /// Enumerates all available devices on the local or remote host. - [SecurityCritical] - internal static IEnumerable EnumerateDevicesCore(SafeHandle safeHandle, string hostName, DeviceGuid deviceInterfaceGuid) - { - var callerHandle = safeHandle != null; - var deviceGuid = new Guid(Utils.GetEnumDescription(deviceInterfaceGuid)); - - - // CM_Connect_Machine() - // MSDN Note: Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. - // You cannot access remote machines when running on these versions of Windows. - // http://msdn.microsoft.com/en-us/library/windows/hardware/ff537948%28v=vs.85%29.aspx - - SafeCmConnectMachineHandle safeMachineHandle; - var lastError = NativeMethods.CM_Connect_Machine(Path.LocalToUncCore(Host.GetUncName(hostName), false, false, false), out safeMachineHandle); - - if (safeMachineHandle != null && safeMachineHandle.IsInvalid) - { - safeMachineHandle.Close(); - NativeError.ThrowException(lastError, Resources.Handle_Is_Invalid); - } - - using (safeMachineHandle) - { - // Start at the "Root" of the device tree of the specified machine. - if (!callerHandle) - safeHandle = NativeMethods.SetupDiGetClassDevsEx(ref deviceGuid, IntPtr.Zero, IntPtr.Zero, - NativeMethods.SetupDiGetClassDevsExFlags.Present | - NativeMethods.SetupDiGetClassDevsExFlags.DeviceInterface, - IntPtr.Zero, hostName, IntPtr.Zero); - - if (safeHandle != null && safeHandle.IsInvalid) - { - safeHandle.Close(); - NativeError.ThrowException(Marshal.GetLastWin32Error(), Resources.Handle_Is_Invalid); - } - - - try - { - uint memberInterfaceIndex = 0; - var deviceInterfaceData = CreateDeviceInterfaceDataInstance(); - - // Start enumerating Device Interfaces. - while (NativeMethods.SetupDiEnumDeviceInterfaces(safeHandle, IntPtr.Zero, ref deviceGuid, memberInterfaceIndex++, ref deviceInterfaceData)) - { - lastError = Marshal.GetLastWin32Error(); - if (lastError != Win32Errors.NO_ERROR) - NativeError.ThrowException(lastError, hostName); - - - var deviceInfoData = CreateDeviceInfoDataInstance(); - var deviceInterfaceDetailData = GetDeviceInterfaceDetailDataInstance(safeHandle, deviceInterfaceData, deviceInfoData); - - // Get device interace details. - if (!NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref deviceInterfaceData, ref deviceInterfaceDetailData, NativeMethods.DefaultFileBufferSize, IntPtr.Zero, ref deviceInfoData)) - { - lastError = Marshal.GetLastWin32Error(); - if (lastError != Win32Errors.NO_ERROR) - NativeError.ThrowException(lastError, hostName); - } - - // Create DeviceInfo instance. - // Set DevicePath property of DeviceInfo instance. - var deviceInfo = new DeviceInfo(hostName) { DevicePath = deviceInterfaceDetailData.DevicePath }; - - - // Current InstanceId is at the "USBSTOR" level, so we - // need up "move up" one level to get to the "USB" level. - uint ptrPrevious; - - // CM_Get_Parent_Ex() - // Note: Using this function to access remote machines is not supported - // beginning with Windows 8 and Windows Server 2012, as this functionality has been removed. - // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538615%28v=vs.85%29.aspx - - lastError = NativeMethods.CM_Get_Parent_Ex(out ptrPrevious, deviceInfoData.DevInst, 0, safeMachineHandle); - if (lastError != Win32Errors.CR_SUCCESS) - NativeError.ThrowException(lastError, hostName); - - - // Now we get the InstanceID of the USB level device. - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize)) - { - // CM_Get_Device_ID_Ex() - // Note: Using this function to access remote machines is not supported beginning with Windows 8 and Windows Server 2012, - // as this functionality has been removed. - // http://msdn.microsoft.com/en-us/library/windows/hardware/ff538411%28v=vs.85%29.aspx - - lastError = NativeMethods.CM_Get_Device_ID_Ex(deviceInfoData.DevInst, safeBuffer, (uint)safeBuffer.Capacity, 0, safeMachineHandle); - if (lastError != Win32Errors.CR_SUCCESS) - NativeError.ThrowException(lastError, hostName); - - // Add to instance. - deviceInfo.InstanceId = safeBuffer.PtrToStringUni(); - } - - #region Get Registry Properties - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize)) - { - uint regType; - string dataString; - var safeBufferCapacity = (uint) safeBuffer.Capacity; - - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.BaseContainerId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - { - dataString = safeBuffer.PtrToStringUni(); - if (!Utils.IsNullOrWhiteSpace(dataString)) - deviceInfo.BaseContainerId = new Guid(dataString); - } - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.ClassGuid, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - { - dataString = safeBuffer.PtrToStringUni(); - if (!Utils.IsNullOrWhiteSpace(dataString)) - deviceInfo.ClassGuid = new Guid(dataString); - } - - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Class, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.Class = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.CompatibleIds, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.CompatibleIds = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.DeviceDescription, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.DeviceDescription = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Driver, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.Driver = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.EnumeratorName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.EnumeratorName = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.FriendlyName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.FriendlyName = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.HardwareId, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.HardwareId = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationInformation, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.LocationInformation = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.LocationPaths, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.LocationPaths = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Manufacturer, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.Manufacturer = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.PhysicalDeviceObjectName, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.PhysicalDeviceObjectName = safeBuffer.PtrToStringUni(); - - if (NativeMethods.SetupDiGetDeviceRegistryProperty(safeHandle, ref deviceInfoData, NativeMethods.SetupDiGetDeviceRegistryPropertyEnum.Service, out regType, safeBuffer, safeBufferCapacity, IntPtr.Zero)) - deviceInfo.Service = safeBuffer.PtrToStringUni(); - } - - #endregion // Get Registry Properties - - yield return deviceInfo; - - // Get new structure instance. - deviceInterfaceData = CreateDeviceInterfaceDataInstance(); - } - } - finally - { - // Handle is ours, dispose. - if (!callerHandle && safeHandle != null) - safeHandle.Close(); - } - } - } - - #endregion // EnumerateDevicesCore - - #region GetLinkTargetInfoCore - - /// Get information about the target of a mount point or symbolic link on an NTFS file system. - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Disposing is controlled.")] - [SecurityCritical] - internal static LinkTargetInfo GetLinkTargetInfoCore(SafeFileHandle safeHandle) - { - // Start with a large buffer to prevent a 2nd call. - // MAXIMUM_REPARSE_DATA_BUFFER_SIZE = 16384 - uint bytesReturned = 4*NativeMethods.DefaultFileBufferSize; - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle((int) bytesReturned)) - { - while (true) - { - // DeviceIoControlMethod.Buffered = 0, - // DeviceIoControlFileDevice.FileSystem = 9 - // FsctlGetReparsePoint = (DeviceIoControlFileDevice.FileSystem << 16) | (42 << 2) | DeviceIoControlMethod.Buffered | (0 << 14) - - if (!NativeMethods.DeviceIoControl(safeHandle, ((9 << 16) | (42 << 2) | 0 | (0 << 14)), IntPtr.Zero, 0, safeBuffer, (uint) safeBuffer.Capacity, out bytesReturned, IntPtr.Zero)) - { - var lastError = Marshal.GetLastWin32Error(); - switch ((uint) lastError) - { - case Win32Errors.ERROR_MORE_DATA: - case Win32Errors.ERROR_INSUFFICIENT_BUFFER: - if (safeBuffer.Capacity < bytesReturned) - { - safeBuffer.Close(); - break; - } - - NativeError.ThrowException(lastError); - break; - } - } - else - break; - } - - - var marshalReparseBuffer = (int) Marshal.OffsetOf(typeof(NativeMethods.ReparseDataBufferHeader), "data"); - - var header = safeBuffer.PtrToStructure(0); - - var dataOffset = (int) (marshalReparseBuffer + (header.ReparseTag == ReparsePointTag.MountPoint - ? Marshal.OffsetOf(typeof (NativeMethods.MountPointReparseBuffer), "data") - : Marshal.OffsetOf(typeof (NativeMethods.SymbolicLinkReparseBuffer), "data")).ToInt64()); - - var dataBuffer = new byte[bytesReturned - dataOffset]; - - - switch (header.ReparseTag) - { - case ReparsePointTag.MountPoint: - var mountPoint = safeBuffer.PtrToStructure(marshalReparseBuffer); - - safeBuffer.CopyTo(dataOffset, dataBuffer, 0, dataBuffer.Length); - - return new LinkTargetInfo( - Encoding.Unicode.GetString(dataBuffer, mountPoint.SubstituteNameOffset, mountPoint.SubstituteNameLength), - Encoding.Unicode.GetString(dataBuffer, mountPoint.PrintNameOffset, mountPoint.PrintNameLength)); - - - case ReparsePointTag.SymLink: - var symLink = safeBuffer.PtrToStructure(marshalReparseBuffer); - - safeBuffer.CopyTo(dataOffset, dataBuffer, 0, dataBuffer.Length); - - return new SymbolicLinkTargetInfo( - Encoding.Unicode.GetString(dataBuffer, symLink.SubstituteNameOffset, symLink.SubstituteNameLength), - Encoding.Unicode.GetString(dataBuffer, symLink.PrintNameOffset, symLink.PrintNameLength), symLink.Flags); - - - default: - throw new UnrecognizedReparsePointException(); - } - } - } - - #endregion // GetLinkTargetInfoCore - - #region ToggleCompressionCore - - /// Sets the NTFS compression state of a file or directory on a volume whose file system supports per-file and per-directory compression. - /// Specifies that is a file or directory. - /// The transaction. - /// A path that describes a folder or file to compress or decompress. - /// = compress, = decompress - /// Indicates the format of the path parameter(s). - - [SecurityCritical] - internal static void ToggleCompressionCore(bool isFolder, KernelTransaction transaction, string path, bool compress, PathFormat pathFormat) - { - using (var handle = File.CreateFileCore(transaction, path, isFolder ? ExtendedFileAttributes.BackupSemantics : ExtendedFileAttributes.Normal, null, FileMode.Open, FileSystemRights.Modify, FileShare.None, true, pathFormat)) - { - // DeviceIoControlMethod.Buffered = 0, - // DeviceIoControlFileDevice.FileSystem = 9 - // FsctlSetCompression = (DeviceIoControlFileDevice.FileSystem << 16) | (16 << 2) | DeviceIoControlMethod.Buffered | ((FileAccess.Read | FileAccess.Write) << 14) - - // 0 = Decompress, 1 = Compress. - InvokeIoControlUnknownSize(handle, ((9 << 16) | (16 << 2) | 0 | ((uint)(FileAccess.Read | FileAccess.Write) << 14)), (compress) ? 1 : 0); - } - } - - #endregion // ToggleCompressionCore - - - #region Private - - #region CreateDeviceInfoDataInstance - - /// Builds a DeviceInfo Data structure. - /// An initialized NativeMethods.SP_DEVINFO_DATA instance. - [SecurityCritical] - private static NativeMethods.SP_DEVINFO_DATA CreateDeviceInfoDataInstance() - { - var did = new NativeMethods.SP_DEVINFO_DATA(); - did.cbSize = (uint) Marshal.SizeOf(did); - - return did; - } - - #endregion // CreateDeviceInfoDataInstance - - #region CreateDeviceInterfaceDataInstance - - /// Builds a Device Interface Data structure. - /// An initialized NativeMethods.SP_DEVICE_INTERFACE_DATA instance. - [SecurityCritical] - private static NativeMethods.SP_DEVICE_INTERFACE_DATA CreateDeviceInterfaceDataInstance() - { - var did = new NativeMethods.SP_DEVICE_INTERFACE_DATA(); - did.cbSize = (uint) Marshal.SizeOf(did); - - return did; - } - - #endregion // CreateDeviceInterfaceDataInstance - - #region GetDeviceInterfaceDetailDataInstance - - /// Builds a Device Interface Detail Data structure. - /// An initialized NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA instance. - [SecurityCritical] - private static NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA GetDeviceInterfaceDetailDataInstance(SafeHandle safeHandle, NativeMethods.SP_DEVICE_INTERFACE_DATA deviceInterfaceData, NativeMethods.SP_DEVINFO_DATA deviceInfoData) - { - // Build a Device Interface Detail Data structure. - var didd = new NativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA - { - cbSize = (IntPtr.Size == 4) ? (uint) (Marshal.SystemDefaultCharSize + 4) : 8 - }; - - // Get device interace details. - if (!NativeMethods.SetupDiGetDeviceInterfaceDetail(safeHandle, ref deviceInterfaceData, ref didd, NativeMethods.DefaultFileBufferSize, IntPtr.Zero, ref deviceInfoData)) - { - var lastError = Marshal.GetLastWin32Error(); - if (lastError != Win32Errors.NO_ERROR) - NativeError.ThrowException(lastError); - } - - return didd; - } - - #endregion // GetDeviceInterfaceDetailDataInstance - - #region InvokeIoControlUnknownSize - - /// Repeatedly invokes InvokeIoControl with the specified input until enough memory has been allocated. - [SecurityCritical] - private static byte[] InvokeIoControlUnknownSize(SafeFileHandle handle, uint controlCode, TV input, uint increment = 128) - { - byte[] output; - uint bytesReturned; - - var inputSize = (uint) Marshal.SizeOf(input); - var outputLength = increment; - - do - { - output = new byte[outputLength]; - if (!NativeMethods.DeviceIoControl(handle, controlCode, input, inputSize, output, outputLength, out bytesReturned, IntPtr.Zero)) - { - var lastError = Marshal.GetLastWin32Error(); - switch ((uint)lastError) - { - case Win32Errors.ERROR_MORE_DATA: - case Win32Errors.ERROR_INSUFFICIENT_BUFFER: - outputLength += increment; - break; - - default: - NativeError.ThrowException(lastError); - break; - } - } - else - break; - - } while (true); - - // Return the result - if (output.Length == bytesReturned) - return output; - - var res = new byte[bytesReturned]; - Array.Copy(output, res, bytesReturned); - - return res; - } - - #endregion // InvokeIoControlUnknownSize - - #endregion // Private - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs deleted file mode 100644 index 82e0946..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DeviceInfo.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Network; -using System; -using System.Collections.Generic; -using System.Security; -using System.Security.Permissions; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides access to information of a device, on a local or remote host. - [SecurityPermission(SecurityAction.InheritanceDemand, UnmanagedCode = true)] - [SerializableAttribute] - [SecurityCritical] - public sealed class DeviceInfo - { - #region Constructors - - /// Initializes a DeviceInfo class. - [SecurityCritical] - public DeviceInfo() - { - HostName = Host.GetUncName(); - } - - /// Initializes a DeviceInfo class. - /// The DNS or NetBIOS name of the remote server. refers to the local host. - [SecurityCritical] - public DeviceInfo(string host) - { - HostName = Host.GetUncName(host).Replace(Path.UncPrefix, string.Empty); - } - - #endregion // Constructors - - - #region Methods - - /// Enumerates all available devices on the local host. - /// One of the devices. - /// instances of type from the local host. - [SecurityCritical] - public IEnumerable EnumerateDevices(DeviceGuid deviceGuid) - { - return Device.EnumerateDevicesCore(null, HostName, deviceGuid); - } - - #endregion // Methods - - - #region Properties - - /// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode). - public Guid BaseContainerId { get; internal set; } - - - /// Represents the name of the device setup class that a device instance belongs to. - public string Class { get; internal set; } - - - /// Represents the of the device setup class that a device instance belongs to. - public Guid ClassGuid { get; internal set; } - - - /// Represents the list of compatible identifiers for a device instance. - public string CompatibleIds { get; internal set; } - - - /// Represents a description of a device instance. - public string DeviceDescription { get; internal set; } - - - /// The device interface path. - public string DevicePath { get; internal set; } - - - /// Represents the registry entry name of the driver key for a device instance. - public string Driver { get; internal set; } - - - /// Represents the name of the enumerator for a device instance. - public string EnumeratorName { get; internal set; } - - - /// Represents the friendly name of a device instance. - public string FriendlyName { get; internal set; } - - - /// Represents the list of hardware identifiers for a device instance. - public string HardwareId { get; internal set; } - - - /// The host name that was passed to the class constructor. - public string HostName { get; internal set; } - - - /// Gets the instance Id of the device. - public string InstanceId { get; internal set; } - - - /// Represents the bus-specific physical location of a device instance. - public string LocationInformation { get; internal set; } - - - /// Represents the location of a device instance in the device tree. - public string LocationPaths { get; internal set; } - - - /// Represents the name of the manufacturer of a device instance. - public string Manufacturer { get; internal set; } - - - /// Encapsulates the physical device location information provided by a device's firmware to Windows. - public string PhysicalDeviceObjectName { get; internal set; } - - - /// Represents the name of the service that is installed for a device instance. - public string Service { get; internal set; } - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs deleted file mode 100644 index 13fb15f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs +++ /dev/null @@ -1,484 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region Compress - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// This will only compress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to compress. - [SecurityCritical] - public static void Compress(string path) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// This will only compress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Compress(string path, PathFormat pathFormat) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, pathFormat); - } - - - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to compress. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static void Compress(string path, DirectoryEnumerationOptions options) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to compress. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Compress(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, true, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// This will only compress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to compress. - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// This will only compress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, pathFormat); - } - - - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to compress. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to compress. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, true, pathFormat); - } - - #endregion // Transactional - - #endregion // Compress - - #region Decompress - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// This will only decompress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decompress. - [SecurityCritical] - public static void Decompress(string path) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// This will only decompress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decompress(string path, PathFormat pathFormat) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, pathFormat); - } - - - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decompress. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static void Decompress(string path, DirectoryEnumerationOptions options) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decompress. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decompress(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - CompressDecompressCore(null, path, Path.WildcardStarMatchAll, options, false, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// This will only decompress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to decompress. - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// This will only decompress the root items (non recursive). - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, pathFormat); - } - - - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to decompress. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to decompress. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - CompressDecompressCore(transaction, path, Path.WildcardStarMatchAll, options, false, pathFormat); - } - - #endregion // Transactional - - #endregion // Decompress - - #region DisableCompression - - /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it. - /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed. - /// - /// - /// - /// - /// - /// - /// A path to a directory to decompress. - [SecurityCritical] - public static void DisableCompression(string path) - { - Device.ToggleCompressionCore(true, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it. - /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed. - /// - /// - /// - /// - /// - /// - /// A path to a directory to decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DisableCompression(string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(true, null, path, false, pathFormat); - } - - - - /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it. - /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path to a directory to decompress. - [SecurityCritical] - public static void DisableCompressionTransacted(KernelTransaction transaction, string path) - { - Device.ToggleCompressionCore(true, transaction, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Disables NTFS compression of the specified directory and the files in it. - /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. However, newly created files and directories will be uncompressed. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// Indicates the format of the path parameter(s). - /// A path to a directory to decompress. - [SecurityCritical] - public static void DisableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(true, transaction, path, false, pathFormat); - } - - #endregion // DisableCompression - - #region EnableCompression - - /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it. - /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed. - /// - /// - /// - /// - /// - /// - /// A path to a directory to compress. - [SecurityCritical] - public static void EnableCompression(string path) - { - Device.ToggleCompressionCore(true, null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it. - /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed. - /// - /// - /// - /// - /// - /// - /// A path to a directory to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void EnableCompression(string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(true, null, path, true, pathFormat); - } - - - - /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it. - /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path to a directory to compress. - [SecurityCritical] - public static void EnableCompressionTransacted(KernelTransaction transaction, string path) - { - Device.ToggleCompressionCore(true, transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Enables NTFS compression of the specified directory and the files in it. - /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. However, newly created files and directories will be compressed. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path to a directory to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void EnableCompressionTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(true, transaction, path, true, pathFormat); - } - - #endregion // EnableCompression - - #region Internal Methods - - /// Compress/decompress Non-/Transacted files/directories. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// A path that describes a directory to compress. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// compress, when decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void CompressDecompressCore(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, bool compress, PathFormat pathFormat) - { - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - // Process directories and files. - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, pathLp, searchPattern, options | DirectoryEnumerationOptions.AsLongPath, PathFormat.LongFullPath)) - Device.ToggleCompressionCore(true, transaction, fsei, compress, PathFormat.LongFullPath); - - // Compress the root directory, the given path. - Device.ToggleCompressionCore(true, transaction, pathLp, compress, PathFormat.LongFullPath); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs deleted file mode 100644 index a0622ed..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs +++ /dev/null @@ -1,978 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region Copy - - // .NET: Directory class does not contain the Copy() method. - // Mimic .NET File.Copy() methods. - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath) - { - return CopyMoveCore(null, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, . - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, bool overwrite) - { - return CopyMoveCore(null, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, bool overwrite, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is not allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, . - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, bool overwrite) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing directory to a new directory. Overwriting a directory of the same name is allowed. - /// - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// if the destination directory should ignoring the read-only and hidden attributes and overwrite; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, bool overwrite, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Copy - - - #region Copy (CopyOptions) - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions) - { - return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Copy(string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult CopyTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Copy (CopyOptions) - - - #region Move - - #region .NET - - /// Moves a file or a directory and its contents to a new location. - /// - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Moves a file or a directory and its contents to a new location. - /// - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, pathFormat); - } - - - - #region Transactional - - /// [AlphaFS] Moves a file or a directory and its contents to a new location. - /// - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a file or a directory and its contents to a new location. - /// - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, MoveOptions.None, null, null, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Move - - - #region Move (MoveOptions) - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult Move(string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - return CopyMoveCore(null, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a file or a directory and its contents to a new location, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// A class with the status of the Move action. - /// - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static CopyMoveResult MoveTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - return CopyMoveCore(transaction, sourcePath, destinationPath, null, moveOptions, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Move (MoveOptions) - - - #region Internal Methods - - /// Copy/move a Non-/Transacted file or directory including its children to a new location, - /// or can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// You cannot use the Move method to overwrite an existing file, unless contains . - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an IOException. - /// - /// - /// A class with the status of the Copy or Move action. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied/moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SecurityCritical] - internal static CopyMoveResult CopyMoveCore(KernelTransaction transaction, string sourcePath, string destinationPath, CopyOptions? copyOptions, MoveOptions? moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat) - { - #region Setup - - var sourcePathLp = sourcePath; - var destinationPathLp = destinationPath; - var emulateMove = false; - - // Determine Copy or Move action. - var isCopy = File.DetermineIsCopy(copyOptions, moveOptions); - var isMove = !isCopy; - - var cmr = copyMoveResult ?? new CopyMoveResult(sourcePath, destinationPath, false, (int) Win32Errors.ERROR_SUCCESS); - - - if (pathFormat != PathFormat.LongFullPath) - { - Path.CheckSupportedPathFormat(sourcePathLp, true, true); - Path.CheckSupportedPathFormat(destinationPathLp, true, true); - - - // MSDN: .NET 4+ Trailing spaces are removed from the end of the path parameters before moving the directory. - // TrimEnd() is also applied for AlphaFS implementation of method Directory.Copy(), .NET does not have this method. - - const GetFullPathOptions fullPathOptions = GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator; - - sourcePathLp = Path.GetExtendedLengthPathCore(transaction, sourcePath, pathFormat, fullPathOptions); - destinationPathLp = Path.GetExtendedLengthPathCore(transaction, destinationPath, pathFormat, fullPathOptions); - - - // MSDN: .NET3.5+: IOException: The sourceDirName and destDirName parameters refer to the same file or directory. - if (sourcePathLp.Equals(destinationPathLp, StringComparison.OrdinalIgnoreCase)) - NativeError.ThrowException(Win32Errors.ERROR_SAME_DRIVE, destinationPathLp); - - - // Execute once only. - if (isMove) - { - // Compare the root part of both paths. - var equalRootPaths = Path.GetPathRoot(sourcePathLp, false).Equals(Path.GetPathRoot(destinationPathLp, false), StringComparison.OrdinalIgnoreCase); - - // Method Volume.IsSameVolume() returns true when both paths refer to the same volume, even if one of the paths is a UNC path. - // For example, src = C:\TempSrc and dst = \\localhost\C$\TempDst - var isSameVolume = equalRootPaths || Volume.IsSameVolume(sourcePathLp, destinationPathLp); - - isMove = isSameVolume && equalRootPaths; - - - if (!isMove) - { - // A Move() can be emulated by using Copy() and Delete(), but only if the CopyAllowed flag is set. - isMove = ((MoveOptions) moveOptions & MoveOptions.CopyAllowed) != 0; - - // MSDN: .NET3.5+: IOException: An attempt was made to move a directory to a different volume. - if (!isMove) - NativeError.ThrowException(Win32Errors.ERROR_NOT_SAME_DEVICE, sourcePathLp, destinationPathLp); - } - - - // The NativeMethod.MoveFileXxx() methods fail when: - // - A directory is being moved; - // - One of the paths is a UNC path, even though both paths refer to the same volume. - // For example, src = C:\TempSrc and dst = \\localhost\C$\TempDst - if (isMove) - { - var srcIsUncPath = Path.IsUncPathCore(sourcePathLp, false, false); - var dstIsUncPath = Path.IsUncPathCore(destinationPathLp, false, false); - - isMove = srcIsUncPath && dstIsUncPath; - if (!isMove) - isMove = !srcIsUncPath && !dstIsUncPath; - } - - - isMove = isMove && isSameVolume && equalRootPaths; - - - // Emulate Move(). - if (!isMove) - { - emulateMove = true; - - moveOptions = null; - - isCopy = true; - copyOptions = CopyOptions.FailIfExists; - } - } - } - - #endregion // Setup - - - #region Copy - - if (isCopy) - { - CreateDirectoryCore(transaction, destinationPathLp, null, null, false, PathFormat.LongFullPath); - - var dirs = new Queue(1000); - dirs.Enqueue(sourcePathLp); - - while (dirs.Count > 0) - { - var srcLp = dirs.Dequeue(); - var dstLp = srcLp.Replace(sourcePathLp, destinationPathLp); - - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, srcLp, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath)) - { - var newDestinationPathLp = Path.CombineCore(false, dstLp, fsei.FileName); - - if (fsei.IsDirectory) - { - CreateDirectoryCore(transaction, newDestinationPathLp, null, null, false, PathFormat.LongFullPath); - - dirs.Enqueue(fsei.LongFullPath); - cmr.TotalFolders++; - - continue; - } - - - cmr = File.CopyMoveCore(false, transaction, fsei.LongFullPath, newDestinationPathLp, false, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath); - - if (cmr.ErrorCode == Win32Errors.ERROR_SUCCESS) - { - cmr.TotalFiles++; - cmr.TotalBytes += fsei.FileSize; - - // Remove the folder or file when copying was successful. - if (emulateMove) - { - if (fsei.IsDirectory) - DeleteDirectoryCore(fsei, transaction, null, true, true, true, PathFormat.LongFullPath); - - else - File.DeleteFileCore(transaction, fsei.LongFullPath, true, PathFormat.LongFullPath); - } - } - - - if (cmr.IsCanceled) - return cmr; - } - } - - // Remove source folder. - if (emulateMove && cmr.ErrorCode == Win32Errors.ERROR_SUCCESS) - DeleteDirectoryCore(null, transaction, sourcePathLp, true, true, true, PathFormat.LongFullPath); - } - - #endregion // Copy - - - #region Move - - else - { - // MoveOptions.ReplaceExisting: This value cannot be used if lpNewFileName or lpExistingFileName names a directory. - if (((MoveOptions) moveOptions & MoveOptions.ReplaceExisting) != 0) - DeleteDirectoryCore(null, transaction, destinationPathLp, true, true, true, PathFormat.LongFullPath); - - - // Moves a file or directory, including its children. - // Copies an existing directory, including its children to a new directory. - cmr = File.CopyMoveCore(true, transaction, sourcePathLp, destinationPathLp, false, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath); - } - - #endregion // Move - - - return isMove ? null : cmr; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs deleted file mode 100644 index 9bbb8af..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs +++ /dev/null @@ -1,195 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The directory path. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static long CountFileSystemObjects(string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath).Count(); - } - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The directory path. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static long CountFileSystemObjects(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat).Count(); - } - - - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The directory path. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static long CountFileSystemObjects(string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).Count(); - } - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The directory path. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static long CountFileSystemObjects(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat).Count(); - } - - #region Transactional - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory path. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath).Count(); - } - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory path. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat).Count(); - } - - - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory path. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).Count(); - } - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory path. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static long CountFileSystemObjectsTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat).Count(); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs deleted file mode 100644 index 4637e2c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs +++ /dev/null @@ -1,800 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Creates all directories and subdirectories in the specified path unless they already exist. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path) - { - return CreateDirectoryCore(null, path, null, null, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, null, null, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, bool compress) - { - return CreateDirectoryCore(null, path, null, null, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, null, null, compress, pathFormat); - } - - - - /// Creates all the directories in the specified path, unless the already exist, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The access control to apply to the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity) - { - return CreateDirectoryCore(null, path, null, directorySecurity, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The access control to apply to the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, null, directorySecurity, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The access control to apply to the directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, bool compress) - { - return CreateDirectoryCore(null, path, null, directorySecurity, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The access control to apply to the directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, null, directorySecurity, compress, pathFormat); - } - - - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath) - { - return CreateDirectoryCore(null, path, templatePath, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, templatePath, null, false, pathFormat); - } - - - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, bool compress) - { - return CreateDirectoryCore(null, path, templatePath, null, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, templatePath, null, compress, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity) - { - return CreateDirectoryCore(null, path, templatePath, directorySecurity, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, templatePath, directorySecurity, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, bool compress) - { - return CreateDirectoryCore(null, path, templatePath, directorySecurity, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectory(string path, string templatePath, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(null, path, templatePath, directorySecurity, compress, pathFormat); - } - - #region Transactional - - /// Creates all directories and subdirectories in the specified path unless they already exist. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path) - { - return CreateDirectoryCore(transaction, path, null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, null, null, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, bool compress) - { - return CreateDirectoryCore(transaction, path, null, null, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, null, null, compress, pathFormat); - } - - - - /// Creates all the directories in the specified path, unless the already exist, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The access control to apply to the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity) - { - return CreateDirectoryCore(transaction, path, null, directorySecurity, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The access control to apply to the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, null, directorySecurity, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The access control to apply to the directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, bool compress) - { - return CreateDirectoryCore(transaction, path, null, directorySecurity, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path, applying the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The access control to apply to the directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, null, directorySecurity, compress, pathFormat); - } - - - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath) - { - return CreateDirectoryCore(transaction, path, templatePath, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, templatePath, null, false, pathFormat); - } - - - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, bool compress) - { - return CreateDirectoryCore(transaction, path, templatePath, null, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new directory, with the attributes of a specified template directory. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, templatePath, null, compress, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity) - { - return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, false, pathFormat); - } - - - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// When compresses the directory. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, bool compress) - { - return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, compress, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates all the directories in the specified path of a specified template directory and applies the specified Windows security. - /// An object that represents the directory at the specified path. This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. - /// The access control to apply to the directory. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static DirectoryInfo CreateDirectoryTransacted(KernelTransaction transaction, string path, string templatePath, DirectorySecurity directorySecurity, bool compress, PathFormat pathFormat) - { - return CreateDirectoryCore(transaction, path, templatePath, directorySecurity, compress, pathFormat); - } - - #endregion // Transactional - - #region Internal Methods - - /// Creates a new directory with the attributes of a specified template directory (if one is specified). - /// If the underlying file system supports security on files and directories, the function applies the specified security descriptor to the new directory. - /// The new directory retains the other attributes of the specified template directory. - /// - /// - /// Returns an object that represents the directory at the specified path. - /// This object is returned regardless of whether a directory at the specified path already exists. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to create. - /// The path of the directory to use as a template when creating the new directory. May be to indicate that no template should be used. - /// The access control to apply to the directory, may be null. - /// When compresses the directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SecurityCritical] - internal static DirectoryInfo CreateDirectoryCore(KernelTransaction transaction, string path, string templatePath, ObjectSecurity directorySecurity, bool compress, PathFormat pathFormat) - { - bool fullCheck = pathFormat == PathFormat.RelativePath; - - Path.CheckSupportedPathFormat(path, fullCheck, fullCheck); - Path.CheckSupportedPathFormat(templatePath, fullCheck, fullCheck); - - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); - - // Return DirectoryInfo instance if the directory specified by path already exists. - if (File.ExistsCore(true, transaction, pathLp, PathFormat.LongFullPath)) - return new DirectoryInfo(transaction, pathLp, PathFormat.LongFullPath); - - // MSDN: .NET 3.5+: IOException: The directory specified by path is a file or the network name was not found. - if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath)) - NativeError.ThrowException(Win32Errors.ERROR_ALREADY_EXISTS, pathLp); - - - string templatePathLp = Utils.IsNullOrWhiteSpace(templatePath) - ? null - : Path.GetExtendedLengthPathCore(transaction, templatePath, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); - - - #region Construct Full Path - - string longPathPrefix = Path.IsUncPathCore(path, false, false) ? Path.LongPathUncPrefix : Path.LongPathPrefix; - path = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false); - - int length = path.Length; - if (length >= 2 && Path.IsDVsc(path[length - 1], false)) - --length; - - int rootLength = Path.GetRootLength(path, false); - if (length == 2 && Path.IsDVsc(path[1], false)) - throw new ArgumentException(Resources.Cannot_Create_Directory, path); - - - // Check if directories are missing. - var list = new Stack(100); - - if (length > rootLength) - { - for (int index = length - 1; index >= rootLength; --index) - { - string path1 = path.Substring(0, index + 1); - string path2 = longPathPrefix + path1.TrimStart('\\'); - - if (!File.ExistsCore(true, transaction, path2, PathFormat.LongFullPath)) - list.Push(path2); - - while (index > rootLength && !Path.IsDVsc(path[index], false)) - --index; - } - } - - #endregion // Construct Full Path - - - // Directory security. - using (var securityAttributes = new Security.NativeMethods.SecurityAttributes(directorySecurity)) - { - // Create the directory paths. - while (list.Count > 0) - { - string folderLp = list.Pop(); - - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - if (!(transaction == null || !NativeMethods.IsAtLeastWindowsVista - ? (templatePathLp == null - ? NativeMethods.CreateDirectory(folderLp, securityAttributes) - : NativeMethods.CreateDirectoryEx(templatePathLp, folderLp, securityAttributes)) - : NativeMethods.CreateDirectoryTransacted(templatePathLp, folderLp, securityAttributes, transaction.SafeHandle))) - { - int lastError = Marshal.GetLastWin32Error(); - - switch ((uint) lastError) - { - // MSDN: .NET 3.5+: If the directory already exists, this method does nothing. - // MSDN: .NET 3.5+: IOException: The directory specified by path is a file. - case Win32Errors.ERROR_ALREADY_EXISTS: - if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath)) - NativeError.ThrowException(lastError, pathLp); - - if (File.ExistsCore(false, transaction, folderLp, PathFormat.LongFullPath)) - NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, folderLp); - break; - - case Win32Errors.ERROR_BAD_NET_NAME: - NativeError.ThrowException(lastError, pathLp); - break; - - case Win32Errors.ERROR_DIRECTORY: - // MSDN: .NET 3.5+: NotSupportedException: path contains a colon character (:) that is not part of a drive label ("C:\"). - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Unsupported_Path_Format, path)); - - default: - NativeError.ThrowException(lastError, folderLp); - break; - } - } - - else if (compress) - Device.ToggleCompressionCore(true, transaction, folderLp, true, PathFormat.LongFullPath); - } - - return new DirectoryInfo(transaction, pathLp, PathFormat.LongFullPath); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs deleted file mode 100644 index df427f3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs +++ /dev/null @@ -1,126 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// - /// Gets the current working directory of the application. - /// - /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names. - /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// The path of the current working directory without a trailing directory separator. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate"), SecurityCritical] - public static string GetCurrentDirectory() - { - var nameBuffer = new StringBuilder(NativeMethods.MaxPathUnicode); - - // SetCurrentDirectory() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2016-09-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - var folderNameLength = NativeMethods.GetCurrentDirectory((uint) nameBuffer.Capacity, nameBuffer); - var lastError = Marshal.GetLastWin32Error(); - - if (folderNameLength == 0) - NativeError.ThrowException(lastError); - - if (folderNameLength > NativeMethods.MaxPathUnicode) - throw new PathTooLongException(string.Format(CultureInfo.InvariantCulture, "Path is greater than {0} characters: {1}", NativeMethods.MaxPathUnicode, folderNameLength)); - - return nameBuffer.ToString(); - } - - - /// - /// Sets the application's current working directory to the specified directory. - /// - /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names. - /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// The path to which the current working directory is set. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public static void SetCurrentDirectory(string path) - { - SetCurrentDirectory(path, PathFormat.RelativePath); - } - - - /// - /// Sets the application's current working directory to the specified directory. - /// - /// MSDN: Multithreaded applications and shared library code should not use the GetCurrentDirectory function and should avoid using relative path names. - /// The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// The path to which the current working directory is set. - /// Indicates the format of the path parameter. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public static void SetCurrentDirectory(string path, PathFormat pathFormat) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - var fullCheck = pathFormat == PathFormat.RelativePath; - Path.CheckSupportedPathFormat(path, fullCheck, fullCheck); - var pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.AddTrailingDirectorySeparator); - - if (pathFormat == PathFormat.FullPath) - pathLp = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false); - - - // SetCurrentDirectory() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2016-09-29: MSDN confirms LongPath usage starting with Windows 10, version 1607. - - if (!NativeMethods.SetCurrentDirectory(pathLp)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs deleted file mode 100644 index de87b48..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs +++ /dev/null @@ -1,422 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Deletes an empty directory from a specified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the empty directory to remove. This directory must be writable and empty. - [SecurityCritical] - public static void Delete(string path) - { - DeleteDirectoryCore(null, null, path, false, false, false, PathFormat.RelativePath); - } - - /// Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - [SecurityCritical] - public static void Delete(string path, bool recursive) - { - DeleteDirectoryCore(null, null, path, recursive, false, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Deletes an empty directory from a specified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the empty directory to remove. This directory must be writable and empty. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Delete(string path, PathFormat pathFormat) - { - DeleteDirectoryCore(null, null, path, false, false, false, pathFormat); - } - - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Delete(string path, bool recursive, PathFormat pathFormat) - { - DeleteDirectoryCore(null, null, path, recursive, false, false, pathFormat); - } - - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// overrides read only of files and directories. - [SecurityCritical] - public static void Delete(string path, bool recursive, bool ignoreReadOnly) - { - DeleteDirectoryCore(null, null, path, recursive, ignoreReadOnly, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// overrides read only of files and directories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Delete(string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteDirectoryCore(null, null, path, recursive, ignoreReadOnly, false, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Deletes an empty directory from a specified path. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the empty directory to remove. This directory must be writable and empty. - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path) - { - DeleteDirectoryCore(null, transaction, path, false, false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes an empty directory from a specified path. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the empty directory to remove. This directory must be writable and empty. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - DeleteDirectoryCore(null, transaction, path, false, false, false, pathFormat); - } - - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive) - { - DeleteDirectoryCore(null, transaction, path, recursive, false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, PathFormat pathFormat) - { - DeleteDirectoryCore(null, transaction, path, recursive, false, false, pathFormat); - } - - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// overrides read only of files and directories. - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly) - { - DeleteDirectoryCore(null, transaction, path, recursive, ignoreReadOnly, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove. - /// to remove directories, subdirectories, and files in . otherwise. - /// overrides read only of files and directories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteDirectoryCore(null, transaction, path, recursive, ignoreReadOnly, false, pathFormat); - } - - #endregion // Transactional - - - #region Internal Methods - - /// Deletes the specified directory and, if indicated, any subdirectories in the directory. - /// The RemoveDirectory function marks a directory for deletion on close. Therefore, the directory is not removed until the last handle to the directory is closed. - /// - /// - /// - /// - /// - /// - /// - /// A FileSystemEntryInfo instance. Use either or , not both. - /// The transaction. - /// The name of the directory to remove. Use either or , not both. - /// to remove all files and subdirectories recursively; otherwise only the top level empty directory. - /// overrides read only attribute of files and directories. - /// When does not throw an Exception when the directory does not exist. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SecurityCritical] - internal static void DeleteDirectoryCore(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool continueOnNotFound, PathFormat pathFormat) - { - #region Setup - - if (fsEntryInfo == null) - { - // MSDN: .NET 3.5+: DirectoryNotFoundException: - // Path does not exist or could not be found. - // Path refers to a file instead of a directory. - // The specified path is invalid (for example, it is on an unmapped drive). - - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator), continueOnNotFound, pathFormat); - - if (fsEntryInfo == null) - return; - } - - #endregion // Setup - - - // Do not follow mount points nor symbolic links, but do delete the reparse point itself. - // If directory is reparse point, disable recursion. - - if (recursive && !fsEntryInfo.IsReparsePoint) - { - var dirs = new Stack(1000); - - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders | DirectoryEnumerationOptions.Recursive, PathFormat.LongFullPath)) - { - if (fsei.IsDirectory) - { - // Check to see if this is a mount point, and unmount it. - // Now it is safe to delete the actual directory. - if (fsei.IsMountPoint) - Volume.DeleteVolumeMountPointCore(fsei.LongFullPath, false); - - dirs.Push(fsei.LongFullPath); - } - - else - File.DeleteFileCore(transaction, fsei.LongFullPath, ignoreReadOnly, PathFormat.LongFullPath); - } - - - while (dirs.Count > 0) - DeleteDirectoryCore(transaction, dirs.Pop(), ignoreReadOnly, continueOnNotFound); - } - - - // Check to see if this is a mount point, and unmount it. - // Now it is safe to delete the actual directory. - if (fsEntryInfo.IsMountPoint) - Volume.DeleteVolumeMountPointCore(fsEntryInfo.LongFullPath, false); - - DeleteDirectoryCore(transaction, fsEntryInfo.LongFullPath, ignoreReadOnly, continueOnNotFound); - } - - - private static void DeleteDirectoryCore(KernelTransaction transaction, string pathLp, bool ignoreReadOnly, bool continueOnNotFound) - { - startRemoveDirectory: - - var success = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // RemoveDirectory() / RemoveDirectoryTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-09-09: MSDN confirms LongPath usage. - - // RemoveDirectory on a symbolic link will remove the link itself. - - ? NativeMethods.RemoveDirectory(pathLp) - : NativeMethods.RemoveDirectoryTransacted(pathLp, transaction.SafeHandle); - - - var lastError = Marshal.GetLastWin32Error(); - if (!success) - { - switch ((uint) lastError) - { - case Win32Errors.ERROR_DIR_NOT_EMPTY: - // MSDN: .NET 3.5+: IOException: The directory specified by path is not an empty directory. - throw new DirectoryNotEmptyException(pathLp); - - - case Win32Errors.ERROR_DIRECTORY: - // MSDN: .NET 3.5+: DirectoryNotFoundException: Path refers to a file instead of a directory. - if (File.ExistsCore(false, transaction, pathLp, PathFormat.LongFullPath)) - throw new DirectoryNotFoundException(string.Format(CultureInfo.CurrentCulture, "({0}) {1}", Win32Errors.ERROR_INVALID_PARAMETER, string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, pathLp))); - break; - - - case Win32Errors.ERROR_PATH_NOT_FOUND: - if (continueOnNotFound) - return; - break; - - - case Win32Errors.ERROR_SHARING_VIOLATION: - // MSDN: .NET 3.5+: IOException: The directory is being used by another process or there is an open handle on the directory. - NativeError.ThrowException(lastError, pathLp); - break; - - - case Win32Errors.ERROR_ACCESS_DENIED: - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - var dataInitialised = File.FillAttributeInfoCore(transaction, pathLp, ref data, false, true); - - if (data.dwFileAttributes != (FileAttributes) (-1)) - { - if ((data.dwFileAttributes & FileAttributes.ReadOnly) != 0) - { - // MSDN: .NET 3.5+: IOException: The directory specified by path is read-only. - - if (ignoreReadOnly) - { - // Reset directory attributes. - File.SetAttributesCore(true, transaction, pathLp, FileAttributes.Normal, PathFormat.LongFullPath); - goto startRemoveDirectory; - } - - // MSDN: .NET 3.5+: IOException: The directory is read-only. - throw new DirectoryReadOnlyException(pathLp); - } - } - - - // MSDN: .NET 3.5+: UnauthorizedAccessException: The caller does not have the required permission. - if (dataInitialised == Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(lastError, pathLp); - - break; - } - - // MSDN: .NET 3.5+: IOException: - // A file with the same name and location specified by path exists. - // The directory specified by path is read-only, or recursive is false and path is not an empty directory. - // The directory is the application's current working directory. - // The directory contains a read-only file. - // The directory is being used by another process. - - NativeError.ThrowException(lastError, pathLp); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs deleted file mode 100644 index 299c6ec..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs +++ /dev/null @@ -1,333 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove empty subdirectories from. - [SecurityCritical] - public static void DeleteEmptySubdirectories(string path) - { - DeleteEmptySubdirectoriesCore(null, null, path, false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - [SecurityCritical] - public static void DeleteEmptySubdirectories(string path, bool recursive) - { - DeleteEmptySubdirectoriesCore(null, null, path, recursive, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteEmptySubdirectories(string path, bool recursive, PathFormat pathFormat) - { - DeleteEmptySubdirectoriesCore(null, null, path, recursive, false, pathFormat); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - [SecurityCritical] - public static void DeleteEmptySubdirectories(string path, bool recursive, bool ignoreReadOnly) - { - DeleteEmptySubdirectoriesCore(null, null, path, recursive, ignoreReadOnly, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteEmptySubdirectories(string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteEmptySubdirectoriesCore(null, null, path, recursive, ignoreReadOnly, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove empty subdirectories from. - [SecurityCritical] - public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path) - { - DeleteEmptySubdirectoriesCore(null, transaction, path, false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - [SecurityCritical] - public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive) - { - DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, PathFormat pathFormat) - { - DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, false, pathFormat); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - [SecurityCritical] - public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly) - { - DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, ignoreReadOnly, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the directory to remove empty subdirectories from. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DeleteEmptySubdirectoriesTransacted(KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteEmptySubdirectoriesCore(null, transaction, path, recursive, ignoreReadOnly, pathFormat); - } - - #endregion // Transactional - - - #region Internal Methods - - /// [AlphaFS] Delete empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// A FileSystemEntryInfo instance. Use either or , not both. - /// The transaction. - /// The name of the directory to remove empty subdirectories from. Use either or , not both. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - /// When indicates the method is called externally. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void DeleteEmptySubdirectoriesCore0(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool initialize, PathFormat pathFormat) - { - #region Setup - - if (fsEntryInfo == null) - { - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - if (!File.ExistsCore(true, transaction, path, pathFormat)) - NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, path); - - fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck) , false, pathFormat); - - if (fsEntryInfo == null) - return; - } - - #endregion // Setup - - - // Ensure path is a directory. - if (!fsEntryInfo.IsDirectory) - throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, fsEntryInfo.LongFullPath)); - - - var dirEnumOptions = DirectoryEnumerationOptions.Folders | DirectoryEnumerationOptions.SkipReparsePoints; - - if (recursive) - dirEnumOptions |= DirectoryEnumerationOptions.Recursive; - - - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, dirEnumOptions, PathFormat.LongFullPath)) - DeleteEmptySubdirectoriesCore0(fsei, transaction, null, recursive, ignoreReadOnly, false, PathFormat.LongFullPath); - - - if (!EnumerateFileSystemEntryInfosCore(transaction, fsEntryInfo.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).Any()) - { - // Prevent deleting path itself. - if (!initialize) - DeleteDirectoryCore(fsEntryInfo, transaction, null, false, ignoreReadOnly, true, PathFormat.LongFullPath); - } - } - - - /// [AlphaFS] Delete empty subdirectories from the specified directory. - /// - /// - /// - /// - /// - /// - /// - /// A FileSystemEntryInfo instance. Use either or , not both. - /// The transaction. - /// The name of the directory to remove empty subdirectories from. Use either or , not both. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void DeleteEmptySubdirectoriesCore(FileSystemEntryInfo fsEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, PathFormat pathFormat) - { - #region Setup - - if (fsEntryInfo == null) - { - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - if (!File.ExistsCore(true, transaction, path, pathFormat)) - NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, path); - - fsEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck), false, pathFormat); - - if (fsEntryInfo == null) - return; - } - - #endregion // Setup - - - // Ensure path is a directory. - if (!fsEntryInfo.IsDirectory) - throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, fsEntryInfo.LongFullPath)); - - - var dirs = new Stack(1000); - dirs.Push(fsEntryInfo.LongFullPath); - - while (dirs.Count > 0) - { - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, dirs.Pop(), Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders | DirectoryEnumerationOptions.ContinueOnException, PathFormat.LongFullPath)) - { - // Ensure the directory is empty. - if (!EnumerateFileSystemEntryInfosCore(transaction, fsei.LongFullPath, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).Any()) - DeleteDirectoryCore(fsei, transaction, null, false, ignoreReadOnly, true, PathFormat.LongFullPath); - - else if (recursive) - dirs.Push(fsei.LongFullPath); - } - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs deleted file mode 100644 index ee0698e..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs +++ /dev/null @@ -1,154 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region Export - - /// [AlphaFS] Backs up (export) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// The directory being backed up is not decrypted; it is backed up in its encrypted state. - /// If the caller does not have access to the key for the file, the caller needs to export encrypted files. See . - /// To backup an encrypted directory call one of the overloads and specify the directory to backup along with the destination stream of the backup data. - /// This function is intended for the backup of only encrypted directories; see for backup of unencrypted directories. - /// Note that this method does not back up the files inside the directory, only the directory entry itself. - /// - /// - /// - /// - /// The name of the file to be backed up. - /// The destination stream to which the backup data will be written. - public static void ExportEncryptedDirectoryRaw(string fileName, Stream outputStream) - { - File.ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, PathFormat.RelativePath, false); - } - - /// [AlphaFS] Backs up (export) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// The directory being backed up is not decrypted; it is backed up in its encrypted state. - /// If the caller does not have access to the key for the file, the caller needs to export encrypted files. See . - /// To backup an encrypted directory call one of the overloads and specify the directory to backup along with the destination stream of the backup data. - /// This function is intended for the backup of only encrypted directories; see for backup of unencrypted directories. - /// Note that this method does not back up the files inside the directory, only the directory entry itself. - /// - /// - /// - /// - /// The name of the file to be backed up. - /// The destination stream to which the backup data will be written. - /// The path format of the parameter. - public static void ExportEncryptedDirectoryRaw(string fileName, Stream outputStream, PathFormat pathFormat) - { - File.ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, pathFormat, false); - } - - #endregion // Export - - #region Import - - /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See . - /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data. - /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files. - /// - /// - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination directory to restore to. - public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath) - { - File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, PathFormat.RelativePath, false); - } - - /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See . - /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data. - /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files. - /// - /// - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination directory to restore to. - /// The path format of the parameter. - public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, PathFormat pathFormat) - { - File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, pathFormat, false); - } - - - /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See . - /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data. - /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files. - /// - /// - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination directory to restore to. - /// If set to a hidden directory will be overwritten on import. - public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, bool overwriteHidden) - { - File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, PathFormat.RelativePath, overwriteHidden); - } - - /// [AlphaFS] Restores (import) encrypted directories. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the directory, the caller needs to restore encrypted directories. See . - /// To restore an encrypted directory call one of the overloads and specify the file to restore along with the destination stream of the restored data. - /// This function is intended for the restoration of only encrypted directories; see for backup of unencrypted files. - /// - /// - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination directory to restore to. - /// If set to a hidden directory will be overwritten on import. - /// The path format of the parameter. - public static void ImportEncryptedDirectoryRaw(Stream inputStream, string destinationPath, bool overwriteHidden, PathFormat pathFormat) - { - File.ImportExportEncryptedFileDirectoryRawCore(false, true, inputStream, destinationPath, pathFormat, overwriteHidden); - } - - #endregion // Import - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs deleted file mode 100644 index 5b1c780..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs +++ /dev/null @@ -1,272 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region Decrypt - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decrypt. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decrypt(string path, PathFormat pathFormat) - { - EncryptDecryptDirectoryCore(path, false, false, pathFormat); - } - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decrypt. - /// to decrypt the directory recursively. only decrypt the directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decrypt(string path, bool recursive, PathFormat pathFormat) - { - EncryptDecryptDirectoryCore(path, false, recursive, pathFormat); - } - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decrypt. - [SecurityCritical] - public static void Decrypt(string path) - { - EncryptDecryptDirectoryCore(path, false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to decrypt. - /// to decrypt the directory recursively. only decrypt the directory. - [SecurityCritical] - public static void Decrypt(string path, bool recursive) - { - EncryptDecryptDirectoryCore(path, false, recursive, PathFormat.RelativePath); - } - - #endregion // Decrypt - - #region Encrypt - - /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to encrypt. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Encrypt(string path, PathFormat pathFormat) - { - EncryptDecryptDirectoryCore(path, true, false, pathFormat); - } - - /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to encrypt. - /// to encrypt the directory recursively. only encrypt the directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Encrypt(string path, bool recursive, PathFormat pathFormat) - { - EncryptDecryptDirectoryCore(path, true, recursive, pathFormat); - } - - - /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to encrypt. - [SecurityCritical] - public static void Encrypt(string path) - { - EncryptDecryptDirectoryCore(path, true, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to encrypt. - /// to encrypt the directory recursively. only encrypt the directory. - [SecurityCritical] - public static void Encrypt(string path, bool recursive) - { - EncryptDecryptDirectoryCore(path, true, recursive, PathFormat.RelativePath); - } - - #endregion // Encrypt - - #region DisableEncryption - - /// [AlphaFS] Disables encryption of the specified directory and the files in it. - /// This method only creates/modifies the file "Desktop.ini" in the root of and disables encryption by writing: "Disable=1" - /// This method does not affect encryption of files and subdirectories below the indicated directory. - /// - /// The name of the directory for which to disable encryption. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DisableEncryption(string path, PathFormat pathFormat) - { - EnableDisableEncryptionCore(path, false, pathFormat); - } - - /// [AlphaFS] Disables encryption of the specified directory and the files in it. - /// This method only creates/modifies the file "Desktop.ini" in the root of and disables encryption by writing: "Disable=1" - /// This method does not affect encryption of files and subdirectories below the indicated directory. - /// - /// The name of the directory for which to disable encryption. - [SecurityCritical] - public static void DisableEncryption(string path) - { - EnableDisableEncryptionCore(path, false, PathFormat.RelativePath); - } - - #endregion // DisableEncryption - - #region EnableEncryption - - /// [AlphaFS] Enables encryption of the specified directory and the files in it. - /// This method only creates/modifies the file "Desktop.ini" in the root of and enables encryption by writing: "Disable=0" - /// This method does not affect encryption of files and subdirectories below the indicated directory. - /// - /// The name of the directory for which to enable encryption. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void EnableEncryption(string path, PathFormat pathFormat) - { - EnableDisableEncryptionCore(path, true, pathFormat); - } - - /// [AlphaFS] Enables encryption of the specified directory and the files in it. - /// This method only creates/modifies the file "Desktop.ini" in the root of and enables encryption by writing: "Disable=0" - /// This method does not affect encryption of files and subdirectories below the indicated directory. - /// - /// The name of the directory for which to enable encryption. - [SecurityCritical] - public static void EnableEncryption(string path) - { - EnableDisableEncryptionCore(path, true, PathFormat.RelativePath); - } - - #endregion // EnableEncryption - - #region Internal Methods - - /// Enables/disables encryption of the specified directory and the files in it. - /// This method only creates/modifies the file "Desktop.ini" in the root of and enables/disables encryption by writing: "Disable=0" or "Disable=1". - /// This method does not affect encryption of files and subdirectories below the indicated directory. - /// - /// The name of the directory for which to enable encryption. - /// enabled encryption, disables encryption. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void EnableDisableEncryptionCore(string path, bool enable, PathFormat pathFormat) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - // EncryptionDisable() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!NativeMethods.EncryptionDisable(pathLp, !enable)) - NativeError.ThrowException(pathLp); - } - - /// Decrypts/encrypts a directory recursively so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - /// A path that describes a directory to encrypt. - /// encrypt, decrypt. - /// to decrypt the directory recursively. only decrypt files and directories in the root of . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void EncryptDecryptDirectoryCore(string path, bool encrypt, bool recursive, PathFormat pathFormat) - { - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - var options = DirectoryEnumerationOptions.FilesAndFolders | DirectoryEnumerationOptions.AsLongPath; - - // Process folders and files when recursive. - if (recursive) - { - options |= DirectoryEnumerationOptions.Recursive; - - foreach (string fsei in EnumerateFileSystemEntryInfosCore(null, pathLp, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath)) - File.EncryptDecryptFileCore(true, fsei, encrypt, PathFormat.LongFullPath); - } - - // Process the root folder, the given path. - File.EncryptDecryptFileCore(true, pathLp, encrypt, PathFormat.LongFullPath); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs deleted file mode 100644 index 8ddcf9d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. - /// The path to the directory to enumerate streams of. - /// The streams of type :$DATA in the specified directory. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreams(string path) - { - return File.EnumerateAlternateDataStreamsCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. - /// The path to the directory to enumerate streams of. - /// Indicates the format of the path parameter(s). - /// The streams of type :$DATA in the specified directory. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreams(string path, PathFormat pathFormat) - { - return File.EnumerateAlternateDataStreamsCore(null, path, pathFormat); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. - /// The transaction. - /// The path to the directory to enumerate streams of. - /// The streams of type :$DATA in the specified directory. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path) - { - return File.EnumerateAlternateDataStreamsCore(transaction, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified directory. - /// The transaction. - /// The path to the directory to enumerate streams of. - /// Indicates the format of the path parameter(s). - /// The streams of type :$DATA in the specified directory. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.EnumerateAlternateDataStreamsCore(transaction, path, pathFormat); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs deleted file mode 100644 index d666b10..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs +++ /dev/null @@ -1,500 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath); - } - - /// Returns an enumerable collection of directory names that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath); - } - - /// Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; // Remove enumeration of files. - options |= DirectoryEnumerationOptions.Folders; // Add enumeration of directories. - - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory names in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectories(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - #region Transactional - - /// [AlphaFS] Returns an enumerable collection of directory instances in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory instances in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory instances in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory instances in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of directory instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the directories in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs deleted file mode 100644 index 68f63aa..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Retrieves information about files in the directory specified by in mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// A path to a directory from which to retrieve information. - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path) - { - return EnumerateFileIdBothDirectoryInfoCore(null, null, path, FileShare.ReadWrite, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves information about files in the directory specified by in mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// A path to a directory from which to retrieve information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, PathFormat pathFormat) - { - return EnumerateFileIdBothDirectoryInfoCore(null, null, path, FileShare.ReadWrite, false, pathFormat); - } - - - - /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// A path to a directory from which to retrieve information. - /// The mode with which to open a handle to the directory. - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, FileShare shareMode) - { - return EnumerateFileIdBothDirectoryInfoCore(null, null, path, shareMode, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// A path to a directory from which to retrieve information. - /// The mode with which to open a handle to the directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfo(string path, FileShare shareMode, PathFormat pathFormat) - { - return EnumerateFileIdBothDirectoryInfoCore(null, null, path, shareMode, false, pathFormat); - } - - - - /// [AlphaFS] Retrieves information about files in the directory handle specified. - /// An IEnumerable of records for each file system entry in the specified diretory. - /// An open handle to the directory from which to retrieve information. - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfo(SafeFileHandle handle) - { - // FileShare has no effect since a handle is already opened. - return EnumerateFileIdBothDirectoryInfoCore(null, handle, null, FileShare.ReadWrite, false, PathFormat.RelativePath); - } - - #region Transactional - - /// [AlphaFS] Retrieves information about files in the directory specified by in mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// The transaction. - /// A path to a directory from which to retrieve information. - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, FileShare.ReadWrite, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves information about files in the directory specified by in mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// The transaction. - /// A path to a directory from which to retrieve information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, FileShare.ReadWrite, false, pathFormat); - } - - - - /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// The transaction. - /// A path to a directory from which to retrieve information. - /// The mode with which to open a handle to the directory. - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, FileShare shareMode) - { - return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, shareMode, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves information about files in the directory specified by in specified mode. - /// An enumeration of records for each file system entry in the specified diretory. - /// The transaction. - /// A path to a directory from which to retrieve information. - /// The mode with which to open a handle to the directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileIdBothDirectoryInfoTransacted(KernelTransaction transaction, string path, FileShare shareMode, PathFormat pathFormat) - { - return EnumerateFileIdBothDirectoryInfoCore(transaction, null, path, shareMode, false, pathFormat); - } - - #endregion // Transactional - - #region Internal Methods - - /// Returns an enumerable collection of information about files in the directory handle specified. - /// An IEnumerable of records for each file system entry in the specified diretory. - /// - /// Either use or , not both. - /// - /// The number of files that are returned for each call to GetFileInformationByHandleEx depends on the size of the buffer that is passed to the function. - /// Any subsequent calls to GetFileInformationByHandleEx on the same handle will resume the enumeration operation after the last file is returned. - /// - /// - /// The transaction. - /// An open handle to the directory from which to retrieve information. - /// A path to the directory. - /// The mode with which to open a handle to the directory. - /// suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or non-accessible reparse points. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static IEnumerable EnumerateFileIdBothDirectoryInfoCore(KernelTransaction transaction, SafeFileHandle safeHandle, string path, FileShare shareMode, bool continueOnException, PathFormat pathFormat) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - bool callerHandle = safeHandle != null; - if (!callerHandle) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - safeHandle = File.CreateFileCore(transaction, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.ReadData, shareMode, true, PathFormat.LongFullPath); - } - - - try - { - if (!NativeMethods.IsValidHandle(safeHandle, Marshal.GetLastWin32Error(), !continueOnException)) - yield break; - - var fileNameOffset = (int)Marshal.OffsetOf(typeof(NativeMethods.FILE_ID_BOTH_DIR_INFO), "FileName"); - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(NativeMethods.DefaultFileBufferSize)) - { - while (true) - { - if (!NativeMethods.GetFileInformationByHandleEx(safeHandle, NativeMethods.FileInfoByHandleClass.FileIdBothDirectoryInfo, safeBuffer, (uint)safeBuffer.Capacity)) - { - uint lastError = (uint)Marshal.GetLastWin32Error(); - switch (lastError) - { - case Win32Errors.ERROR_SUCCESS: - case Win32Errors.ERROR_NO_MORE_FILES: - case Win32Errors.ERROR_HANDLE_EOF: - yield break; - - case Win32Errors.ERROR_MORE_DATA: - continue; - - default: - NativeError.ThrowException(lastError, path); - yield break; // we should never get to this yield break. - } - } - - int offset = 0; - NativeMethods.FILE_ID_BOTH_DIR_INFO fibdi; - do - { - fibdi = safeBuffer.PtrToStructure(offset); - string fileName = safeBuffer.PtrToStringUni(offset + fileNameOffset, (int)(fibdi.FileNameLength / 2)); - - if (!fileName.Equals(Path.CurrentDirectoryPrefix, StringComparison.OrdinalIgnoreCase) && - !fileName.Equals(Path.ParentDirectoryPrefix, StringComparison.OrdinalIgnoreCase)) - yield return new FileIdBothDirectoryInfo(fibdi, fileName); - - offset += fibdi.NextEntryOffset; - } - while (fibdi.NextEntryOffset != 0); - } - } - } - finally - { - // Handle is ours, dispose. - if (!callerHandle && safeHandle != null) - safeHandle.Close(); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs deleted file mode 100644 index f346b00..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs +++ /dev/null @@ -1,472 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - - - /// Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of file system entries in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of file system entries in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntries(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - #region Transactional - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of file system entries in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of file system entries in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names in a specified . - /// An enumerable collection of file system entries in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names and directory names that match a in a specified . - /// An enumerable collection of file system entries in the directory specified by and that match the specified . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs deleted file mode 100644 index 890d394..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs +++ /dev/null @@ -1,670 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using . - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using . - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfos(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path. - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using . - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file system entries that match a in a specified path using . - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public static IEnumerable EnumerateFileSystemEntryInfosTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - #endregion // Transactional - - #region Internal Methods - - /// Returns an enumerable collection of file system entries in a specified path using . - /// The matching file system entries. The type of the items is determined by the type . - /// - /// - /// - /// - /// - /// - /// The type to return. This may be one of the following types: - /// - /// - /// - /// This method will return instances of instances. - /// - /// - /// - /// This method will return instances of and instances. - /// - /// - /// - /// This method will return the full path of each item. - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static IEnumerable EnumerateFileSystemEntryInfosCore(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Enable BasicSearch and LargeCache by default. - options |= DirectoryEnumerationOptions.BasicSearch | DirectoryEnumerationOptions.LargeCache; - - return new FindFileSystemEntryInfo(true, transaction, path, searchPattern, options, typeof(T), pathFormat).Enumerate(); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs deleted file mode 100644 index f4ee086..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs +++ /dev/null @@ -1,502 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath); - } - - /// Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath); - } - - /// Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of file names that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; // Remove enumeration of directories. - options |= DirectoryEnumerationOptions.Files; // Add enumeration of files. - - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFiles(string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, pathFormat); - } - - - - #region Transactional - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath); - } - - - - /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file instances instances that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, PathFormat pathFormat) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Files, pathFormat); - } - - /// [AlphaFS] Returns an enumerable collection of file instances instances that match a in a specified , and optionally searches subdirectories. - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the specified and . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption, PathFormat pathFormat) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file names in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, options, pathFormat); - } - - - - /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Returns an enumerable collection of file instances that match a in a specified . - /// An enumerable collection of the full names (including paths) for the files in the directory specified by and that match the . - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static IEnumerable EnumerateFilesTransacted(KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs deleted file mode 100644 index c0639b0..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Determines whether the given path refers to an existing directory on disk. - /// - /// Returns if refers to an existing directory. - /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists. - /// - /// - /// The Exists method returns if any error occurs while trying to determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// - /// The path to test. - [SecurityCritical] - public static bool Exists(string path) - { - return File.ExistsCore(true, null, path, PathFormat.RelativePath); - } - - #endregion // .NET - - - - /// [AlphaFS] Determines whether the given path refers to an existing directory on disk. - /// - /// Returns if refers to an existing directory. - /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists. - /// - /// - /// The Exists method returns if any error occurs while trying to determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// - /// The path to test. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static bool Exists(string path, PathFormat pathFormat) - { - return File.ExistsCore(true, null, path, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Determines whether the given path refers to an existing directory on disk. - /// - /// Returns if refers to an existing directory. - /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists. - /// - /// - /// The Exists method returns if any error occurs while trying to determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// - /// The transaction. - /// The path to test. - [SecurityCritical] - public static bool ExistsTransacted(KernelTransaction transaction, string path) - { - return File.ExistsCore(true, transaction, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Determines whether the given path refers to an existing directory on disk. - /// - /// Returns if refers to an existing directory. - /// Returns if the directory does not exist or an error occurs when trying to determine if the specified file exists. - /// - /// - /// The Exists method returns if any error occurs while trying to determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// - /// The transaction. - /// The path to test. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static bool ExistsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.ExistsCore(true, transaction, path, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs deleted file mode 100644 index 9d90e02..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// Gets a object that encapsulates the access control list (ACL) entries for the specified directory. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a directory containing a object that describes the file's access control list (ACL) information. - [SecurityCritical] - public static DirectorySecurity GetAccessControl(string path) - { - return File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.RelativePath); - } - - /// Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory. - /// A object that encapsulates the access control rules for the directory described by the parameter. - /// - /// - /// - /// The path to a directory containing a object that describes the directory's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - [SecurityCritical] - public static DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections) - { - return File.GetAccessControlCore(true, path, includeSections, PathFormat.RelativePath); - } - - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a directory containing a object that describes the file's access control list (ACL) information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DirectorySecurity GetAccessControl(string path, PathFormat pathFormat) - { - return File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, pathFormat); - } - - /// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory. - /// A object that encapsulates the access control rules for the directory described by the parameter. - /// - /// - /// - /// The path to a directory containing a object that describes the directory's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DirectorySecurity GetAccessControl(string path, AccessControlSections includeSections, PathFormat pathFormat) - { - return File.GetAccessControlCore(true, path, includeSections, pathFormat); - } - - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for the specified directory handle. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// A to a directory containing a object that describes the directory's access control list (ACL) information. - [SecurityCritical] - public static DirectorySecurity GetAccessControl(SafeFileHandle handle) - { - return File.GetAccessControlHandleCore(false, true, handle, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, SecurityInformation.None); - } - - /// [AlphaFS] Gets a object that encapsulates the specified type of access control list (ACL) entries for a particular directory handle. - /// A object that encapsulates the access control rules for the directory described by the parameter. - /// - /// - /// - /// A to a directory containing a object that describes the directory's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - [SecurityCritical] - public static DirectorySecurity GetAccessControl(SafeFileHandle handle, AccessControlSections includeSections) - { - return File.GetAccessControlHandleCore(false, true, handle, includeSections, SecurityInformation.None); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs deleted file mode 100644 index d70676c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Gets the change date and time of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in local time. - /// The directory for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetChangeTime(string path) - { - return File.GetChangeTimeCore(true, null, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in local time. - /// The directory for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTime(string path, PathFormat pathFormat) - { - return File.GetChangeTimeCore(true, null, null, path, false, pathFormat); - } - - - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetChangeTimeUtc(string path) - { - return File.GetChangeTimeCore(true, null, null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) - { - return File.GetChangeTimeCore(true, null, null, path, true, pathFormat); - } - - - - /// [AlphaFS] Gets the change date and time of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in local time. - /// An open handle to the directory from which to retrieve information. - [SecurityCritical] - public static DateTime GetChangeTime(SafeFileHandle safeHandle) - { - return File.GetChangeTimeCore(true, null, safeHandle, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time. - /// An open handle to the directory from which to retrieve information. - [SecurityCritical] - public static DateTime GetChangeTimeUtc(SafeFileHandle safeHandle) - { - return File.GetChangeTimeCore(true, null, safeHandle, null, true, PathFormat.RelativePath); - } - - #region Transactional - - /// [AlphaFS] Gets the change date and time of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path) - { - return File.GetChangeTimeCore(true, transaction, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetChangeTimeCore(true, transaction, null, path, false, pathFormat); - } - - - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time. - /// The transaction. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path) - { - return File.GetChangeTimeCore(true, transaction, null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the change date and time for the specified directory. This value is expressed in UTC time. - /// The transaction. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetChangeTimeCore(true, transaction, null, path, true, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs deleted file mode 100644 index 8b6b3aa..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Gets the creation date and time of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in local time. - /// The directory for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetCreationTime(string path) - { - return File.GetCreationTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - - - /// Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time. - /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetCreationTimeUtc(string path) - { - return File.GetCreationTimeCore(null, path, true, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Gets the creation date and time of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in local time. - /// The directory for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetCreationTime(string path, PathFormat pathFormat) - { - return File.GetCreationTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time. - /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetCreationTimeUtc(string path, PathFormat pathFormat) - { - return File.GetCreationTimeCore(null, path, true, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Gets the creation date and time of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path) - { - return File.GetCreationTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the creation date and time of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetCreationTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path) - { - return File.GetCreationTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified directory. - /// A structure set to the creation date and time for the specified directory. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetCreationTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs deleted file mode 100644 index ccac010..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs +++ /dev/null @@ -1,210 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - // Since Directory.GetDirectories() is less efficient than Directory.EnumerateDirectories(), - // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods. - - #region .NET - - /// Returns the names of subdirectories (including their paths) in the specified directory. - /// An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - [SecurityCritical] - public static string[] GetDirectories(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory. - /// An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetDirectories(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories. - /// An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetDirectories(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // .NET - - #region Transactional - - /// Returns the names of subdirectories (including their paths) in the specified directory. - /// An array of the full names (including paths) of subdirectories in the specified path, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - [SecurityCritical] - public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of subdirectories (including their paths) that match the specified search pattern in the specified directory. - /// An array of the full names (including paths) of the subdirectories that match the search pattern in the specified directory, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of the subdirectories (including their paths) that match the specified search pattern in the specified directory, and optionally searches subdirectories. - /// An array of the full names (including paths) of the subdirectories that match the specified criteria, or an empty array if no directories are found. - /// - /// The names returned by this method are prefixed with the directory information provided in path. - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetDirectoriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs deleted file mode 100644 index 91b62f6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Returns the volume information, root information, or both for the specified path. - /// The volume information, root information, or both for the specified path, or if path does not contain root directory information. - /// - /// - /// - /// The path of a file or directory. - [SecurityCritical] - public static string GetDirectoryRoot(string path) - { - return GetDirectoryRootCore(null, path, PathFormat.RelativePath); - } - - #endregion // .NET - - /// Returns the volume information, root information, or both for the specified path. - /// The volume information, root information, or both for the specified path, or if path does not contain root directory information. - /// - /// - /// - /// The path of a file or directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static string GetDirectoryRoot(string path, PathFormat pathFormat) - { - return GetDirectoryRootCore(null, path, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Returns the volume information, root information, or both for the specified path. - /// The volume information, root information, or both for the specified path, or if path does not contain root directory information. - /// - /// - /// - /// The transaction. - /// The path of a file or directory. - [SecurityCritical] - public static string GetDirectoryRootTransacted(KernelTransaction transaction, string path) - { - return GetDirectoryRootCore(transaction, path, PathFormat.RelativePath); - } - - /// Returns the volume information, root information, or both for the specified path. - /// The volume information, root information, or both for the specified path, or if path does not contain root directory information. - /// - /// - /// - /// The transaction. - /// The path of a file or directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static string GetDirectoryRootTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetDirectoryRootCore(transaction, path, pathFormat); - } - - #endregion // Transactional - - #region Internal Methods - - /// Returns the volume information, root information, or both for the specified path. - /// The volume information, root information, or both for the specified path, or if path does not contain root directory information. - /// - /// - /// - /// The transaction. - /// The path of a file or directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static string GetDirectoryRootCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - Path.CheckInvalidUncPath(path); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.CheckInvalidPathChars); - - pathLp = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false); - - string rootPath = Path.GetPathRoot(pathLp, false); - - return Utils.IsNullOrWhiteSpace(rootPath) ? null : rootPath; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs deleted file mode 100644 index e4974a0..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs +++ /dev/null @@ -1,210 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - // Since Directory.GetFileSystemEntries() is less efficient than Directory.EnumerateFileSystemEntries(), - // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods. - - #region .NET - - /// Returns the names of all files and subdirectories in the specified directory. - /// An string[] array of the names of files and subdirectories in the specified directory. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory for which file and subdirectory names are returned. - [SecurityCritical] - public static string[] GetFileSystemEntries(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray(); - } - - /// Returns an array of file system entries that match the specified search criteria. - /// An string[] array of file system entries that match the specified search criteria. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The path to be searched. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetFileSystemEntries(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray(); - } - - /// Gets an array of all the file names and directory names that match a in a specified path, and optionally searches subdirectories. - /// An string[] array of file system entries that match the specified search criteria. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetFileSystemEntries(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // .NET - - #region Transactional - - /// Returns the names of all files and subdirectories in the specified directory. - /// An string[] array of the names of files and subdirectories in the specified directory. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory for which file and subdirectory names are returned. - [SecurityCritical] - public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray(); - } - - /// Returns an array of file system entries that match the specified search criteria. - /// An string[] array of file system entries that match the specified search criteria. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The path to be searched. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath).ToArray(); - } - - /// Gets an array of all the file names and directory names that match a in a specified path, and optionally searches subdirectories. - /// An string[] array of file system entries that match the specified search criteria. - /// - /// The EnumerateFileSystemEntries and GetFileSystemEntries methods differ as follows: When you use EnumerateFileSystemEntries, - /// you can start enumerating the collection of entries before the whole collection is returned; when you use GetFileSystemEntries, - /// you must wait for the whole array of entries to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetFileSystemEntriesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs deleted file mode 100644 index 4d1d46f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs +++ /dev/null @@ -1,216 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; -using SearchOption = System.IO.SearchOption; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - // Since Directory.GetFiles() is less efficient than Directory.EnumerateFiles(), - // only .NET and AlphaFS Transactional methods are implemented. No additional overloaded methods. - - #region .NET - - /// Returns the names of files (including their paths) in the specified directory. - /// An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - [SecurityCritical] - public static string[] GetFiles(string path) - { - return EnumerateFileSystemEntryInfosCore(null, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory. - /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetFiles(string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of files (including their paths) that match the specified search pattern in the current directory, and optionally searches subdirectories. - /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(null, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // .NET - - #region Transactional - - /// Returns the names of files (including their paths) in the specified directory. - /// An array of the full names (including paths) for the files in the specified directory, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - [SecurityCritical] - public static string[] GetFilesTransacted(KernelTransaction transaction, string path) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of files (including their paths) that match the specified search pattern in the specified directory. - /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public static string[] GetFilesTransacted(KernelTransaction transaction, string path, string searchPattern) - { - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.RelativePath).ToArray(); - } - - /// Returns the names of files (including their paths) that match the specified search pattern in the current directory, and optionally searches subdirectories. - /// An array of the full names (including paths) for the files in the specified directory that match the specified search pattern and option, or an empty array if no files are found. - /// - /// The returned file names are appended to the supplied parameter. - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The directory to search. - /// - /// The search string to match against the names of directories in . - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public static string[] GetFilesTransacted(KernelTransaction transaction, string path, string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return EnumerateFileSystemEntryInfosCore(transaction, path, searchPattern, options, PathFormat.RelativePath).ToArray(); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastAccessTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastAccessTime.cs deleted file mode 100644 index 9808b72..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastAccessTime.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Gets the date and time that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in local time. - /// The directory for which to obtain access date and time information. - [SecurityCritical] - public static DateTime GetLastAccessTime(string path) - { - return File.GetLastAccessTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// Gets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in UTC time. - /// The directory for which to obtain access date and time information. - [SecurityCritical] - public static DateTime GetLastAccessTimeUtc(string path) - { - return File.GetLastAccessTimeCore(null, path, true, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Gets the date and time that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in local time. - /// The directory for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastAccessTime(string path, PathFormat pathFormat) - { - return File.GetLastAccessTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in UTC time. - /// The directory for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastAccessTimeUtc(string path, PathFormat pathFormat) - { - return File.GetLastAccessTimeCore(null, path, true, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Gets the date and time that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain access date and time information. - [SecurityCritical] - public static DateTime GetLastAccessTimeTransacted(KernelTransaction transaction, string path) - { - return File.GetLastAccessTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastAccessTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetLastAccessTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain access date and time information. - [SecurityCritical] - public static DateTime GetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path) - { - return File.GetLastAccessTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// A structure set to the date and time that the specified directory was last accessed. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetLastAccessTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastWriteTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastWriteTime.cs deleted file mode 100644 index c34a959..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLastWriteTime.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Gets the date and time that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in local time. - /// The directory for which to obtain write date and time information. - [SecurityCritical] - public static DateTime GetLastWriteTime(string path) - { - return File.GetLastWriteTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - - - /// Gets the date and time, in coordinated universal time (UTC) time, that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in UTC time. - /// The directory for which to obtain write date and time information. - [SecurityCritical] - public static DateTime GetLastWriteTimeUtc(string path) - { - return File.GetLastWriteTimeCore(null, path, true, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Gets the date and time that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in local time. - /// The directory for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastWriteTime(string path, PathFormat pathFormat) - { - return File.GetLastWriteTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in UTC time. - /// The directory for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastWriteTimeUtc(string path, PathFormat pathFormat) - { - return File.GetLastWriteTimeCore(null, path, true, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Gets the date and time that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain write date and time information. - [SecurityCritical] - public static DateTime GetLastWriteTimeTransacted(KernelTransaction transaction, string path) - { - return File.GetLastWriteTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in local time. - /// The transaction. - /// The directory for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastWriteTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetLastWriteTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain write date and time information. - [SecurityCritical] - public static DateTime GetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path) - { - return File.GetLastWriteTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified directory was last written to. - /// A structure set to the date and time that the specified directory was last written to. This value is expressed in UTC time. - /// The transaction. - /// The directory for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return File.GetLastWriteTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs deleted file mode 100644 index a6a3620..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Retrieves the names of the logical drives on this computer in the form "<drive letter>:\". - /// An array of type that represents the logical drives on a computer. - [SecurityCritical] - public static string[] GetLogicalDrives() - { - return EnumerateLogicalDrivesCore(false, false).Select(drive => drive.Name).ToArray(); - } - - #endregion // .NET - - /// [AlphaFS] Retrieves the names of the logical drives on this computer in the form "<drive letter>:\". - /// An array of type that represents the logical drives on a computer. - /// Retrieve logical drives as known by the Environment. - /// Retrieve only when accessible (IsReady) logical drives. - [SecurityCritical] - public static string[] GetLogicalDrives(bool fromEnvironment, bool isReady) - { - return EnumerateLogicalDrivesCore(fromEnvironment, isReady).Select(drive => drive.Name).ToArray(); - } - - - /// [AlphaFS] Enumerates the drive names of all logical drives on a computer. - /// An IEnumerable of type that represents the logical drives on a computer. - /// Retrieve logical drives as known by the Environment. - /// Retrieve only when accessible (IsReady) logical drives. - [SecurityCritical] - public static IEnumerable EnumerateLogicalDrives(bool fromEnvironment, bool isReady) - { - return EnumerateLogicalDrivesCore(fromEnvironment, isReady); - } - - #region Internal Methods - - /// Enumerates the drive names of all logical drives on a computer. - /// An IEnumerable of type that represents the logical drives on a computer. - /// Retrieve logical drives as known by the Environment. - /// Retrieve only when accessible (IsReady) logical drives. - [SecurityCritical] - internal static IEnumerable EnumerateLogicalDrivesCore(bool fromEnvironment, bool isReady) - { - #region Get from Environment - - if (fromEnvironment) - { - IEnumerable drivesEnv = isReady - ? Environment.GetLogicalDrives().Where(ld => File.ExistsCore(true, null, ld, PathFormat.FullPath)) - : Environment.GetLogicalDrives().Select(ld => ld); - - foreach (string drive in drivesEnv) - { - // Optionally check Drive .IsReady. - if (isReady) - { - if (File.ExistsCore(true, null, drive, PathFormat.FullPath)) - yield return new DriveInfo(drive); - } - else - yield return new DriveInfo(drive); - } - - yield break; - } - - #endregion // Get from Environment - - #region Get through NativeMethod - - uint lastError = NativeMethods.GetLogicalDrives(); - if (lastError == Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException((int)lastError); - - uint drives = lastError; - int count = 0; - while (drives != 0) - { - if ((drives & 1) != 0) - ++count; - - drives >>= 1; - } - - string[] result = new string[count]; - char[] root = { 'A', Path.VolumeSeparatorChar }; - - drives = lastError; - count = 0; - - while (drives != 0) - { - if ((drives & 1) != 0) - { - string drive = new string(root); - - if (isReady) - { - // Optionally check Drive .IsReady. - if (File.ExistsCore(true, null, drive, PathFormat.FullPath)) - yield return new DriveInfo(drive); - } - else - { - // Ready or not. - yield return new DriveInfo(drive); - } - - result[count++] = drive; - } - - drives >>= 1; - root[0]++; - } - - #endregion // Get through NativeMethod - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetParent.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetParent.cs deleted file mode 100644 index c2945a4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetParent.cs +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Retrieves the parent directory of the specified path, including both absolute and relative paths. - /// The path for which to retrieve the parent directory. - /// The parent directory, or if is the root directory, including the root of a UNC server or share name. - [SecurityCritical] - public static DirectoryInfo GetParent(string path) - { - return GetParentCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves the parent directory of the specified path, including both absolute and relative paths. - /// The parent directory, or if is the root directory, including the root of a UNC server or share name. - /// The path for which to retrieve the parent directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DirectoryInfo GetParent(string path, PathFormat pathFormat) - { - return GetParentCore(null, path, pathFormat); - } - - #endregion // .NET - - /// [AlphaFS] Retrieves the parent directory of the specified path, including both absolute and relative paths. - /// The parent directory, or if is the root directory, including the root of a UNC server or share name. - /// The transaction. - /// The path for which to retrieve the parent directory. - [SecurityCritical] - public static DirectoryInfo GetParentTransacted(KernelTransaction transaction, string path) - { - return GetParentCore(transaction, path, PathFormat.RelativePath); - } - - /// Retrieves the parent directory of the specified path, including both absolute and relative paths. - /// The parent directory, or if is the root directory, including the root of a UNC server or share name. - /// The transaction. - /// The path for which to retrieve the parent directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DirectoryInfo GetParentTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetParentCore(transaction, path, pathFormat); - } - - #region Internal Methods - - /// Retrieves the parent directory of the specified path, including both absolute and relative paths. - /// The parent directory, or if is the root directory, including the root of a UNC server or share name. - /// The transaction. - /// The path for which to retrieve the parent directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static DirectoryInfo GetParentCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.CheckInvalidPathChars); - - pathLp = Path.GetRegularPathCore(pathLp, GetFullPathOptions.None, false); - string dirName = Path.GetDirectoryName(pathLp, false); - - return Utils.IsNullOrWhiteSpace(dirName) ? null : new DirectoryInfo(transaction, dirName, PathFormat.RelativePath); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs deleted file mode 100644 index 92dfe70..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs +++ /dev/null @@ -1,286 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The target directory. - [SecurityCritical] - public static Dictionary GetProperties(string path) - { - return GetPropertiesCore(null, path, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The target directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static Dictionary GetProperties(string path, PathFormat pathFormat) - { - return GetPropertiesCore(null, path, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The target directory. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static Dictionary GetProperties(string path, DirectoryEnumerationOptions options) - { - return GetPropertiesCore(null, path, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The target directory. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static Dictionary GetProperties(string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return GetPropertiesCore(null, path, options, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The target directory. - [SecurityCritical] - public static Dictionary GetPropertiesTransacted(KernelTransaction transaction, string path) - { - return GetPropertiesCore(transaction, path, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The target directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static Dictionary GetPropertiesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetPropertiesCore(transaction, path, DirectoryEnumerationOptions.FilesAndFolders, pathFormat); - } - - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The target directory. - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public static Dictionary GetPropertiesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options) - { - return GetPropertiesCore(transaction, path, options, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The target directory. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static Dictionary GetPropertiesTransacted(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - return GetPropertiesCore(transaction, path, options, pathFormat); - } - - #endregion // Transactional - - #region Internal Methods - - /// [AlphaFS] Gets the properties of the particular directory without following any symbolic links or mount points. - /// Properties include aggregated info from of each encountered file system object, plus additional ones: Total, File, Size and Error. - /// Total: is the total number of enumerated objects. - /// File: is the total number of files. File is considered when object is neither nor . - /// Size: is the total size of enumerated objects. - /// Error: is the total number of errors encountered during enumeration. - /// - /// A dictionary mapping the keys mentioned above to their respective aggregated values. - /// Directory: is an object which has attribute without one. - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The target directory. - /// flags that specify how the directory is to be enumerated. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static Dictionary GetPropertiesCore(KernelTransaction transaction, string path, DirectoryEnumerationOptions options, PathFormat pathFormat) - { - long total = 0; - long size = 0; - - const string propFile = "File"; - const string propTotal = "Total"; - const string propSize = "Size"; - - var typeOfAttrs = typeof(FileAttributes); - var attributes = Enum.GetValues(typeOfAttrs); - var props = Enum.GetNames(typeOfAttrs).OrderBy(attrs => attrs).ToDictionary(name => name, name => 0); - var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, pathLp, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath)) - { - total++; - - if (!fsei.IsDirectory) - size += fsei.FileSize; - - var fsei1 = fsei; - - foreach (var attributeMarker in attributes.Cast().Where(attributeMarker => (fsei1.Attributes & attributeMarker) != 0)) - props[((attributeMarker & FileAttributes.Directory) != 0 ? FileAttributes.Directory : attributeMarker).ToString()]++; - } - - // Adjust regular files count. - props.Add(propFile, total - props[FileAttributes.Directory.ToString()] - props[FileAttributes.ReparsePoint.ToString()]); - props.Add(propTotal, total); - props.Add(propSize, size); - - return props; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.HasInheritedPermissions.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.HasInheritedPermissions.cs deleted file mode 100644 index 71e4033..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.HasInheritedPermissions.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security.AccessControl; -using System.Security.Principal; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Check if the directory has permission inheritance enabled. - /// if permission inheritance is enabled, if permission inheritance is disabled. - /// The full path to the directory to check. - /// Indicates the format of the path parameter(s). - public static bool HasInheritedPermissions(string path, PathFormat pathFormat) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - var acl = File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, pathFormat); - - return acl.GetAccessRules(false, true, typeof(SecurityIdentifier)).Count > 0; - } - - - /// [AlphaFS] Check if the directory has permission inheritance enabled. - /// The full path to the directory to check. - /// if permission inheritance is enabled, if permission inheritance is disabled. - public static bool HasInheritedPermissions(string path) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - var acl = File.GetAccessControlCore(true, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.RelativePath); - - return acl.GetAccessRules(false, true, typeof(SecurityIdentifier)).Count > 0; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetAccessControl.cs deleted file mode 100644 index fc0559b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetAccessControl.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Security.AccessControl; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// Applies access control list (ACL) entries described by a object to the specified directory. - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, DirectorySecurity directorySecurity) - { - File.SetAccessControlCore(path, null, directorySecurity, AccessControlSections.All, PathFormat.RelativePath); - } - - /// Applies access control list (ACL) entries described by a object to the specified directory. - /// Note that unlike this method does not automatically - /// determine what parts of the specified instance has been modified. Instead, the - /// parameter is used to specify what entries from to apply to . - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, DirectorySecurity directorySecurity, AccessControlSections includeSections) - { - File.SetAccessControlCore(path, null, directorySecurity, includeSections, PathFormat.RelativePath); - } - - - /// [AlphaFS] Applies access control list (ACL) entries described by a object to the specified directory. - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, DirectorySecurity directorySecurity, PathFormat pathFormat) - { - File.SetAccessControlCore(path, null, directorySecurity, AccessControlSections.All, pathFormat); - } - - /// [AlphaFS] Applies access control list (ACL) entries described by a object to the specified directory. - /// Note that unlike this method does not automatically - /// determine what parts of the specified instance has been modified. Instead, the - /// parameter is used to specify what entries from to apply to . - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, DirectorySecurity directorySecurity, AccessControlSections includeSections, PathFormat pathFormat) - { - File.SetAccessControlCore(path, null, directorySecurity, includeSections, pathFormat); - } - - - /// Applies access control list (ACL) entries described by a object to the specified directory. - /// A to a file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(SafeFileHandle handle, DirectorySecurity directorySecurity) - { - File.SetAccessControlCore(null, handle, directorySecurity, AccessControlSections.All, PathFormat.LongFullPath); - } - - /// Applies access control list (ACL) entries described by a object to the specified directory. - /// A to a file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(SafeFileHandle handle, DirectorySecurity directorySecurity, AccessControlSections includeSections) - { - File.SetAccessControlCore(null, handle, directorySecurity, includeSections, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetCreationTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetCreationTime.cs deleted file mode 100644 index f2698a1..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetCreationTime.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Sets the date and time the directory was created. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), null, null, false, PathFormat.RelativePath); - } - - - - /// Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, null, null, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Sets the date and time the directory was created. - /// The directory for which to set the creation date and time information. - /// Indicates the format of the path parameter(s). - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time the directory was created. - /// The directory for which to set the creation date and time information. - /// Indicates the format of the path parameter(s). - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), null, null, modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, null, null, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets the date and time the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), null, null, modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the directory was created. - /// The transaction. - /// The directory for which to set the creation date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, null, null, modifyReparsePoint, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastAccessTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastAccessTime.cs deleted file mode 100644 index 998ef00..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastAccessTime.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Sets the date and time that the specified directory was last accessed. - /// The file for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTime.ToUniversalTime(), null, false, PathFormat.RelativePath); - } - - - - /// Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTimeUtc, null, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Sets the date and time that the specified directory was last accessed. - /// The file for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTime.ToUniversalTime(), null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last accessed. - /// The file for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTime.ToUniversalTime(), null, modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTimeUtc, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, lastAccessTimeUtc, null, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets the date and time that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTime.ToUniversalTime(), null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTime.ToUniversalTime(), null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTime.ToUniversalTime(), null, modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTimeUtc, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTimeUtc, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last accessed. - /// The transaction. - /// The directory for which to set the access date and time information. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, lastAccessTimeUtc, null, modifyReparsePoint, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastWriteTime.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastWriteTime.cs deleted file mode 100644 index 2211921..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetLastWriteTime.cs +++ /dev/null @@ -1,167 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - #region .NET - - /// Sets the date and time that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - - - /// Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Sets the date and time that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets the date and time that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified directory was last written to. - /// The transaction. - /// The directory for which to set the date and time information. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetTimestamps.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetTimestamps.cs deleted file mode 100644 index a3711ca..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.SetTimestamps.cs +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in local time. - /// A containing the value to set for the last access date and time of . This value is expressed in local time. - /// A containing the value to set for the last write date and time of . This value is expressed in local time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified directory, at once. - /// The transaction. - /// The directory for which to set the dates and times information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - File.SetFsoDateTimeCore(true, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.TransferTimestamps.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.TransferTimestamps.cs deleted file mode 100644 index 069f9c9..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.TransferTimestamps.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class Directory - { - /// [AlphaFS] Transfers the date and time stamps for the specified directories. - /// This method uses BackupSemantics flag to get Timestamp changed for directories. - /// The source directory to get the date and time stamps from. - /// The destination directory to set the date and time stamps. - [SecurityCritical] - public static void TransferTimestamps(string sourcePath, string destinationPath) - { - File.TransferTimestampsCore(true, null, sourcePath, destinationPath, PathFormat.RelativePath); - } - - /// [AlphaFS] Transfers the date and time stamps for the specified directories. - /// This method uses BackupSemantics flag to get Timestamp changed for directories. - /// The source directory to get the date and time stamps from. - /// The destination directory to set the date and time stamps. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void TransferTimestamps(string sourcePath, string destinationPath, PathFormat pathFormat) - { - File.TransferTimestampsCore(true, null, sourcePath, destinationPath, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Transfers the date and time stamps for the specified directories. - /// This method uses BackupSemantics flag to get Timestamp changed for directories. - /// The transaction. - /// The source directory to get the date and time stamps from. - /// The destination directory to set the date and time stamps. - [SecurityCritical] - public static void TransferTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath) - { - File.TransferTimestampsCore(true, transaction, sourcePath, destinationPath, PathFormat.RelativePath); - } - - /// [AlphaFS] Transfers the date and time stamps for the specified directories. - /// This method uses BackupSemantics flag to get Timestamp changed for directories. - /// The transaction. - /// The source directory to get the date and time stamps from. - /// The destination directory to set the date and time stamps. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void TransferTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat) - { - File.TransferTimestampsCore(true, transaction, sourcePath, destinationPath, pathFormat); - } - - #endregion // Transactional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.cs b/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.cs deleted file mode 100644 index 70e6604..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Directory Class/Directory.cs +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Exposes static methods for creating, moving, and enumerating through directories and subdirectories. - /// This class cannot be inherited. - /// - public static partial class Directory - { - // This file only exists for the documentation. - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Compression.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Compression.cs deleted file mode 100644 index 0070b8d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Compression.cs +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region AlphaFS - - #region Compress - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// This will only compress the root items (non recursive). - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public void Compress() - { - Directory.CompressDecompressCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, true, PathFormat.LongFullPath); - } - - /// [AlphaFS] Compresses a directory using NTFS compression. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public void Compress(DirectoryEnumerationOptions options) - { - Directory.CompressDecompressCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, true, PathFormat.LongFullPath); - } - - #endregion // Compress - - #region Decompress - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// This will only decompress the root items (non recursive). - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public void Decompress() - { - Directory.CompressDecompressCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Decompresses an NTFS compressed directory. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public void Decompress(DirectoryEnumerationOptions options) - { - Directory.CompressDecompressCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, false, PathFormat.LongFullPath); - } - - #endregion // Decompress - - #region DisableCompression - - /// [AlphaFS] Disables compression of the specified directory and the files in it. - /// - /// This method disables the directory-compression attribute. It will not decompress the current contents of the directory. - /// However, newly created files and directories will be uncompressed. - /// - [SecurityCritical] - public void DisableCompression() - { - Device.ToggleCompressionCore(true, Transaction, LongFullName, false, PathFormat.LongFullPath); - } - - #endregion // DisableCompression - - #region EnableCompression - - /// [AlphaFS] Enables compression of the specified directory and the files in it. - /// - /// This method enables the directory-compression attribute. It will not compress the current contents of the directory. - /// However, newly created files and directories will be compressed. - /// - [SecurityCritical] - public void EnableCompression() - { - Device.ToggleCompressionCore(true, Transaction, LongFullName, true, PathFormat.LongFullPath); - } - - #endregion // EnableCompression - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CopyToMoveTo.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CopyToMoveTo.cs deleted file mode 100644 index f58feda..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CopyToMoveTo.cs +++ /dev/null @@ -1,459 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region CopyTo - - // .NET: Directory class does not contain the Copy() method. - // Mimic .NET File.Copy() methods. - - /// [AlphaFS] Copies a instance and its contents to a new path. - /// - /// Use this method to prevent overwriting of an existing directory by default. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance if the directory was completely copied. - /// - /// - /// - /// - /// - /// - /// The destination directory path. - [SecurityCritical] - public DirectoryInfo CopyTo(string destinationPath) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, CopyOptions.FailIfExists, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Copies a instance and its contents to a new path. - /// - /// Use this method to prevent overwriting of an existing directory by default. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance if the directory was completely copied. - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public DirectoryInfo CopyTo(string destinationPath, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, CopyOptions.FailIfExists, null, null, null, out destinationPathLp, pathFormat); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing directory to a new directory, allowing the overwriting of an existing directory, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing directory. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// Returns a new directory, or an overwrite of an existing directory if is not . - /// If the directory exists and contains , an is thrown. - /// - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - [SecurityCritical] - public DirectoryInfo CopyTo(string destinationPath, CopyOptions copyOptions) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, copyOptions, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Copies an existing directory to a new directory, allowing the overwriting of an existing directory, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing directory. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// Returns a new directory, or an overwrite of an existing directory if is not . - /// If the directory exists and contains , an is thrown. - /// - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public DirectoryInfo CopyTo(string destinationPath, CopyOptions copyOptions, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, copyOptions, null, null, null, out destinationPathLp, pathFormat); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing directory to a new directory, allowing the overwriting of an existing directory, can be specified. - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing directory. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - /// [AlphaFS] Copies an existing directory to a new directory, allowing the overwriting of an existing directory, can be specified. - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing directory. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// that specify how the directory is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the directory has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, pathFormat); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - #endregion // CopyTo - - - #region MoveTo - - #region .NET - - /// Moves a instance and its contents to a new path. - /// - /// Use this method to prevent overwriting of an existing directory by default. - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath) - { - string destinationPathLp; - var copyMoveResult = CopyToMoveToCore(destinationPath, null, MoveOptions.None, null, null, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - - return copyMoveResult; - } - - #endregion // .NET - - - #region AlphaFS - - /// Moves a instance and its contents to a new path. - /// - /// Use this method to prevent overwriting of an existing directory by default. - /// This method does not work across disk volumes. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance if the directory was completely moved. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public DirectoryInfo MoveTo(string destinationPath, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, null, MoveOptions.None, null, null, out destinationPathLp, pathFormat); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Moves a instance and its contents to a new path, can be specified. - /// - /// Use this method to allow or prevent overwriting of an existing directory. - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance if the directory was completely moved. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume unless contains , or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - /// that specify how the directory is to be moved. This parameter can be . - [SecurityCritical] - public DirectoryInfo MoveTo(string destinationPath, MoveOptions moveOptions) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, null, moveOptions, null, null, out destinationPathLp, PathFormat.RelativePath); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Moves a instance and its contents to a new path, can be specified. - /// - /// Use this method to allow or prevent overwriting of an existing directory. - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance if the directory was completely moved. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume unless contains , or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - /// that specify how the directory is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public DirectoryInfo MoveTo(string destinationPath, MoveOptions moveOptions, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, null, moveOptions, null, null, out destinationPathLp, pathFormat); - return new DirectoryInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Moves a instance and its contents to a new path, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Use this method to allow or prevent overwriting of an existing directory. - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume unless contains , or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, null, moveOptions, progressHandler, userProgressData, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - - - /// [AlphaFS] Moves a instance and its contents to a new path, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Use this method to allow or prevent overwriting of an existing directory. - /// This method does not work across disk volumes unless contains . - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two directories have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The name and path to which to move this directory. - /// The destination cannot be another disk volume unless contains , or a directory with the identical name. - /// It can be an existing directory to which you want to add this directory as a subdirectory. - /// - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, null, moveOptions, progressHandler, userProgressData, out destinationPathLp, pathFormat); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - #endregion // AlphaFS - - #endregion // MoveTo - - - #region Internal Methods - - /// Copy/move a Non-/Transacted file or directory including its children to a new location, - /// or can be specified, and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// You cannot use the Move method to overwrite an existing file, unless contains . - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an IOException. - /// - /// - /// A class with details of the Copy or Move action. - /// - /// - /// - /// - /// - /// - /// The destination directory path. - /// that specify how the file is to be copied. This parameter can be . - /// that specify how the file is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Returns the retrieved long full path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - private CopyMoveResult CopyToMoveToCore(string destinationPath, CopyOptions? copyOptions, MoveOptions? moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, out string longFullPath, PathFormat pathFormat) - { - var destinationPathLp = Path.GetExtendedLengthPathCore(null, destinationPath, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - longFullPath = destinationPathLp; - - // Returns false when CopyMoveProgressResult is PROGRESS_CANCEL or PROGRESS_STOP. - return Directory.CopyMoveCore(Transaction, LongFullName, destinationPathLp, copyOptions, moveOptions, progressHandler, userProgressData, null, PathFormat.LongFullPath); - } - - - private void CopyToMoveToCoreRefresh(string destinationPath, string destinationPathLp) - { - LongFullName = destinationPathLp; - FullPath = Path.GetRegularPathCore(destinationPathLp, GetFullPathOptions.None, false); - - OriginalPath = destinationPath; - DisplayPath = Path.GetRegularPathCore(OriginalPath, GetFullPathOptions.None, false); - - // Flush any cached information about the directory. - Reset(); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CountFileSystemObjects.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CountFileSystemObjects.cs deleted file mode 100644 index 71b69ab..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CountFileSystemObjects.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region AlphaFS - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public long CountFileSystemObjects(DirectoryEnumerationOptions options) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath).Count(); - } - - /// [AlphaFS] Counts file system objects: files, folders or both) in a given directory. - /// The counted number of file system objects. - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public long CountFileSystemObjects(string searchPattern, DirectoryEnumerationOptions options) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath).Count(); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Create.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Create.cs deleted file mode 100644 index dd01e8b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Create.cs +++ /dev/null @@ -1,81 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Creates a directory. - /// If the directory already exists, this method does nothing. - - [SecurityCritical] - public void Create() - { - Directory.CreateDirectoryCore(Transaction, LongFullName, null, null, false, PathFormat.LongFullPath); - } - - /// Creates a directory using a object. - /// The access control to apply to the directory. - /// If the directory already exists, this method does nothing. - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void Create(DirectorySecurity directorySecurity) - { - Directory.CreateDirectoryCore(Transaction, LongFullName, null, directorySecurity, false, PathFormat.LongFullPath); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Creates a directory using a object. - /// When compresses the directory. - /// If the directory already exists, this method does nothing. - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void Create(bool compress) - { - Directory.CreateDirectoryCore(Transaction, LongFullName, null, null, compress, PathFormat.LongFullPath); - } - - /// [AlphaFS] Creates a directory using a object. - /// The access control to apply to the directory. - /// When compresses the directory. - /// If the directory already exists, this method does nothing. - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void Create(DirectorySecurity directorySecurity, bool compress) - { - Directory.CreateDirectoryCore(Transaction, LongFullName, null, directorySecurity, compress, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CreateSubdirectory.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CreateSubdirectory.cs deleted file mode 100644 index f4b40d2..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CreateSubdirectory.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The specified path. This cannot be a different disk volume. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path) - { - return CreateSubdirectoryCore(path, null, null, false); - } - - /// Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The specified path. This cannot be a different disk volume. - /// The security to apply. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path, DirectorySecurity directorySecurity) - { - return CreateSubdirectoryCore(path, null, directorySecurity, false); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - /// The specified path. This cannot be a different disk volume. - /// When compresses the directory. - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path, bool compress) - { - return CreateSubdirectoryCore(path, null, null, compress); - } - - /// [AlphaFS] Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The specified path. This cannot be a different disk volume. - /// The path of the directory to use as a template when creating the new directory. - /// When compresses the directory. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path, string templatePath, bool compress) - { - return CreateSubdirectoryCore(path, templatePath, null, compress); - } - - - /// [AlphaFS] Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The specified path. This cannot be a different disk volume. - /// The security to apply. - /// When compresses the directory. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path, DirectorySecurity directorySecurity, bool compress) - { - return CreateSubdirectoryCore(path, null, directorySecurity, compress); - } - - /// [AlphaFS] Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the class. - /// The path of the directory to use as a template when creating the new directory. - /// The specified path. This cannot be a different disk volume. - /// When compresses the directory. - /// The security to apply. - /// The last directory specified in . - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public DirectoryInfo CreateSubdirectory(string path, string templatePath, DirectorySecurity directorySecurity, bool compress) - { - return CreateSubdirectoryCore(path, templatePath, directorySecurity, compress); - } - - #endregion // AlphaFS - - #region Internal Methods - - /// Creates a subdirectory or subdirectories on the specified path. The specified path can be relative to this instance of the DirectoryInfo class. - /// The last directory specified in path as an object. - /// - /// Any and all directories specified in path are created, unless some part of path is invalid. - /// The path parameter specifies a directory path, not a file path. - /// If the subdirectory already exists, this method does nothing. - /// - /// The specified path. This cannot be a different disk volume or Universal Naming Convention (UNC) name. - /// The path of the directory to use as a template when creating the new directory. - /// The security to apply. - /// When compresses the directory. - [SecurityCritical] - private DirectoryInfo CreateSubdirectoryCore(string path, string templatePath, ObjectSecurity directorySecurity, bool compress) - { - string pathLp = Path.CombineCore(false, LongFullName, path); - string templatePathLp = templatePath == null ? null : - Path.GetExtendedLengthPathCore(Transaction, templatePath, PathFormat.RelativePath, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); - - if (string.Compare(LongFullName, 0, pathLp, 0, LongFullName.Length, StringComparison.OrdinalIgnoreCase) != 0) - throw new ArgumentException(Resources.Invalid_Subpath, pathLp); - - return Directory.CreateDirectoryCore(Transaction, pathLp, templatePathLp, directorySecurity, compress, PathFormat.LongFullPath); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Decrypt.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Decrypt.cs deleted file mode 100644 index 4e453e3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Decrypt.cs +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Delete.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Delete.cs deleted file mode 100644 index ee84a63..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Delete.cs +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Deletes this if it is empty. - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public override void Delete() - { - Directory.DeleteDirectoryCore(EntryInfo, Transaction, null, false, false, false, PathFormat.LongFullPath); - } - - /// Deletes this instance of a , specifying whether to delete subdirectories and files. - /// - /// If the has no files or subdirectories, this method deletes the even if recursive is . - /// Attempting to delete a that is not empty when recursive is false throws an . - /// - /// - /// - /// - /// - /// - /// - /// to delete this directory, its subdirectories, and all files; otherwise, . - [SecurityCritical] - public void Delete(bool recursive) - { - Directory.DeleteDirectoryCore(EntryInfo, Transaction, null, recursive, false, false, PathFormat.LongFullPath); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Deletes this instance of a , specifying whether to delete files and subdirectories. - /// - /// If the has no files or subdirectories, this method deletes the even if recursive is . - /// Attempting to delete a that is not empty when recursive is false throws an . - /// - /// - /// - /// - /// - /// - /// - /// to delete this directory, its subdirectories, and all files; otherwise, . - /// ignores read only attribute of files and directories. - [SecurityCritical] - public void Delete(bool recursive, bool ignoreReadOnly) - { - Directory.DeleteDirectoryCore(EntryInfo, Transaction, null, recursive, ignoreReadOnly, false, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.DeleteEmptySubdirectories.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.DeleteEmptySubdirectories.cs deleted file mode 100644 index 4cd21e6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.DeleteEmptySubdirectories.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region AlphaFS - - /// [AlphaFS] Deletes empty subdirectories from the instance. - [SecurityCritical] - public void DeleteEmptySubdirectories() - { - Directory.DeleteEmptySubdirectoriesCore(EntryInfo, Transaction, null, false, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Deletes empty subdirectories from the instance. - /// deletes empty subdirectories from this directory and its subdirectories. - [SecurityCritical] - public void DeleteEmptySubdirectories(bool recursive) - { - Directory.DeleteEmptySubdirectoriesCore(EntryInfo, Transaction, null, recursive, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Deletes empty subdirectories from the instance. - /// deletes empty subdirectories from this directory and its subdirectories. - /// overrides read only of empty directories. - [SecurityCritical] - public void DeleteEmptySubdirectories(bool recursive, bool ignoreReadOnly) - { - Directory.DeleteEmptySubdirectoriesCore(EntryInfo, Transaction, null, recursive, ignoreReadOnly, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Encryption.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Encryption.cs deleted file mode 100644 index 16ff27b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Encryption.cs +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region AlphaFS - - #region Decrypt - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public void Decrypt() - { - Directory.EncryptDecryptDirectoryCore(LongFullName, false, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// to decrypt the directory recursively. only decrypt files and directories in the root of the directory. - [SecurityCritical] - public void Decrypt(bool recursive) - { - Directory.EncryptDecryptDirectoryCore(LongFullName, false, recursive, PathFormat.LongFullPath); - } - - #endregion // Decrypt - - #region DisableEncryption - - /// [AlphaFS] Disables encryption of the specified directory and the files in it. It does not affect encryption of subdirectories below the indicated directory. - /// on success, otherwise. - /// This method will create/change the file "Desktop.ini" and wil set Encryption value: "Disable=0" - [SecurityCritical] - public void DisableEncryption() - { - Directory.EnableDisableEncryptionCore(LongFullName, false, PathFormat.LongFullPath); - } - - #endregion // DisableEncryption - - #region EnableEncryption - - /// [AlphaFS] Enables encryption of the specified directory and the files in it. It does not affect encryption of subdirectories below the indicated directory. - /// on success, otherwise. - /// This method will create/change the file "Desktop.ini" and wil set Encryption value: "Disable=1" - [SecurityCritical] - public void EnableEncryption() - { - Directory.EnableDisableEncryptionCore(LongFullName, true, PathFormat.LongFullPath); - } - - #endregion // EnableEncryption - - #region Encrypt - - /// [AlphaFS] Encrypts a directory so that only the account used to encrypt the directory can decrypt it. - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public void Encrypt() - { - Directory.EncryptDecryptDirectoryCore(LongFullName, true, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Decrypts a directory that was encrypted by the current account using the Encrypt method. - /// - /// - /// - /// - /// - /// - /// to encrypt the directory recursively. only encrypt files and directories in the root of the directory. - [SecurityCritical] - public void Encrypt(bool recursive) - { - Directory.EncryptDecryptDirectoryCore(LongFullName, true, recursive, PathFormat.LongFullPath); - } - - #endregion // Encrypt - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs deleted file mode 100644 index 4b91dd7..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateAlternateDataStreams.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - /// [AlphaFS] Returns an enumerable collection of instances for the directory. - /// An enumerable collection of instances for the directory. - [SecurityCritical] - public IEnumerable EnumerateAlternateDataStreams() - { - return File.EnumerateAlternateDataStreamsCore(Transaction, LongFullName, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs deleted file mode 100644 index 05b5cee..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateDirectories.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns an enumerable collection of directory information in the current directory. - /// An enumerable collection of directories in the current directory. - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public IEnumerable EnumerateDirectories() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of directory information that matches a specified search pattern. - /// An enumerable collection of directories that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public IEnumerable EnumerateDirectories(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of directory information that matches a specified search pattern and search subdirectory option. - /// An enumerable collection of directories that matches and . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public IEnumerable EnumerateDirectories(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath); - } - - #endregion // .NET - - - - /// [AlphaFS] Returns an enumerable collection of directory information in the current directory. - /// An enumerable collection of directories in the current directory. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public IEnumerable EnumerateDirectories(DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of directory information that matches a specified search pattern. - /// An enumerable collection of directories that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public IEnumerable EnumerateDirectories(string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Files; - options |= DirectoryEnumerationOptions.Folders; - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.Folders | options, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs deleted file mode 100644 index 11bc623..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFileSystemInfos.cs +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns an enumerable collection of file system information in the current directory. - /// An enumerable collection of file system information in the current directory. - /// - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public IEnumerable EnumerateFileSystemInfos() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of file system information that matches a specified search pattern. - /// An enumerable collection of file system information objects that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public IEnumerable EnumerateFileSystemInfos(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of file system information that matches a specified search pattern and search subdirectory option. - /// An enumerable collection of file system information objects that matches and . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public IEnumerable EnumerateFileSystemInfos(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath); - } - - #endregion // .NET - - - - /// [AlphaFS] Returns an enumerable collection of file system information in the current directory. - /// An enumerable collection of file system information in the current directory. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public IEnumerable EnumerateFileSystemInfos(DirectoryEnumerationOptions options) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath); - } - - /// [AlphaFS] Returns an enumerable collection of file system information that matches a specified search pattern. - /// An enumerable collection of file system information objects that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public IEnumerable EnumerateFileSystemInfos(string searchPattern, DirectoryEnumerationOptions options) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs deleted file mode 100644 index 710ee06..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.EnumerateFiles.cs +++ /dev/null @@ -1,138 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns an enumerable collection of file information in the current directory. - /// An enumerable collection of the files in the current directory. - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public IEnumerable EnumerateFiles() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of file information that matches a search pattern. - /// An enumerable collection of files that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public IEnumerable EnumerateFiles(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of file information that matches a specified search pattern and search subdirectory option. - /// An enumerable collection of files that matches and . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public IEnumerable EnumerateFiles(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath); - } - - #endregion // .NET - - - - /// Returns an enumerable collection of file information in the current directory. - /// An enumerable collection of the files in the current directory. - /// - /// - /// - /// - /// - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public IEnumerable EnumerateFiles(DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, options, PathFormat.LongFullPath); - } - - /// Returns an enumerable collection of file information that matches a search pattern. - /// An enumerable collection of files that matches . - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// flags that specify how the directory is to be enumerated. - [SecurityCritical] - public IEnumerable EnumerateFiles(string searchPattern, DirectoryEnumerationOptions options) - { - // Adhere to the method name. - options &= ~DirectoryEnumerationOptions.Folders; - options |= DirectoryEnumerationOptions.Files; - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetAccessControl.cs deleted file mode 100644 index 2f844ea..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetAccessControl.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Gets a object that encapsulates the access control list (ACL) entries for the directory described by the current DirectoryInfo object. - /// A object that encapsulates the access control rules for the directory. - - [SecurityCritical] - public DirectorySecurity GetAccessControl() - { - return File.GetAccessControlCore(true, LongFullName, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.LongFullPath); - } - - /// Gets a object that encapsulates the specified type of access control list (ACL) entries for the directory described by the current object. - /// One of the values that specifies the type of access control list (ACL) information to receive. - /// A object that encapsulates the access control rules for the file described by the path parameter. - - [SecurityCritical] - public DirectorySecurity GetAccessControl(AccessControlSections includeSections) - { - return File.GetAccessControlCore(true, LongFullName, includeSections, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs deleted file mode 100644 index 848f4ea..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetDirectories.cs +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns the subdirectories of the current directory. - /// An array of objects. - /// If there are no subdirectories, this method returns an empty array. This method is not recursive. - /// - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public DirectoryInfo[] GetDirectories() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Folders, PathFormat.LongFullPath).ToArray(); - } - - /// Returns an array of directories in the current matching the given search criteria. - /// An array of type matching . - /// - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - [SecurityCritical] - public DirectoryInfo[] GetDirectories(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.Folders, PathFormat.LongFullPath).ToArray(); - } - - /// Returns an array of directories in the current matching the given search criteria and using a value to determine whether to search subdirectories. - /// An array of type matching . - /// If there are no subdirectories, or no subdirectories match the searchPattern parameter, this method returns an empty array. - /// - /// The EnumerateDirectories and GetDirectories methods differ as follows: When you use EnumerateDirectories, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetDirectories, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateDirectories can be more efficient. - /// - /// - /// - /// - /// - /// - /// - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - [SecurityCritical] - public DirectoryInfo[] GetDirectories(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Folders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath).ToArray(); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs deleted file mode 100644 index 7bcaa25..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFileSystemInfos.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns an array of strongly typed entries representing all the files and subdirectories in a directory. - /// An array of strongly typed entries. - /// - /// For subdirectories, the objects returned by this method can be cast to the derived class . - /// Use the value returned by the property to determine whether the represents a file or a directory. - /// - /// - /// If there are no files or directories in the DirectoryInfo, this method returns an empty array. This method is not recursive. - /// For subdirectories, the FileSystemInfo objects returned by this method can be cast to the derived class DirectoryInfo. - /// Use the FileAttributes value returned by the Attributes property to determine whether the FileSystemInfo represents a file or a directory. - /// - /// - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public FileSystemInfo[] GetFileSystemInfos() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).ToArray(); - } - - /// Retrieves an array of strongly typed objects representing the files and subdirectories that match the specified search criteria. - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// An array of strongly typed entries. - /// - /// For subdirectories, the objects returned by this method can be cast to the derived class . - /// Use the value returned by the property to determine whether the represents a file or a directory. - /// - /// - /// If there are no files or directories in the DirectoryInfo, this method returns an empty array. This method is not recursive. - /// For subdirectories, the FileSystemInfo objects returned by this method can be cast to the derived class DirectoryInfo. - /// Use the FileAttributes value returned by the Attributes property to determine whether the FileSystemInfo represents a file or a directory. - /// - /// - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public FileSystemInfo[] GetFileSystemInfos(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).ToArray(); - } - - /// Retrieves an array of strongly typed objects representing the files and subdirectories that match the specified search criteria. - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// An array of strongly typed entries. - /// - /// For subdirectories, the objects returned by this method can be cast to the derived class . - /// Use the value returned by the property to determine whether the represents a file or a directory. - /// - /// - /// If there are no files or directories in the DirectoryInfo, this method returns an empty array. This method is not recursive. - /// For subdirectories, the FileSystemInfo objects returned by this method can be cast to the derived class DirectoryInfo. - /// Use the FileAttributes value returned by the Attributes property to determine whether the FileSystemInfo represents a file or a directory. - /// - /// - /// - /// - /// - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Infos")] - [SecurityCritical] - public FileSystemInfo[] GetFileSystemInfos(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.FilesAndFolders | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath).ToArray(); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs deleted file mode 100644 index 1c5ce95..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.GetFiles.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Returns a file list from the current directory. - /// An array of type . - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// If there are no files in the , this method returns an empty array. - /// - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public FileInfo[] GetFiles() - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.Files, PathFormat.LongFullPath).ToArray(); - } - - /// Returns a file list from the current directory matching the given search pattern. - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// An array of type . - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// If there are no files in the , this method returns an empty array. - /// - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public FileInfo[] GetFiles(string searchPattern) - { - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, DirectoryEnumerationOptions.Files, PathFormat.LongFullPath).ToArray(); - } - - /// Returns a file list from the current directory matching the given search pattern and using a value to determine whether to search subdirectories. - /// - /// The search string to match against the names of directories in path. - /// This parameter can contain a combination of valid literal path and wildcard - /// ( and ) characters, but does not support regular expressions. - /// - /// - /// One of the enumeration values that specifies whether the - /// should include only the current directory or should include all subdirectories. - /// - /// An array of type . - /// The order of the returned file names is not guaranteed; use the Sort() method if a specific sort order is required. - /// If there are no files in the , this method returns an empty array. - /// - /// The EnumerateFiles and GetFiles methods differ as follows: When you use EnumerateFiles, you can start enumerating the collection of names - /// before the whole collection is returned; when you use GetFiles, you must wait for the whole array of names to be returned before you can access the array. - /// Therefore, when you are working with many files and directories, EnumerateFiles can be more efficient. - /// - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public FileInfo[] GetFiles(string searchPattern, SearchOption searchOption) - { - var options = DirectoryEnumerationOptions.Files | ((searchOption == SearchOption.AllDirectories) ? DirectoryEnumerationOptions.Recursive : 0); - - return Directory.EnumerateFileSystemEntryInfosCore(Transaction, LongFullName, searchPattern, options, PathFormat.LongFullPath).ToArray(); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Refresh.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Refresh.cs deleted file mode 100644 index 90bc626..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Refresh.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region .NET - - /// Refreshes the state of the object. - [SecurityCritical] - public new void Refresh() - { - base.Refresh(); - } - - #endregion // .NET - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.RefreshEntryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.RefreshEntryInfo.cs deleted file mode 100644 index e50d1d0..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.RefreshEntryInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - #region AlphaFS - - /// Refreshes the state of the EntryInfo instance. - [SecurityCritical] - public new void RefreshEntryInfo() - { - base.RefreshEntryInfo(); - } - - #endregion // AlphaFS - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.SetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.SetAccessControl.cs deleted file mode 100644 index 8bc5686..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.SetAccessControl.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - /// Applies access control list (ACL) entries described by a object to the directory described by the current DirectoryInfo object. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void SetAccessControl(DirectorySecurity directorySecurity) - { - File.SetAccessControlCore(LongFullName, null, directorySecurity, AccessControlSections.All, PathFormat.LongFullPath); - } - - /// Applies access control list (ACL) entries described by a object to the directory described by the current DirectoryInfo object. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void SetAccessControl(DirectorySecurity directorySecurity, AccessControlSections includeSections) - { - File.SetAccessControlCore(LongFullName, null, directorySecurity, includeSections, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.ToString.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.ToString.cs deleted file mode 100644 index 7e4b33a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.ToString.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - partial class DirectoryInfo - { - /// Returns the original path that was passed by the user. - /// A string that represents this object. - public override string ToString() - { - return DisplayPath; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.cs deleted file mode 100644 index d784bc1..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.cs +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Exposes instance methods for creating, moving, and enumerating through directories and subdirectories. This class cannot be inherited. - [SerializableAttribute] - public sealed partial class DirectoryInfo : FileSystemInfo - { - #region Constructors - - #region .NET - - /// Initializes a new instance of the class on the specified path. - /// The path on which to create the . - /// - /// This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations. - /// The path parameter can be a file name, including a file on a Universal Naming Convention (UNC) share. - /// - public DirectoryInfo(string path) : this(null, path, PathFormat.RelativePath) - { - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Initializes a new instance of the class on the specified path. - /// The path on which to create the . - /// Indicates the format of the path parameter(s). - /// This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations. - public DirectoryInfo(string path, PathFormat pathFormat) : this(null, path, pathFormat) - { - } - - /// [AlphaFS] Special internal implementation. - /// The transaction. - /// The full path on which to create the . - /// Not used. - /// Not used. - /// This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations. - [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "junk1")] - [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "junk2")] - private DirectoryInfo(KernelTransaction transaction, string fullPath, bool junk1, bool junk2) - { - IsDirectory = true; - Transaction = transaction; - - LongFullName = Path.GetLongPathCore(fullPath, GetFullPathOptions.None); - - OriginalPath = Path.GetFileName(fullPath, true); - - FullPath = fullPath; - - DisplayPath = OriginalPath.Length != 2 || OriginalPath[1] != Path.VolumeSeparatorChar ? OriginalPath : Path.CurrentDirectoryPrefix; - } - - #region Transactional - - /// [AlphaFS] Initializes a new instance of the class on the specified path. - /// The transaction. - /// The path on which to create the . - /// This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations. - public DirectoryInfo(KernelTransaction transaction, string path) : this(transaction, path, PathFormat.RelativePath) - { - } - - /// [AlphaFS] Initializes a new instance of the class on the specified path. - /// The transaction. - /// The path on which to create the . - /// Indicates the format of the path parameter(s). - /// This constructor does not check if a directory exists. This constructor is a placeholder for a string that is used to access the disk in subsequent operations. - public DirectoryInfo(KernelTransaction transaction, string path, PathFormat pathFormat) - { - InitializeCore(true, transaction, path, pathFormat); - } - - #endregion // Transactional - - #endregion // AlphaFS - - #endregion // Constructors - - #region Properties - - #region .NET - - #region Exists - - /// Gets a value indicating whether the directory exists. - /// - /// The property returns if any error occurs while trying to determine if the - /// specified directory exists. - /// This can occur in situations that raise exceptions such as passing a directory name with invalid characters or too many - /// characters, - /// a failing or missing disk, or if the caller does not have permission to read the directory. - /// - /// if the directory exists; otherwise, . - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public override bool Exists - { - [SecurityCritical] - get - { - try - { - if (DataInitialised == -1) - Refresh(); - - FileAttributes attrs = Win32AttributeData.dwFileAttributes; - return DataInitialised == 0 && attrs != (FileAttributes) (-1) && (attrs & FileAttributes.Directory) != 0; - } - catch - { - return false; - } - } - } - - #endregion // Exists - - #region Name - - /// Gets the name of this instance. - /// The directory name. - /// - /// This Name property returns only the name of the directory, such as "Bin". - /// To get the full path, such as "c:\public\Bin", use the FullName property. - /// - public override string Name - { - get - { - // GetDirName() - return FullPath.Length > 3 - ? Path.GetFileName(Path.RemoveTrailingDirectorySeparator(FullPath, false), true) - : FullPath; - } - } - - #endregion // Name - - #region Parent - - /// Gets the parent directory of a specified subdirectory. - /// The parent directory, or null if the path is null or if the file path denotes a root (such as "\", "C:", or * "\\server\share"). - public DirectoryInfo Parent - { - [SecurityCritical] - get - { - string path = FullPath; - - if (path.Length > 3) - path = Path.RemoveTrailingDirectorySeparator(FullPath, false); - - string dirName = Path.GetDirectoryName(path, false); - return dirName == null ? null : new DirectoryInfo(Transaction, dirName, true, true); - } - } - - #endregion // Parent - - #region Root - - /// Gets the root portion of the directory. - /// An object that represents the root of the directory. - public DirectoryInfo Root - { - [SecurityCritical] - get { return new DirectoryInfo(Transaction, Path.GetPathRoot(FullPath, false), PathFormat.RelativePath); } - } - - #endregion // Root - - #endregion // .NET - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DiskSpaceInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DiskSpaceInfo.cs deleted file mode 100644 index 619673e..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DiskSpaceInfo.cs +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, - /// the total amount of free space, and the total amount of free space available to the user that is associated with the calling thread. - /// This class cannot be inherited. - /// - [SerializableAttribute] - [SecurityCritical] - public sealed class DiskSpaceInfo - { - #region Constructor - - /// Initializes a DiskSpaceInfo instance. - /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share - /// This is a Lazyloading object; call to populate all properties first before accessing. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public DiskSpaceInfo(string drivePath) - { - if (Utils.IsNullOrWhiteSpace(drivePath)) - throw new ArgumentNullException("drivePath"); - - if (drivePath.Length == 1) - DriveName += Path.VolumeSeparatorChar; - else - DriveName = Path.GetPathRoot(drivePath, false); - - if (Utils.IsNullOrWhiteSpace(DriveName)) - throw new ArgumentException("Argument must be a drive letter (\"C\"), RootDir (\"C:\\\") or UNC path (\"\\\\server\\share\")"); - - // MSDN: - // If this parameter is a UNC name, it must include a trailing backslash (for example, "\\MyServer\MyShare\"). - // Furthermore, a drive specification must have a trailing backslash (for example, "C:\"). - // The calling application must have FILE_LIST_DIRECTORY access rights for this directory. - DriveName = Path.AddTrailingDirectorySeparator(DriveName, false); - } - - /// Initializes a DiskSpaceInfo instance. - /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share - /// gets both size- and disk cluster information. Get only disk cluster information, Get only size information. - /// Refreshes the state of the object. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public DiskSpaceInfo(string drivePath, bool? spaceInfoType, bool refresh, bool continueOnException) : this(drivePath) - { - if (spaceInfoType == null) - _initGetSpaceInfo = _initGetClusterInfo = true; - - else - { - _initGetSpaceInfo = (bool) !spaceInfoType; - _initGetClusterInfo = (bool) spaceInfoType; - } - - _continueOnAccessError = continueOnException; - - if (refresh) - Refresh(); - } - - #endregion // Constructor - - #region Fields - - private readonly bool _initGetClusterInfo = true; - private readonly bool _initGetSpaceInfo = true; - private readonly bool _continueOnAccessError; - - #endregion // Fields - - #region Methods - - #region Refresh - - /// Refreshes the state of the object. - public void Refresh() - { - Reset(); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - int lastError = (int) Win32Errors.NO_ERROR; - - #region Get size information. - - if (_initGetSpaceInfo) - { - long freeBytesAvailable, totalNumberOfBytes, totalNumberOfFreeBytes; - - if (!NativeMethods.GetDiskFreeSpaceEx(DriveName, out freeBytesAvailable, out totalNumberOfBytes, out totalNumberOfFreeBytes)) - lastError = Marshal.GetLastWin32Error(); - - else - { - FreeBytesAvailable = freeBytesAvailable; - TotalNumberOfBytes = totalNumberOfBytes; - TotalNumberOfFreeBytes = totalNumberOfFreeBytes; - } - - if (!_continueOnAccessError && (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NOT_READY)) - NativeError.ThrowException(DriveName); - } - - #endregion // Get size information. - - #region Get cluster information. - - if (_initGetClusterInfo) - { - int sectorsPerCluster, bytesPerSector, numberOfFreeClusters; - uint totalNumberOfClusters; - - if (!NativeMethods.GetDiskFreeSpace(DriveName, out sectorsPerCluster, out bytesPerSector, out numberOfFreeClusters, out totalNumberOfClusters)) - lastError = Marshal.GetLastWin32Error(); - - else - { - BytesPerSector = bytesPerSector; - NumberOfFreeClusters = numberOfFreeClusters; - SectorsPerCluster = sectorsPerCluster; - TotalNumberOfClusters = totalNumberOfClusters; - } - - if (!_continueOnAccessError && (lastError != Win32Errors.NO_ERROR && lastError != Win32Errors.ERROR_NOT_READY)) - NativeError.ThrowException(DriveName); - } - - #endregion // Get cluster information. - } - } - - #endregion // Refresh - - #region Reset - - /// Initializes all properties to 0. - private void Reset() - { - if (_initGetSpaceInfo) - FreeBytesAvailable = TotalNumberOfBytes = TotalNumberOfFreeBytes = 0; - - if (_initGetClusterInfo) - { - BytesPerSector = NumberOfFreeClusters = SectorsPerCluster = 0; - TotalNumberOfClusters = 0; - } - } - - #endregion // Reset - - #region ToString - /// Returns the drive name. - /// A string that represents this object. - public override string ToString() - { - return DriveName; - } - - #endregion // ToString - - #endregion // Methods - - #region Properties - - /// Indicates the amount of available free space on a drive, formatted as percentage. - public string AvailableFreeSpacePercent - { - get - { - return string.Format(CultureInfo.CurrentCulture, "{0:0.00}%", Utils.PercentCalculate(TotalNumberOfBytes - (TotalNumberOfBytes - TotalNumberOfFreeBytes), 0, TotalNumberOfBytes)); - } - } - - /// Indicates the amount of available free space on a drive, formatted as a unit size. - public string AvailableFreeSpaceUnitSize - { - get { return Utils.UnitSizeToText(TotalNumberOfFreeBytes); } - } - - /// Returns the Clusters size. - public long ClusterSize - { - get { return SectorsPerCluster * BytesPerSector; } - } - - /// Gets the name of a drive. - /// The name of the drive. - /// This property is the name assigned to the drive, such as C:\ or E:\ - public string DriveName { get; private set; } - - /// The total number of bytes on a disk that are available to the user who is associated with the calling thread, formatted as a unit size. - public string TotalSizeUnitSize - { - get { return Utils.UnitSizeToText(TotalNumberOfBytes); } - } - - /// Indicates the amount of used space on a drive, formatted as percentage. - public string UsedSpacePercent - { - get - { - return string.Format(CultureInfo.CurrentCulture, "{0:0.00}%", Utils.PercentCalculate(TotalNumberOfBytes - FreeBytesAvailable, 0, TotalNumberOfBytes)); - } - } - - /// Indicates the amount of used space on a drive, formatted as a unit size. - public string UsedSpaceUnitSize - { - get { return Utils.UnitSizeToText(TotalNumberOfBytes - FreeBytesAvailable); } - } - - /// The total number of free bytes on a disk that are available to the user who is associated with the calling thread. - public long FreeBytesAvailable { get; private set; } - - /// The total number of bytes on a disk that are available to the user who is associated with the calling thread. - public long TotalNumberOfBytes { get; private set; } - - /// The total number of free bytes on a disk. - public long TotalNumberOfFreeBytes { get; private set; } - - /// The number of bytes per sector. - public int BytesPerSector { get; private set; } - - /// The total number of free clusters on the disk that are available to the user who is associated with the calling thread. - public int NumberOfFreeClusters { get; private set; } - - /// The number of sectors per cluster. - public int SectorsPerCluster { get; private set; } - - /// The total number of clusters on the disk that are available to the user who is associated with the calling thread. - /// If per-user disk quotas are in use, this value may be less than the total number of clusters on the disk. - /// - public long TotalNumberOfClusters { get; private set; } - - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/DriveInfo.cs b/FolderMonitor/AlphaFS/Filesystem/DriveInfo.cs deleted file mode 100644 index 6238c5c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/DriveInfo.cs +++ /dev/null @@ -1,422 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides access to information on a local or remote drive. - /// - /// This class models a drive and provides methods and properties to query for drive information. - /// Use DriveInfo to determine what drives are available, and what type of drives they are. - /// You can also query to determine the capacity and available free space on the drive. - /// - [Serializable] - [SecurityCritical] - public sealed class DriveInfo - { - #region Private Fields - - [NonSerialized] - private readonly VolumeInfo _volumeInfo; - - [NonSerialized] - private readonly DiskSpaceInfo _dsi; - - [NonSerialized] - private bool _initDsie; - - [NonSerialized] - private DriveType? _driveType; - - [NonSerialized] - private string _dosDeviceName; - - [NonSerialized] - private DirectoryInfo _rootDirectory; - - private readonly string _name; - - - #endregion - - #region Constructors - - /// Provides access to information on the specified drive. - /// - /// - /// - /// A valid drive path or drive letter. - /// This can be either uppercase or lowercase, - /// 'a' to 'z' or a network share in the format: \\server\share - /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public DriveInfo(string driveName) - { - if (Utils.IsNullOrWhiteSpace(driveName)) - throw new ArgumentNullException("driveName"); - - if (driveName.Length == 1) - _name += Path.VolumeSeparatorChar; - else - _name = Path.GetPathRoot(driveName, false); - - if (Utils.IsNullOrWhiteSpace(_name)) - throw new ArgumentException("Argument must be a drive letter (\"C\"), RootDir (\"C:\\\") or UNC path (\"\\\\server\\share\")"); - - // If an exception is thrown, the original drivePath is used. - _name = Path.AddTrailingDirectorySeparator(_name, false); - - - // Initiate VolumeInfo() lazyload instance. - _volumeInfo = new VolumeInfo(_name, false, true); - - // Initiate DiskSpaceInfo() lazyload instance. - _dsi = new DiskSpaceInfo(_name, null, false, true); - } - - #endregion // Constructors - - #region Properties - - /// Indicates the amount of available free space on a drive. - /// The amount of free space available on the drive, in bytes. - /// This property indicates the amount of free space available on the drive. Note that this number may be different from the number because this property takes into account disk quotas. - public long AvailableFreeSpace - { - get - { - GetDeviceInfo(3, 0); - return _dsi == null ? 0 : _dsi.FreeBytesAvailable; - } - } - - /// Gets the name of the file system, such as NTFS or FAT32. - /// Use DriveFormat to determine what formatting a drive uses. - public string DriveFormat - { - get { return (string)GetDeviceInfo(0, 1); } - } - - /// Gets the drive type. - /// One of the values. - /// - /// The DriveType property indicates whether a drive is any of: CDRom, Fixed, Unknown, Network, NoRootDirectory, - /// Ram, Removable, or Unknown. Values are listed in the enumeration. - /// - public DriveType DriveType - { - get { return (DriveType)GetDeviceInfo(2, 0); } - } - - /// Gets a value indicating whether a drive is ready. - /// if the drive is ready; otherwise, . - /// - /// IsReady indicates whether a drive is ready. For example, it indicates whether a CD is in a CD drive or whether - /// a removable storage device is ready for read/write operations. If you do not test whether a drive is ready, and - /// it is not ready, querying the drive using DriveInfo will raise an IOException. - /// - /// Do not rely on IsReady() to avoid catching exceptions from other members such as TotalSize, TotalFreeSpace, and DriveFormat. - /// Between the time that your code checks IsReady and then accesses one of the other properties - /// (even if the access occurs immediately after the check), a drive may have been disconnected or a disk may have been removed. - /// - public bool IsReady - { - get { return File.ExistsCore(true, null, Name, PathFormat.LongFullPath); } - } - - - /// Gets the name of the drive. - /// The name of the drive. - /// This property is the name assigned to the drive, such as C:\ or E:\ - public string Name - { - get { return _name; } - } - - /// Gets the root directory of a drive. - /// A DirectoryInfo object that contains the root directory of the drive. - public DirectoryInfo RootDirectory - { - get { return (DirectoryInfo)GetDeviceInfo(2, 1); } - } - - /// Gets the total amount of free space available on a drive. - /// The total free space available on a drive, in bytes. - /// This property indicates the total amount of free space available on the drive, not just what is available to the current user. - public long TotalFreeSpace - { - get - { - GetDeviceInfo(3, 0); - return _dsi == null ? 0 : _dsi.TotalNumberOfFreeBytes; - } - } - - /// Gets the total size of storage space on a drive. - /// The total size of the drive, in bytes. - /// This property indicates the total size of the drive in bytes, not just what is available to the current user. - public long TotalSize - { - get - { - GetDeviceInfo(3, 0); - return _dsi == null ? 0 : _dsi.TotalNumberOfBytes; - } - } - - /// Gets or sets the volume label of a drive. - /// The volume label. - /// - /// The label length is determined by the operating system. For example, NTFS allows a volume label - /// to be up to 32 characters long. Note that is a valid VolumeLabel. - /// - - public string VolumeLabel - { - get { return (string)GetDeviceInfo(0, 2); } - set { Volume.SetVolumeLabel(Name, value); } - } - - /// [AlphaFS] Returns the instance. - public DiskSpaceInfo DiskSpaceInfo - { - get - { - GetDeviceInfo(3, 0); - return _dsi; - } - } - - /// [AlphaFS] The MS-DOS device name. - public string DosDeviceName - { - get { return (string)GetDeviceInfo(1, 0); } - } - - /// [AlphaFS] Indicates if this drive is a SUBST.EXE / DefineDosDevice drive mapping. - public bool IsDosDeviceSubstitute - { - get { return !Utils.IsNullOrWhiteSpace(DosDeviceName) && DosDeviceName.StartsWith(Path.SubstitutePrefix, StringComparison.OrdinalIgnoreCase); } - } - - /// [AlphaFS] Indicates if this drive is a UNC path. - /// Only retrieve this information if we're dealing with a real network share mapping: http://alphafs.codeplex.com/discussions/316583 - public bool IsUnc - { - get { return !IsDosDeviceSubstitute && DriveType == DriveType.Network; } - } - - /// [AlphaFS] Determines whether the specified volume name is a defined volume on the current computer. - public bool IsVolume - { - get { return GetDeviceInfo(0, 0) != null; } - } - - /// [AlphaFS] Contains information about a file-system volume. - /// A VolumeInfo object that contains file-system volume information of the drive. - public VolumeInfo VolumeInfo - { - get { return (VolumeInfo)GetDeviceInfo(0, 0); } - } - - - #endregion // Properties - - #region Methods - - /// Retrieves the drive names of all logical drives on a computer. - /// An array of type that represents the logical drives on a computer. - - [SecurityCritical] - public static DriveInfo[] GetDrives() - { - return Directory.EnumerateLogicalDrivesCore(false, false).ToArray(); - } - - /// Returns a drive name as a string. - /// The name of the drive. - /// This method returns the Name property. - public override string ToString() - { - return _name; - } - - - /// [AlphaFS] Enumerates the drive names of all logical drives on a computer. - /// Retrieve logical drives as known by the Environment. - /// Retrieve only when accessible (IsReady) logical drives. - /// - /// An IEnumerable of type that represents - /// the logical drives on a computer. - /// - [SecurityCritical] - public static IEnumerable EnumerateDrives(bool fromEnvironment, bool isReady) - { - return Directory.EnumerateLogicalDrivesCore(fromEnvironment, isReady); - } - - - /// [AlphaFS] Gets the first available drive letter on the local system. - /// A drive letter as . When no drive letters are available, an exception is thrown. - /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function. - - public static char GetFreeDriveLetter() - { - return GetFreeDriveLetter(false); - } - - /// Gets an available drive letter on the local system. - /// When get the last available drive letter. When gets the first available drive letter. - /// A drive letter as . When no drive letters are available, an exception is thrown. - /// The letters "A" and "B" are reserved for floppy drives and will never be returned by this function. - - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SuppressMessage("Microsoft.Usage", "CA2201:DoNotRaiseReservedExceptionTypes")] - public static char GetFreeDriveLetter(bool getLastAvailable) - { - IEnumerable freeDriveLetters = "CDEFGHIJKLMNOPQRSTUVWXYZ".Except(Directory.EnumerateLogicalDrivesCore(false, false).Select(d => d.Name[0])); - - try - { - return getLastAvailable ? freeDriveLetters.Last() : freeDriveLetters.First(); - } - catch - { - throw new Exception("There are no drive letters available."); - } - } - - #endregion // Methods - - #region Private Methods - - /// Retrieves information about the file system and volume associated with the specified root file or directorystream. - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - private object GetDeviceInfo(int type, int mode) - { - try - { - switch (type) - { - #region Volume - - // VolumeInfo properties. - case 0: - if (Utils.IsNullOrWhiteSpace(_volumeInfo.FullPath)) - _volumeInfo.Refresh(); - - switch (mode) - { - case 0: - // IsVolume, VolumeInfo - return _volumeInfo; - - case 1: - // DriveFormat - return _volumeInfo == null ? DriveType.Unknown.ToString() : _volumeInfo.FileSystemName ?? DriveType.Unknown.ToString(); - - case 2: - // VolumeLabel - return _volumeInfo == null ? string.Empty : _volumeInfo.Name ?? string.Empty; - } - break; - - // Volume related. - case 1: - switch (mode) - { - case 0: - // DosDeviceName - - // Do not use ?? expression here. - if (_dosDeviceName == null) - _dosDeviceName = Volume.QueryDosDevice(Name).FirstOrDefault(); - - return _dosDeviceName; - } - break; - - #endregion // Volume - - #region Drive - - // Drive related. - case 2: - switch (mode) - { - case 0: - // DriveType - // Do not use ?? expression here. - if (_driveType == null) - _driveType = Volume.GetDriveType(Name); - - return _driveType; - - case 1: - // RootDirectory - - // Do not use ?? expression here. - if (_rootDirectory == null) - _rootDirectory = new DirectoryInfo(null, Name, PathFormat.RelativePath); - - return _rootDirectory; - } - break; - - // DiskSpaceInfo related. - case 3: - switch (mode) - { - case 0: - // AvailableFreeSpace, TotalFreeSpace, TotalSize, DiskSpaceInfo - if (!_initDsie) - { - _dsi.Refresh(); - _initDsie = true; - } - break; - } - break; - - #endregion // Drive - } - } - catch - { - } - - return type == 0 && mode > 0 ? string.Empty : null; - } - - - #endregion // Private - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/BackupStreamType.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/BackupStreamType.cs deleted file mode 100644 index 495f7e1..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/BackupStreamType.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The type of the data contained in the backup stream. - public enum BackupStreamType - { - /// This indicates an error. - None = 0, - - /// BACKUP_DATA - /// Standard data. This corresponds to the NTFS $DATA stream type on the default (unnamed) data stream. - /// - Data = 1, - - /// BACKUP_EA_DATA - /// Extended attribute data. This corresponds to the NTFS $EA stream type. - /// - ExtendedAttributesData = 2, - - /// BACKUP_SECURITY_DATA - /// Security descriptor data. - /// - SecurityData = 3, - - /// BACKUP_ALTERNATE_DATA - /// Alternative data streams. This corresponds to the NTFS $DATA stream type on a named data stream. - /// - AlternateData = 4, - - /// BACKUP_LINK - /// Hard link information. This corresponds to the NTFS $FILE_NAME stream type. - /// - Link = 5, - - /// BACKUP_PROPERTY_DATA - /// Property data. - /// - PropertyData = 6, - - /// BACKUP_OBJECT_ID - /// Objects identifiers. This corresponds to the NTFS $OBJECT_ID stream type. - /// - ObjectId = 7, - - /// BACKUP_REPARSE_DATA - /// Reparse points. This corresponds to the NTFS $REPARSE_POINT stream type. - /// - ReparseData = 8, - - /// BACKUP_SPARSE_BLOCK - /// Sparse file. This corresponds to the NTFS $DATA stream type for a sparse file. - /// - SparseBlock = 9, - - /// BACKUP_TXFS_DATA - /// Transactional NTFS (TxF) data stream. - /// - /// Windows Server 2003 and Windows XP: This value is not supported. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Txfs")] - TxfsData = 10 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressCallbackReason.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressCallbackReason.cs deleted file mode 100644 index 1664118..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressCallbackReason.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Used by CopyFileXxx and MoveFileXxx. The reason that was called. - public enum CopyMoveProgressCallbackReason - { - /// CALLBACK_CHUNK_FINISHED - /// Another part of the data file was copied. - /// - ChunkFinished = 0, - - /// CALLBACK_STREAM_SWITCH - /// Another stream was created and is about to be copied. This is the callback reason given when the callback routine is first invoked. - /// - StreamSwitch = 1 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressResult.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressResult.cs deleted file mode 100644 index 2d925d5..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyMoveProgressResult.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Used by CopyFileXxx and MoveFileXxx. The function should return one of the following values. - public enum CopyMoveProgressResult - { - /// PROGRESS_CONTINUE - /// Continue the copy/move operation. - /// - Continue = 0, - - /// PROGRESS_CANCEL - /// Cancel the copy/move operation and delete the destination file. - /// - Cancel = 1, - - /// PROGRESS_STOP - /// Stop the copy/move operation. It can be restarted at a later time. - /// - Stop = 2, - - /// PROGRESS_QUIET - /// Continue the copy/move operation, but stop invoking to report progress. - /// - Quiet = 3 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyOptions.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyOptions.cs deleted file mode 100644 index 1b2d066..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/CopyOptions.cs +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Flags that specify how a file or directory is to be copied. - [Flags] - public enum CopyOptions - { - /// No CopyOptions used, this allows overwriting the file. - None = 0, - - /// COPY_FILE_FAIL_IF_EXISTS - /// The copy operation fails immediately if the target file already exists. - /// - FailIfExists = 1, - - /// COPY_FILE_RESTARTABLE - /// - /// Progress of the copy is tracked in the target file in case the copy fails. The failed copy can be restarted at a later time by specifying the same values - /// forexisting file name and new file name as those used in the call that failed. This can significantly slow down the copy operation as the new file may be - /// flushed multiple times during the copy operation. - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Restartable")] - Restartable = 2, - - /// COPY_FILE_OPEN_SOURCE_FOR_WRITE - /// The file is copied and the original file is opened for write access. - /// - OpenSourceForWrite = 4, - - /// COPY_FILE_ALLOW_DECRYPTED_DESTINATION - /// An attempt to copy an encrypted file will succeed even if the destination copy cannot be encrypted. - /// - AllowDecryptedDestination = 8, - - /// COPY_FILE_COPY_SYMLINK - /// If the source file is a symbolic link, the destination file is also a symbolic link pointing to the same file that the source symbolic link is pointing to. - /// - CopySymbolicLink = 2048, - - /// COPY_FILE_NO_BUFFERING - /// The copy operation is performed using unbuffered I/O, bypassing system I/O cache resources. Recommended for very large file transfers. - /// - NoBuffering = 4096 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DeviceGuid.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/DeviceGuid.cs deleted file mode 100644 index 288e0ef..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DeviceGuid.cs +++ /dev/null @@ -1,200 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// System-Defined Device Interface Classes - /// http://msdn.microsoft.com/en-us/library/windows/hardware/ff541389%28v=vs.85%29.aspx - public enum DeviceGuid - { - #region 1394 and 61883 Devices - - /// The BUS1394_CLASS_GUID device interface class is defined for 1394 bus devices. - [Description("6BDD1FC1-810F-11d0-BEC7-08002BE2092F")] Bus1394, - - /// The GUID_61883_CLASS device interface class is defined for devices in the 61883 device setup class. - [Description("7EBEFBC0-3200-11d2-B4C2-00A0C9697D07")] Guid61883, - - #endregion // 1394 and 61883 Devices - - #region Battery and ACPI devices - - /// The GUID_DEVICE_APPLICATIONLAUNCH_BUTTON device interface class is defined for Advanced Configuration and Power Interface (ACPI) application start buttons. - [Description("629758EE-986E-4D9E-8E47-DE27F8AB054D")] ApplicationLaunchButton, - - /// The GUID_DEVICE_BATTERY device interface class is defined for battery devices. - [Description("72631E54-78A4-11D0-BCF7-00AA00B7B32A")] Battery, - - /// The GUID_DEVICE_LID device interface class is defined for Advanced Configuration and Power Interface (ACPI) lid devices. - [Description("4AFA3D52-74A7-11d0-be5e-00A0C9062857")] Lid, - - /// The GUID_DEVICE_MEMORY device interface class is defined for Advanced Configuration and Power Interface (ACPI) memory devices. - [Description("3FD0F03D-92E0-45FB-B75C-5ED8FFB01021")] Memory, - - /// The GUID_DEVICE_MESSAGE_INDICATOR device interface class is defined for Advanced Configuration and Power Interface (ACPI) message indicator devices. - [Description("CD48A365-FA94-4CE2-A232-A1B764E5D8B4")] MessageIndicator, - - /// The GUID_DEVICE_PROCESSOR device interface class is defined for Advanced Configuration and Power Interface (ACPI) processor devices. - [Description("97FADB10-4E33-40AE-359C-8BEF029DBDD0")] Processor, - - /// The GUID_DEVICE_SYS_BUTTON device interface classis defined for Advanced Configuration and Power Interface (ACPI) system power button devices. - [Description("4AFA3D53-74A7-11d0-be5e-00A0C9062857")] SysButton, - - /// The GUID_DEVICE_THERMAL_ZONE device interface class is defined for Advanced Configuration and Power Interface (ACPI) thermal zone devices. - [Description("4AFA3D51-74A7-11d0-be5e-00A0C9062857")] ThermalZone, - - #endregion // Battery and ACPI devices - - #region Bluetooth Devices - - /// The GUID_BTHPORT_DEVICE_INTERFACE device interface class is defined for Bluetooth radios. - [Description("0850302A-B344-4fda-9BE9-90576B8D46F0")] Bluetooth, - - #endregion // Bluetooth Devices - - #region Display and Image Devices - - /// The GUID_DEVINTERFACE_BRIGHTNESS device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and support brightness control of monitor child devices. - [Description("FDE5BBA4-B3F9-46FB-BDAA-0728CE3100B4")] Brightness, - - /// The GUID_DEVINTERFACE_DISPLAY_ADAPTER device interface class is defined for display views that are supported by display adapters. - [Description("5B45201D-F2F2-4F3B-85BB-30FF1F953599")] DisplayAdapter, - - /// The GUID_DEVINTERFACE_I2C device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and perform I2C transactions with monitor child devices. - [Description("2564AA4F-DDDB-4495-B497-6AD4A84163D7")] I2C, - - /// The GUID_DEVINTERFACE_IMAGE device interface class is defined for WIA devices and Still Image (STI) devices, including digital cameras and scanners. - [Description("6BDD1FC6-810F-11D0-BEC7-08002BE2092F")] StillImage, - - /// The GUID_DEVINTERFACE_MONITOR device interface class is defined for monitor devices. - [Description("E6F07B5F-EE97-4a90-B076-33F57BF4EAA7")] Monitor, - - /// The GUID_DEVINTERFACE_OPM device interface class is defined for display adapter drivers that operate in the context of the Windows Vista Display Driver Model and support output protection management (OPM) for monitor child devices. - [Description("BF4672DE-6B4E-4BE4-A325-68A91EA49C09")] OutputProtectionManagement, - - /// The GUID_DEVINTERFACE_VIDEO_OUTPUT_ARRIVAL device interface class is defined for child devices of display devices. - [Description("1AD9E4F0-F88D-4360-BAB9-4C2D55E564CD")] VideoOutputArrival, - - /// The GUID_DISPLAY_DEVICE_ARRIVAL device interface class is defined for display adapters. - [Description("1CA05180-A699-450A-9A0C-DE4FBE3DDD89")] DisplayDeviceArrival, - - #endregion // Display and Image Devices - - #region Interactive Input Devices - - /// The GUID_DEVINTERFACE_HID device interface class is defined for HID collections. - [Description("4D1E55B2-F16F-11CF-88CB-001111000030")] Hid, - - /// The GUID_DEVINTERFACE_KEYBOARD device interface class is defined for keyboard devices. - [Description("4D1E55B2-F16F-11CF-88CB-001111000030")] Keyboard, - - /// The GUID_DEVINTERFACE_MOUSE device interface class is defined for mouse devices. - [Description("378DE44C-56EF-11D1-BC8C-00A0C91405DD")] Mouse, - - #endregion // Interactive Input Devices - - #region Modem Devices - - /// The GUID_DEVINTERFACE_MODEM device interface class is defined for modem devices. - [Description("2C7089AA-2E0E-11D1-B114-00C04FC2AAE4")] Modem, - - #endregion // Modem Devices - - #region Network Devices - - /// The GUID_DEVINTERFACE_NET device interface class is defined for network devices. - [Description("CAC88484-7515-4C03-82E6-71A87ABAC361")] Network, - - #endregion // Network Devices - - #region Serial and Parallel Port Devices - - /// The GUID_DEVINTERFACE_COMPORT device interface class is defined for COM ports. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "ComPort")] - [Description("86E0D1E0-8089-11D0-9CE4-08003E301F73")] ComPort, - - /// The GUID_DEVINTERFACE_PARALLEL device interface class is defined for parallel ports that support an IEEE 1284-compatible hardware interface. - [Description("97F76EF0-F883-11D0-AF1F-0000F800845C")] Parallel, - - /// The GUID_DEVINTERFACE_PARCLASS device interface class is defined for devices that are attached to a parallel port. - [Description("811FC6A5-F728-11D0-A537-0000F8753ED1")] ParallelClass, - - /// The GUID_DEVINTERFACE_SERENUM_BUS_ENUMERATOR device interface class is defined for Plug and Play (PnP) serial ports. - [Description("4D36E978-E325-11CE-BFC1-08002BE10318")] SerialEnumBusEnumerator, - - #endregion // Serial and Parallel Port Devices - - #region Storage Devices - - /// The GUID_DEVINTERFACE_CDCHANGER device interface class is defined for CD-ROM changer devices. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cdrom")] - [Description("53F56312-B6BF-11D0-94F2-00A0C91EFB8B")] CdromChanger, - - /// The GUID_DEVINTERFACE_CDROM device interface class is defined for CD-ROM storage devices. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cdrom")] - [Description("53F56308-B6BF-11D0-94F2-00A0C91EFB8B")] Cdrom, - - /// The GUID_DEVINTERFACE_DISK device interface class is defined for hard disk storage devices. - [Description("53F56307-B6BF-11D0-94F2-00A0C91EFB8B")] Disk, - - /// The GUID_DEVINTERFACE_FLOPPY device interface class is defined for floppy disk storage devices. - [Description("53F56311-B6BF-11D0-94F2-00A0C91EFB8B")] Floppy, - - /// The GUID_DEVINTERFACE_MEDIUMCHANGER device interface class is defined for medium changer devices. - [Description("53F56310-B6BF-11D0-94F2-00A0C91EFB8B")] MediumChanger, - - /// The GUID_DEVINTERFACE_PARTITION device interface class is defined for partition devices. - [Description("53F5630A-B6BF-11D0-94F2-00A0C91EFB8B")] Partition, - - /// The GUID_DEVINTERFACE_STORAGEPORT device interface class is defined for storage port devices. - [Description("2ACCFE60-C130-11D2-B082-00A0C91EFB8B")] StoragePort, - - /// The GUID_DEVINTERFACE_TAPE device interface class is defined for tape storage devices. - [Description("53F5630B-B6BF-11D0-94F2-00A0C91EFB8B")] Tape, - - /// The GUID_DEVINTERFACE_VOLUME device interface class is defined for volume devices. - [Description("53F5630D-B6BF-11D0-94F2-00A0C91EFB8B")] Volume, - - /// The GUID_DEVINTERFACE_WRITEONCEDISK device interface class is defined for write-once disk devices. - [Description("53F5630C-B6BF-11D0-94F2-00A0C91EFB8B")] WriteOnceDisk, - - #endregion // Storage Devices - - #region USB Devices - - /// The GUID_DEVINTERFACE_USB_DEVICE device interface class is defined for USB devices that are attached to a USB hub. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")] - [Description("A5DCBF10-6530-11D2-901F-00C04FB951ED")] UsbDevice, - - /// The GUID_DEVINTERFACE_USB_HOST_CONTROLLER device interface class is defined for USB host controller devices. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")] - [Description("3ABF6F2D-71C4-462A-8A92-1E6861E6AF27")] UsbHostController, - - /// The GUID_DEVINTERFACE_USB_HUB device interface class is defined for USB hub devices. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usb")] - [Description("F18A0E88-C30C-11D0-8815-00A0C906BED8")] UsbHub - - #endregion // USB Devices - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DiGetClassFlags.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/DiGetClassFlags.cs deleted file mode 100644 index 416cd9e..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DiGetClassFlags.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Specifies control options that filter the device information elements that are added to the device information set. - [Flags] - internal enum SetupDiGetClassDevsExFlags - { - /// DIGCF_DEFAULT - /// Return only the device that is associated with the system default device interface, if one is set, for the specified device interface classes. - /// - Default = 1, // only valid with DIGCF_DEVICEINTERFACE - - /// DIGCF_PRESENT - /// Return only devices that are currently present. - /// - Present = 2, - - /// DIGCF_ALLCLASSES - /// Return a list of installed devices for the specified device setup classes or device interface classes. - /// - AllClasses = 4, - - /// DIGCF_PROFILE - /// Return only devices that are a part of the current hardware profile. - /// - Profile = 8, - - /// DIGCF_DEVICEINTERFACE - /// - /// Return devices that support device interfaces for the specified device interface classes. - /// This flag must be set in the Flags parameter if the Enumerator parameter specifies a Device Instance ID. - /// - /// - DeviceInterface = 16 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DirectoryEnumerationOptions.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/DirectoryEnumerationOptions.cs deleted file mode 100644 index fd9ce87..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DirectoryEnumerationOptions.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - /// [AlphaFS] Directory enumeration options, flags that specify how a directory is to be enumerated. - [Flags] - public enum DirectoryEnumerationOptions - { - /// None (do not use). - None = 0, - - /// Enumerate files only. - Files = 1, - - /// Enumerate directories only. - Folders = 2, - - /// Enumerate files and directories. - FilesAndFolders = Files | Folders, - - /// Return full path as long full path (Unicode format), only valid when return type is . - AsLongPath = 4, - - /// Skip reparse points during directory enumeration. - SkipReparsePoints = 8, - - /// Suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or non-accessible reparse points. - ContinueOnException = 16, - - /// Specifies whether to search the current directory, or the current directory and all subdirectories. - Recursive = 32, - - /// Enumerates the directory without querying the short file name, improving overall enumeration speed. - /// This option is enabled by default if supported. This value is not supported until Windows Server 2008 R2 and Windows 7. - BasicSearch = 64, - - /// Enumerates the directory using a larger buffer for directory queries, which can increase performance of the find operation. - /// This option is enabled by default if supported. This value is not supported until Windows Server 2008 R2 and Windows 7. - LargeCache = 128 - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DosDeviceAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/DosDeviceAttributes.cs deleted file mode 100644 index b3b58f3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/DosDeviceAttributes.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Defines the controllable aspects of the Volume.DefineDosDevice() method. - [Flags] - public enum DosDeviceAttributes - { - /// DDD_EXACT_MATCH_ON_REMOVE - /// Default. - /// - None = 0, - - /// DDD_RAW_TARGET_PATH - /// Uses the targetPath string as is. Otherwise, it is converted from an MS-DOS path to a path. - /// - RawTargetPath = 1, - - /// DDD_REMOVE_DEFINITION - /// Removes the specified definition for the specified device. - /// To determine which definition to remove, the function walks the list of mappings for the device, looking for a match of targetPath against a prefix of each mapping associated with this device. - /// The first mapping that matches is the one removed, and then the function returns. - /// If targetPath is null or a pointer to a null string, the function will remove the first mapping associated with the device and pop the most recent one pushed.If there is nothing left to pop, the device name will be removed. - /// If this value is not specified, the string pointed to by the targetPath parameter will become the new mapping for this device. - /// - RemoveDefinition = 2, - - /// DDD_EXACT_MATCH_ON_REMOVE - /// If this value is specified along with , the function will use an exact match to determine which mapping to remove. - /// Use this value to ensure that you do not delete something that you did not define. - /// - ExactMatchOnRemove = 4, - - /// DDD_NO_BROADCAST_SYSTEM - /// Do not broadcast the WM_SETTINGCHANGE message. - /// By default, this message is broadcast to notify the shell and applications of the change. - /// - NoBroadcastSystem = 8 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/EncryptedFileRawMode.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/EncryptedFileRawMode.cs deleted file mode 100644 index a75e013..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/EncryptedFileRawMode.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class NativeMethods - { - /// Indicates the operation to be performed when opening a file using the OpenEncryptedFileRaw. - [Flags] - internal enum EncryptedFileRawMode - { - /// (0) Open the file for export (backup). - CreateForExport = 0, - - /// (1) The file is being opened for import (restore). - CreateForImport = 1, - - /// (2) Import (restore) a directory containing encrypted files. This must be combined with one of the previous two flags to indicate the operation. - CreateForDir = 2, - - /// (4) Overwrite a hidden file on import. - OverwriteHidden = 4 - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ErrorMode.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/ErrorMode.cs deleted file mode 100644 index 44a6aa3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ErrorMode.cs +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Enum for struct ChangeErrorMode. - [Flags] - internal enum ErrorMode - { - /// Use the system default, which is to display all error dialog boxes. - SystemDefault = 0, - - /// The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process/thread. - FailCriticalErrors = 1, - - /// The system does not display the Windows Error Reporting dialog. - NoGpfaultErrorbox = 2, - - /// The system automatically fixes memory alignment faults and makes them invisible to the application. It does this for the calling process and any descendant processes. This feature is only supported by certain processor architectures. - NoAlignmentFaultExcept = 4, - - /// The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process/thread. - NoOpenFileErrorbox = 32768 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ExtendedFileAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/ExtendedFileAttributes.cs deleted file mode 100644 index 0828647..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ExtendedFileAttributes.cs +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Specifies how the operating system should open a file. - [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")] - [Flags] - public enum ExtendedFileAttributes - { - /// If you pass , the set of attributes is unspecified. explicitly sets no attributes. - None = 0, - - #region FILE_ATTRIBUTE - Attributes applying to any file - - /// The file is read only. Applications can read the file, but cannot write to or delete it. - /// Equals 1 - ReadOnly = FileAttributes.ReadOnly, - - /// The file is hidden. Do not include it in an ordinary directory listing. - /// Equals 2 - Hidden = FileAttributes.Hidden, - - /// The file is part of or used exclusively by an operating system. - /// Equals 4 - System = FileAttributes.System, - - /// The handle that identifies a directory. - /// Equals 16 - Directory = FileAttributes.Directory, - - /// The file should be archived. Applications use this attribute to mark files for backup or removal. - /// Equals 32 - Archive = FileAttributes.Archive, - - /// The file should be archived. Applications use this attribute to mark files for backup or removal. - /// Equals 64 - Device = FileAttributes.Device, - - /// The file does not have other attributes set. This attribute is valid only if used alone. - /// Equals 128 - Normal = FileAttributes.Normal, - - /// The file is being used for temporary storage. - /// Equals 256 - Temporary = FileAttributes.Temporary, - - /// A file that is a sparse file. - /// Equals 512 - SparseFile = FileAttributes.SparseFile, - - /// A file or directory that has an associated reparse point, or a file that is a symbolic link. - /// Equals 1024 - ReparsePoint = FileAttributes.ReparsePoint, - - /// A file or directory that is compressed. For a file, all of the data in the file is compressed. For a directory, compression is the default for newly created files and subdirectories. - /// Equals 2048 - Compressed = FileAttributes.Compressed, - - /// The data of a file is not immediately available. This attribute indicates that file data is physically moved to offline storage. This attribute is used by Remote Storage, the hierarchical storage management software. Applications should not arbitrarily change this attribute. - /// Equals 4096 - Offline = FileAttributes.Offline, - - /// The file or directory is not to be indexed by the content indexing service. - /// Equals 8192 - NotContentIndexed = FileAttributes.NotContentIndexed, - - /// The file or directory is encrypted. For a file, this means that all data in the file is encrypted. For a directory, this means that encryption is the default for newly created files and subdirectories. - /// Equals 16384 - Encrypted = FileOptions.Encrypted, - - #endregion // FILE_ATTRIBUTE - Attributes applying to any file - - /// The directory or user data stream is configured with integrity (only supported on ReFS volumes). It is not included in an ordinary directory listing. The integrity setting persists with the file if it's renamed. If a file is copied the destination file will have integrity set if either the source file or destination directory have integrity set. - /// This flag is not supported until Windows Server 2012. - IntegrityStream = 32768, - - /// The user data stream not to be read by the background data integrity scanner (AKA scrubber). When set on a directory it only provides inheritance. This flag is only supported on Storage Spaces and ReFS volumes. It is not included in an ordinary directory listing. - /// This flag is not supported until Windows Server 2012. - NoScrubData = 131072, - - /// ... - FirstPipeInstance = 524288, - - /// The file data is requested, but it should continue to be located in remote storage. It should not be transported back to local storage. This flag is for use by remote storage systems. - OpenNoRecall = 1048576, - - /// Normal reparse point processing will not occur; an attempt to open the reparse point will be made. When a file is opened, a file handle is returned, whether or not the filter that controls the reparse point is operational. See MSDN documentation for more information. - OpenReparsePoint = 2097152, - - /// Access will occur according to POSIX rules. This includes allowing multiple files with names, differing only in case, for file systems that support that naming. Use care when using this option, because files created with this flag may not be accessible by applications that are written for MS-DOS or 16-bit Windows. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Posix")] - PosixSemantics = 16777216, - - /// The file is being opened or created for a backup or restore operation. The system ensures that the calling process overrides file security checks when the process has SE_BACKUP_NAME and SE_RESTORE_NAME privileges. You must set this flag to obtain a handle to a directory. A directory handle can be passed to some functions instead of a file handle. - BackupSemantics = 33554432, - - /// The file is to be deleted immediately after all of its handles are closed, which includes the specified handle and any other open or duplicated handles. If there are existing open handles to a file, the call fails unless they were all opened with the share mode. Subsequent open requests for the file fail, unless the share mode is specified. - /// Equals 67108864 - DeleteOnClose = FileOptions.DeleteOnClose, - - /// Access is intended to be sequential from beginning to end. The system can use this as a hint to optimize file caching. - /// Equals 134217728 - SequentialScan = FileOptions.SequentialScan, - - /// Access is intended to be random. The system can use this as a hint to optimize file caching. - /// Equals 268435456 - RandomAccess = FileOptions.RandomAccess, - - /// There are strict requirements for successfully working with files opened with the flag, for details see the section on "File Buffering" in the online MSDN documentation. - NoBuffering = 536870912, - - /// The file or device is being opened or created for asynchronous I/O. - /// Equals 1073741824 - Overlapped = FileOptions.Asynchronous, - - /// Write operations will not go through any intermediate cache, they will go directly to disk. - /// Equals .NET -2147483648 - WriteThrough = FileOptions.WriteThrough - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FINDEX_INFO_LEVELS.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FINDEX_INFO_LEVELS.cs deleted file mode 100644 index 40bf4b4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FINDEX_INFO_LEVELS.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// FINDEX_INFO_LEVELS Enumeration - Defines values that are used with the FindFirstFileEx function to specify the information level of the returned data. - /// - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - internal enum FINDEX_INFO_LEVELS - { - /// A standard set of attribute is returned in a structure. - Standard = 0, - - /// The FindFirstFileEx function does not query the short file name, improving overall enumeration speed. - /// This value is not supported until Windows Server 2008 R2 and Windows 7. - Basic = 1 - - ///// This value is used for validation. Supported values are less than this value. - //MaxLevel - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileEncryptionStatus.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileEncryptionStatus.cs deleted file mode 100644 index 158c8ec..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileEncryptionStatus.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents the encryption status of the specified file. - public enum FileEncryptionStatus - { - /// The file can be encrypted. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Encryptable")] - Encryptable = 0, - - /// The file is encrypted. - Encrypted = 1, - - /// The file is a system file. System files cannot be encrypted. - SystemFile = 2, - - /// The file is a root directory. Root directories cannot be encrypted. - RootDirectory = 3, - - /// The file is a system directory. System directories cannot be encrypted. - SystemDirectory = 4, - - /// The encryption status is unknown. The file may be encrypted. - Unknown = 5, - - /// The file system does not support file encryption. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Filesystem")] - NoFilesystemSupport = 6, - - /// Reserved for future use. - UserDisallowed = 7, - - /// The file is a read-only file. - ReadOnly = 8 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileInfoByHandleClass.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileInfoByHandleClass.cs deleted file mode 100644 index d52969f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FileInfoByHandleClass.cs +++ /dev/null @@ -1,270 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// FILE_INFO_BY_HANDLE_CLASS - /// Identifies the type of file information that GetFileInformationByHandleEx should retrieve or SetFileInformationByHandle should set. - /// - internal enum FileInfoByHandleClass - { - #region FILE_BASIC_INFO - - /// FILE_BASIC_INFO - /// Minimal information for the file should be retrieved or set. Used for file handles. - /// - FileBasicInfo = 0, - - #endregion // FILE_BASIC_INFO - - #region FILE_STANDARD_INFO - - ///// FILE_STANDARD_INFO - ///// Extended information for the file should be retrieved. Used for file handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileStandardInfo = 1, - - #endregion // FILE_STANDARD_INFO - - #region FILE_NAME_INFO - - ///// FILE_NAME_INFO - ///// The file name should be retrieved. Used for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileNameInfo = 2, - - #endregion // FILE_NAME_INFO - - #region FILE_RENAME_INFO - - ///// FILE_RENAME_INFO - ///// The file name should be changed. Used for file handles. - ///// Use only when calling . - ///// - //FileRenameInfo = 3, - - #endregion // FILE_RENAME_INFO - - #region FILE_DISPOSITION_INFO - - ///// FILE_DISPOSITION_INFO - ///// The file should be deleted. Used for any handles. - ///// Use only when calling . - ///// - //FileDispositionInfo = 4, - - #endregion // FILE_DISPOSITION_INFO - - #region FILE_ALLOCATION_INFO - - ///// FILE_ALLOCATION_INFO - ///// The file allocation information should be changed. Used for file handles. - ///// Use only when calling . - ///// - //FileAllocationInfo = 5, - - #endregion // FILE_ALLOCATION_INFO - - #region FILE_END_OF_FILE_INFO - - ///// FILE_END_OF_FILE_INFO - ///// The end of the file should be set. Use only when calling . - ///// - //FileEndOfFileInfo = 6, - - #endregion // FILE_END_OF_FILE_INFO - - #region FILE_STREAM_INFO - - ///// FILE_STREAM_INFO - ///// File stream information for the specified file should be retrieved. Used for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileStreamInfo = 7, - - #endregion // FILE_STREAM_INFO - - #region FILE_COMPRESSION_INFO - - ///// FILE_COMPRESSION_INFO - ///// File compression information should be retrieved. Used for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileCompressionInfo = 8, - - #endregion // FILE_COMPRESSION_INFO - - #region FILE_ATTRIBUTE_TAG_INFO - - ///// FILE_ATTRIBUTE_TAG_INFO - ///// File attribute information should be retrieved. Used for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileAttributeTagInfo = 9, - - #endregion // FILE_ATTRIBUTE_TAG_INFO - - #region FILE_ID_BOTH_DIR_INFO - - /// FILE_ID_BOTH_DIR_INFO - /// Files in the specified directory should be retrieved. Used for directory handles. - /// Use only when calling GetFileInformationByHandleEx. - /// - /// The number of files returned for each call to GetFileInformationByHandleEx - /// depends on the size of the buffer that is passed to the function. - /// Any subsequent calls to GetFileInformationByHandleEx on the same handle - /// will resume the enumeration operation after the last file is returned. - /// - /// - FileIdBothDirectoryInfo = 10 - - #endregion // FILE_ID_BOTH_DIR_INFO - - #region FILE_ID_BOTH_DIR_INFO - - ///// FILE_ID_BOTH_DIR_INFO - ///// Identical to , but forces the enumeration operation to start again from the beginning. - ///// - //FileIdBothDirectoryInfoRestartInfo = 11, - - #endregion // FILE_ID_BOTH_DIR_INFO - - #region FILE_IO_PRIORITY_HINT_INFO - - ///// FILE_IO_PRIORITY_HINT_INFO - ///// Priority hint information should be set.Use only when calling . - ///// - //FileIoPriorityHintInfo = 12, - - #endregion // FILE_IO_PRIORITY_HINT_INFO - - #region FILE_REMOTE_PROTOCOL_INFO - - ///// (13) FILE_REMOTE_PROTOCOL_INFO - ///// File remote protocol information should be retrieved.Use for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - //FileRemoteProtocolInfo = 13, - - #endregion // FILE_REMOTE_PROTOCOL_INFO - - #region FILE_FULL_DIR_INFO - - ///// (14) FILE_FULL_DIR_INFO - ///// Files in the specified directory should be retrieved. Used for directory handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileFullDirectoryInfo = 14, - - #endregion // FILE_FULL_DIR_INFO - - #region FILE_FULL_DIR_INFO - - ///// FILE_FULL_DIR_INFO - ///// Identical to , but forces the enumeration operation to start again from the beginning. Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileFullDirectoryRestartInfo = 15, - - #endregion // FILE_FULL_DIR_INFO - - #region FILE_STORAGE_INFO - - ///// FILE_STORAGE_INFO - ///// File storage information should be retrieved. Use for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileStorageInfo = 16, - - #endregion // FILE_STORAGE_INFO - - #region FILE_ALIGNMENT_INFO - - ///// FILE_ALIGNMENT_INFO - ///// File alignment information should be retrieved. Use for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileAlignmentInfo = 17, - - #endregion FILE_ALIGNMENT_INFO - - #region FILE_ID_INFO - - ///// FILE_ID_INFO - ///// File information should be retrieved. Use for any handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileIdInfo = 18, - - #endregion // FILE_ID_INFO - - #region FILE_ID_EXTD_DIR_INFO - - ///// FILE_ID_EXTD_DIR_INFO - ///// Files in the specified directory should be retrieved. Used for directory handles. - ///// Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileIdExtdDirectoryInfo = 19, - - #endregion // FILE_ID_EXTD_DIR_INFO - - #region FILE_ID_EXTD_DIR_INFO - - ///// FILE_ID_EXTD_DIR_INFO - ///// Identical to , but forces the enumeration operation to start again from the beginning. Use only when calling GetFileInformationByHandleEx. - ///// - ///// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - ///// This value is not supported before Windows 8 and Windows Server 2012 - ///// - ///// - //FileIdExtdDirectoryRestartInfo = 20 - - #endregion // FILE_ID_EXTD_DIR_INFO - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FinalPathFormats.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FinalPathFormats.cs deleted file mode 100644 index 8e5feea..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FinalPathFormats.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Determines the format to convert a path to using - [Flags] - public enum FinalPathFormats - { - /// (FileNameNormalized / VolumeNameDos) Return the normalized drive name. This is the default. - None = 0, - - /// Return the path with a volume GUID path instead of the drive name. - VolumeNameGuid = 1, - - /// Return the path with the volume device path. - VolumeNameNT = 2, - - /// Return the path with no drive information. - VolumeNameNone = 4, - - /// Return the opened file name (not normalized). - FileNameOpened = 8 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExAdditionalFlags.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExAdditionalFlags.cs deleted file mode 100644 index 3b7cdf4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExAdditionalFlags.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Additional flags that control the search. - [Flags] - internal enum FindExAdditionalFlags - { - /// No additional flags used. - None = 0, - - /// Searches are case-sensitive. - CaseSensitive = 1, - - /// Uses a larger buffer for directory queries, which can increase performance of the find operation. - /// This value is not supported until Windows Server 2008 R2 and Windows 7. - LargeFetch = 2 - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExSearchOps.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExSearchOps.cs deleted file mode 100644 index c1eda52..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/FindExSearchOps.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// FINDEX_SEARCH_OPS Enumeration - Defines values that are used with the FindFirstFileEx function to specify the type of filtering to perform. - /// - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - internal enum FINDEX_SEARCH_OPS - { - /// The search for a file that matches a specified file name. - /// The lpSearchFilter parameter of FindFirstFileEx must be NULL when this search operation is used. - /// - SearchNameMatch = 0, - - /// This is an advisory flag. If the file system supports directory filtering, - /// the function searches for a file that matches the specified name and is also a directory. - /// If the file system does not support directory filtering, this flag is silently ignored. - ///   - /// - /// The lpSearchFilter parameter of the FindFirstFileEx function must be NULL when this search value is used. - /// If directory filtering is desired, this flag can be used on all file systems, - /// but because it is an advisory flag and only affects file systems that support it, - /// the application must examine the file attribute data stored in the lpFindFileData parameter - /// of the FindFirstFileEx function to determine whether the function has returned a handle to a directory. - /// - /// - SearchLimitToDirectories = 1, - - /// This filtering type is not available. - /// For more information, see Device Interface Classes. - SearchLimitToDevices = 2 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFileExInfoLevels.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFileExInfoLevels.cs deleted file mode 100644 index 4eb25a6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFileExInfoLevels.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Defines values that are used with the GetFileAttributesEx and GetFileAttributesTransacted functions to specify the information level of the returned data. - public enum GetFileExInfoLevels - { - /// The GetFileAttributesEx or GetFileAttributesTransacted function retrieves a standard set of attribute information. The data is returned in a WIN32_FILE_ATTRIBUTE_DATA structure. - GetFileExInfoStandard = 0 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFullPathOptions.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFullPathOptions.cs deleted file mode 100644 index ec6999c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/GetFullPathOptions.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - /// A bitfield of flags for specifying options for various internal operations that convert paths to full paths. - [Flags] - public enum GetFullPathOptions - { - /// No special options applies. - None = 0, - - /// Remove any trailing whitespace from the path. - TrimEnd = 1, - - /// Add a trailing directory separator to the path (if one does not already exist). - AddTrailingDirectorySeparator = 2, - - /// Remove the trailing directory separator from the path (if one exists). - RemoveTrailingDirectorySeparator = 4, - - /// Return full path as long full path (Unicode format). Not valid for . - AsLongPath = 8, - - /// Prevents any exception from being thrown if a filesystem object does not exist. Not valid for . - ContinueOnNonExist = 16, - - /// Check that the path contains only valid path-characters. - CheckInvalidPathChars = 32, - - /// Also check for wildcard (? and *) characters. - CheckAdditional = 64, - - /// Do not trim the trailing dot or space. - KeepDotOrSpace = 128, - - /// Performs both and checks. - FullCheck = CheckInvalidPathChars | CheckAdditional - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/MoveOptions.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/MoveOptions.cs deleted file mode 100644 index c2e4e29..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/MoveOptions.cs +++ /dev/null @@ -1,83 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Used by MoveFileXxx.Flags that specify how a file or directory is to be moved. - [Flags] - public enum MoveOptions - { - /// No MoveOptions used, this fails when the file name already exists. - None = 0, - - /// MOVE_FILE_REPLACE_EXISTSING - /// If the destination file name already exists, the function replaces its contents with the contents of the source file. - /// This value cannot be used if lpNewFileName or lpExistingFileName names a directory. - /// This value cannot be used if either source or destination names a directory. - /// - ReplaceExisting = 1, - - /// MOVE_FILE_COPY_ALLOWED - /// If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions. - /// This value cannot be used with . - /// - CopyAllowed = 2, - - /// MOVE_FILE_DELAY_UNTIL_REBOOT - /// - /// The system does not move the file until the operating system is restarted. - /// The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. - /// - /// - /// Consequently, this parameter enables the function to delete paging files from previous startups. - /// This value can only be used if the process is in the context of a user who belongs to the administrators group or the LocalSystem account. - /// - /// This value cannot be used with . - /// - DelayUntilReboot = 4, - - /// MOVE_FILE_WRITE_THROUGH - /// The function does not return until the file has actually been moved on the disk. - /// - /// Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. - /// The flush occurs at the end of the copy operation. - /// - /// This value has no effect if is set. - /// - WriteThrough = 8, - - /// MOVE_FILE_CREATE_HARDLINK - /// Reserved for future use. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - CreateHardlink = 16, - - /// MOVE_FILE_FAIL_IF_NOT_TRACKABLE - /// The function fails if the source file is a link source, but the file cannot be tracked after the move. - /// This situation can occur if the destination is a volume formatted with the FAT file system. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Trackable")] - FailIfNotTrackable = 32 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/PathFormat.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/PathFormat.cs deleted file mode 100644 index e2c6b60..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/PathFormat.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Indicates the format of a path passed to a method. - /// - /// At some point in code you know the full path of file system objects, e.g.: "C:\Windows". - /// For example, Directory.EnumerateFileSystemEntries() will return all files and directories from a given path. - /// Most likely, some processing will happen on the results of the enum. The file or directory may be passed - /// on to another function. Whenever a file path is required, some performance can be gained. - ///   - /// A path like: "C:\Windows" or "\\server\share" is considered a full path for a directory because it is rooted and has a drive/unc path. - /// If the method supports it, and will skip GetFullPath() - /// calls for path resolving of the object, while also avoiding path validation and checks. - /// Using (default) will always call GetFullPath() and perform path validation and checks. - ///   - /// When working in a loop with thousands of files, will give the best performance. - /// - public enum PathFormat - { - /// The format of the path is automatically detected by the method and internally converted to an extended length path. - /// It can be either a standard (short) full path, an extended length (unicode) full path or a relative path. - /// Example relative path: "Windows". - /// - RelativePath, - - /// The path is a full path in either normal or extended length (UNICODE) format. - /// Internally it will be converted to an extended length (UNICODE) path. - /// Using this option has a very slight performance advantage compared to using . - /// Example full path: "C:\Windows" or "\\server\share". - /// - FullPath, - - /// The path is an extended length path. No additional processing will be done on the path, and it will be used as is. - /// Using this option has a slight performance advantage compared to using . - /// Example long full path: "\\?\C:\Windows" or "\\?\UNC\server\share". - /// - LongFullPath - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ReparsePointTag.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/ReparsePointTag.cs deleted file mode 100644 index 894f460..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/ReparsePointTag.cs +++ /dev/null @@ -1,106 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Enumeration specifying the different reparse point tags. - /// - /// Reparse tags, with the exception of IO_REPARSE_TAG_SYMLINK, are processed on the server and are not processed by a client after transmission over the wire. - /// Clients should treat associated reparse data as opaque data. - /// - public enum ReparsePointTag - { - /// The entry is not a reparse point. - None = 0, - - /// IO_REPARSE_APPXSTREAM - AppXStream = unchecked ((int) 3221225492), - - /// IO_REPARSE_TAG_CSV - Csv = unchecked ((int) 2147483657), - - /// IO_REPARSE_TAG_DRIVER_EXTENDER - /// Used by Home server drive extender. - /// - DriverExtender = unchecked ((int) 2147483653), - - /// IO_REPARSE_TAG_DEDUP - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dedup")] - Dedup = unchecked ((int) 2147483667), - - /// IO_REPARSE_TAG_DFS - /// Used by the DFS filter. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - Dfs = unchecked ((int) 2147483658), - - /// IO_REPARSE_TAG_DFSR - /// Used by the DFS filter. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfsr")] - Dfsr = unchecked ((int) 2147483666), - - /// IO_REPARSE_TAG_FILTER_MANAGER - /// Used by filter manager test harness. - /// - FilterManager = unchecked ((int) 2147483659), - - /// IO_REPARSE_TAG_HSM - /// (Obsolete) Used by legacy Hierarchical Storage Manager Product. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hsm")] - Hsm = unchecked ((int) 3221225476), - - /// IO_REPARSE_TAG_HSM2 - /// (Obsolete) Used by legacy Hierarchical Storage Manager Product. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hsm")] - Hsm2 = unchecked ((int) 2147483654), - - /// IO_REPARSE_TAG_NFS - /// NFS symlinks, Windows 8 / SMB3 and later. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nfs")] - Nfs = unchecked ((int) 2147483668), - - /// IO_REPARSE_TAG_MOUNT_POINT - /// Used for mount point support. - /// - MountPoint = unchecked ((int) 2684354563), - - /// IO_REPARSE_TAG_SIS - /// Used by single-instance storage (SIS) filter driver. - /// - Sis = unchecked ((int) 2147483655), - - /// IO_REPARSE_TAG_SYMLINK - /// Used for symbolic link support. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sym")] - SymLink = unchecked ((int) 2684354572), - - /// IO_REPARSE_TAG_WIM - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Wim")] - Wim = unchecked ((int) 2147483656) - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/STREAM_INFO_LEVELS.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/STREAM_INFO_LEVELS.cs deleted file mode 100644 index 44b2a53..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/STREAM_INFO_LEVELS.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Defines values that are used with the FindFirstStreamW function to specify the information level of the returned data. - /// - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - internal enum STREAM_INFO_LEVELS - { - /// The FindFirstStreamW function retrieves standard stream information. The data is returned in a structure. - FindStreamInfoStandard = 0, - - /// Used to determine valid enumeration values. All supported enumeration values are less than FindStreamInfoMaxInfoLevel. - FindStreamInfoMaxInfoLevel = 1 - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs deleted file mode 100644 index b8121e1..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SetupDiGetDeviceRegistryPropertyEnum.cs +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Flags for SetupDiGetDeviceRegistryProperty(). - internal enum SetupDiGetDeviceRegistryPropertyEnum - { - /// SPDRP_DEVICEDESC - /// Represents a description of a device instance. - /// - DeviceDescription = 0, - - /// SPDRP_HARDWAREID - /// Represents the list of hardware identifiers for a device instance. - /// - HardwareId = 1, - - /// SPDRP_COMPATIBLEIDS - /// Represents the list of compatible identifiers for a device instance. - /// - CompatibleIds = 2, - - //SPDRP_UNUSED0 = 0x00000003, - - /// SPDRP_CLASS - /// Represents the name of the service that is installed for a device instance. - /// - Service = 4, - - //SPDRP_UNUSED1 = 0x00000005, - //SPDRP_UNUSED2 = 0x00000006, - - /// SPDRP_CLASS - /// Represents the name of the device setup class that a device instance belongs to. - /// - Class = 7, - - /// SPDRP_CLASSGUID - /// Represents the of the device setup class that a device instance belongs to. - /// - ClassGuid = 8, - - /// SPDRP_DRIVER - /// Represents the registry entry name of the driver key for a device instance. - /// - Driver = 9, - - ///// SPDRP_CONFIGFLAGS - ///// Represents the configuration flags that are set for a device instance. - ///// - //ConfigurationFlags = 10, - - /// SPDRP_MFG - /// Represents the name of the manufacturer of a device instance. - /// - Manufacturer = 11, - - /// SPDRP_FRIENDLYNAME - /// Represents the friendly name of a device instance. - /// - FriendlyName = 12, - - /// SPDRP_LOCATION_INFORMATION - /// Represents the bus-specific physical location of a device instance. - /// - LocationInformation = 13, - - /// SPDRP_PHYSICAL_DEVICE_LOCATION - /// Encapsulates the physical device location information provided by a device's firmware to Windows. - /// - PhysicalDeviceObjectName = 14, - - ///// SPDRP_CAPABILITIES - //// Represents the capabilities of a device instance. - //// - //Capabilities = 15, - - ///// SPDRP_UI_NUMBER - Represents a number for the device instance that can be displayed in a user interface item. - //UiNumber = 16, - - ///// SPDRP_UPPERFILTERS - Represents a list of the service names of the upper-level filter drivers that are installed for a device instance. - //UpperFilters = 17, - - ///// SPDRP_LOWERFILTERS - Represents a list of the service names of the lower-level filter drivers that are installed for a device instance. - //LowerFilters = 18, - - ///// SPDRP_BUSTYPEGUID - Represents the that identifies the bus type of a device instance. - //BusTypeGuid = 19, - - ///// SPDRP_LEGACYBUSTYPE - Represents the legacy bus number of a device instance. - //LegacyBusType = 20, - - ///// SPDRP_BUSNUMBER - Represents the number that identifies the bus instance that a device instance is attached to. - //BusNumber = 21, - - /// SPDRP_ENUMERATOR_NAME - /// Represents the name of the enumerator for a device instance. - /// - EnumeratorName = 22, - - ///// SPDRP_SECURITY - Represents a security descriptor structure for a device instance. - //Security = 23, - - ///// SPDRP_SECURITY_SDS - Represents a security descriptor string for a device instance. - //SecuritySds = 24, - - ///// SPDRP_DEVTYPE - Represents the device type of a device instance. - //DeviceType = 25, - - ///// SPDRP_EXCLUSIVE - Represents a Boolean value that determines whether a device instance can be opened for exclusive use. - //Exclusive = 26, - - ///// SPDRP_CHARACTERISTICS - Represents the characteristics of a device instance. - //Characteristics = 27, - - ///// SPDRP_ADDRESS - Represents the bus-specific address of a device instance. - //Address = 28, - - ///// SPDRP_UI_NUMBER_DESC_FORMAT - Represents a printf-compatible format string that you should use to display the value of the device property for a device instance. - //UiNumberDescriptionFormat = 29, - - ///// SPDRP_DEVICE_POWER_DATA - Represents power information about a device instance. - //DevicePowerData = 30, - - ///// SPDRP_REMOVAL_POLICY - Represents the current removal policy for a device instance. - //RemovalPolicy = 31, - - ///// SPDRP_REMOVAL_POLICY_HW_DEFAULT - Represents the default removal policy for a device instance. - //RemovalPolicyDefault = 32, - - ///// SPDRP_REMOVAL_POLICY_OVERRIDE- Represents the removal policy override for a device instance. - //RemovalPolicyOverride = 33, - - ///// SPDRP_INSTALL_STATE - Represents the installation state of a device instance. - //InstallState = 34, - - /// SPDRP_LOCATION_PATHS - /// Represents the location of a device instance in the device tree. - /// - LocationPaths = 35, - - /// SPDRP_BASE_CONTAINERID - /// Represents the value of the base container identifier (ID) .The Windows Plug and Play (PnP) manager assigns this value to the device node (devnode). - /// - BaseContainerId = 36 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/StreamAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/StreamAttributes.cs deleted file mode 100644 index 869c55f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/StreamAttributes.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - /// WIN32_STREAM_ID Attributes of data to facilitate cross-operating system transfer. - [Flags] - public enum StreamAttributes - { - /// STREAM_NORMAL_ATTRIBUTE - /// This backup stream has no special attributes. - /// - None = 0, - - /// STREAM_MODIFIED_WHEN_READ - /// Attribute set if the stream contains data that is modified when read. - /// Allows the backup application to know that verification of data will fail. - /// - ModifiedWhenRead = 1, - - /// STREAM_CONTAINS_SECURITY - /// The backup stream contains security information. - /// This attribute applies only to backup stream of type . - /// - ContainsSecurity = 2, - - /// Reserved. - ContainsProperties = 4, - - /// STREAM_SPARSE_ATTRIBUTE - /// The backup stream is part of a sparse file stream. - /// This attribute applies only to backup stream of type , , and . - /// - Sparse = 8 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkTarget.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkTarget.cs deleted file mode 100644 index 485a094..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkTarget.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Indicates whether the link target is a file or directory. - /// Used by Win32 API CreateSymbolicLink()/CreateSymbolicLinkTransacted() - public enum SymbolicLinkTarget - { - /// The link target is a file. - File = 0, - - /// The link target is a directory. - Directory = 1 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkType.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkType.cs deleted file mode 100644 index 88a7f0b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/SymbolicLinkType.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Specifies the type of a symbolic link. - public enum SymbolicLinkType - { - /// The symbolic link is absolute. - Absolute = 0, - - /// The symbolic link is relative. - Relative = 1 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Enumerations/VolumeInfoAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/Enumerations/VolumeInfoAttributes.cs deleted file mode 100644 index e9cc092..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Enumerations/VolumeInfoAttributes.cs +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Volume Attributes used by the GetVolumeInfo() function. - [Flags] - internal enum VolumeInfoAttributes - { - /// No VolumeInfo attributes. - None = 0, - - /// FILE_CASE_SENSITIVE_SEARCH - /// The specified volume supports case-sensitive file names. - /// - CaseSensitiveSearch = 1, - - /// FILE_CASE_PRESERVED_NAMES - /// The specified volume supports preserved case of file names when it places a name on disk. - /// - CasePreservedNames = 2, - - /// FILE_UNICODE_ON_DISK - /// The specified volume supports Unicode in file names as they appear on disk. - /// - UnicodeOnDisk = 4, - - /// FILE_PERSISTENT_ACLS - /// - /// The specified volume preserves and enforces access control lists (ACL). - /// For example, the NTFS file system preserves and enforces ACLs, and the FAT file system does not. - /// - /// - PersistentAcls = 8, - - /// FILE_FILE_COMPRESSION - /// The specified volume supports file-based compression. - /// - Compression = 16, - - /// FILE_VOLUME_QUOTAS - /// The specified volume supports disk quotas. - /// - VolumeQuotas = 32, - - /// FILE_SUPPORTS_SPARSE_FILES - /// The specified volume supports sparse files. - /// - SupportsSparseFiles = 64, - - /// FILE_SUPPORTS_REPARSE_POINTS - /// The specified volume supports re-parse points. - /// - SupportsReparsePoints = 128, - - /// (does not appear on MSDN) - SupportsRemoteStorage = 256, - - /// FILE_VOLUME_IS_COMPRESSED - /// The specified volume is a compressed volume, for example, a DoubleSpace volume. - /// - VolumeIsCompressed = 32768, - - /// FILE_SUPPORTS_OBJECT_IDS - /// The specified volume supports object identifiers. - /// - SupportsObjectIds = 65536, - - /// FILE_SUPPORTS_ENCRYPTION - /// The specified volume supports the Encrypted File System (EFS). For more information, see File Encryption. - /// - SupportsEncryption = 131072, - - /// FILE_NAMED_STREAMS - /// The specified volume supports named streams. - /// - NamedStreams = 262144, - - /// FILE_READ_ONLY_VOLUME - /// The specified volume is read-only. - /// - ReadOnlyVolume = 524288, - - /// FILE_SEQUENTIAL_WRITE_ONCE - /// The specified volume is read-only. - /// - SequentialWriteOnce = 1048576, - - /// FILE_SUPPORTS_TRANSACTIONS - /// The specified volume supports transactions.For more information, see About KTM. - /// - SupportsTransactions = 2097152, - - /// FILE_SUPPORTS_HARD_LINKS - /// The specified volume supports hard links. For more information, see Hard Links and Junctions. - /// - /// Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This value is not supported until Windows Server 2008 R2 and Windows 7. - SupportsHardLinks = 4194304, - - /// FILE_SUPPORTS_EXTENDED_ATTRIBUTES - /// - /// The specified volume supports extended attributes. An extended attribute is a piece of application-specific metadata - /// that an application can associate with a file and is not part of the file's data. - /// - /// - /// Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This value is not supported until Windows Server 2008 R2 and Windows 7. - SupportsExtendedAttributes = 8388608, - - /// FILE_SUPPORTS_OPEN_BY_FILE_ID - /// The file system supports open by FileID. For more information, see FILE_ID_BOTH_DIR_INFO. - /// - /// Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This value is not supported until Windows Server 2008 R2 and Windows 7. - SupportsOpenByFileId = 16777216, - - /// FILE_SUPPORTS_USN_JOURNAL - /// The specified volume supports update sequence number (USN) journals. For more information, see Change Journal Records. - /// - /// Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This value is not supported until Windows Server 2008 R2 and Windows 7. - SupportsUsnJournal = 33554432 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs deleted file mode 100644 index 5f67e09..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/AlreadyExistsException.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The exception that is thrown when an attempt to create a directory or file that already exists was made. - [Serializable] - public class AlreadyExistsException : System.IO.IOException - { - private static readonly int s_errorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_ALREADY_EXISTS); - - /// Initializes a new instance of the class. - public AlreadyExistsException() : base(Resources.File_Or_Directory_Already_Exists, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - public AlreadyExistsException(string message) : base(message, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public AlreadyExistsException(string message, Exception innerException) : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected AlreadyExistsException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs deleted file mode 100644 index 1c4cd44..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DeviceNotReadyException.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The requested operation could not be completed because the device was not ready. - [Serializable] - public class DeviceNotReadyException : System.IO.IOException - { - private static readonly int s_errorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_NOT_READY); - - /// Initializes a new instance of the class. - public DeviceNotReadyException() - : base(Resources.Device_Not_Ready, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - public DeviceNotReadyException(string message) - : base(message, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public DeviceNotReadyException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected DeviceNotReadyException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs deleted file mode 100644 index b321980..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryNotEmptyException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The operation could not be completed because the directory was not empty. - [Serializable] - public class DirectoryNotEmptyException : System.IO.IOException - { - private static readonly int s_errorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_DIR_NOT_EMPTY); - - /// Initializes a new instance of the class. - public DirectoryNotEmptyException() : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is not empty", Win32Errors.ERROR_DIR_NOT_EMPTY), s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - public DirectoryNotEmptyException(string message) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is not empty: [{1}]", Win32Errors.ERROR_DIR_NOT_EMPTY, message), s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public DirectoryNotEmptyException(string message, Exception innerException) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is not empty: [{1}]", Win32Errors.ERROR_DIR_NOT_EMPTY, message), innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected DirectoryNotEmptyException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryReadOnlyException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryReadOnlyException.cs deleted file mode 100644 index be8bd0f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/DirectoryReadOnlyException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The operation could not be completed because the directory is read-only. - [Serializable] - public class DirectoryReadOnlyException : System.IO.IOException - { - private static readonly int s_errorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_FILE_READ_ONLY); - - /// Initializes a new instance of the class. - public DirectoryReadOnlyException() : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is read-only", Win32Errors.ERROR_FILE_READ_ONLY), s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - public DirectoryReadOnlyException(string message) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is read-only: [{1}]", Win32Errors.ERROR_FILE_READ_ONLY, message), s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public DirectoryReadOnlyException(string message, Exception innerException) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The directory is read-only: [{1}]", Win32Errors.ERROR_FILE_READ_ONLY, message), innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected DirectoryReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/FileReadOnlyException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/FileReadOnlyException.cs deleted file mode 100644 index 4fb197d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/FileReadOnlyException.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The operation could not be completed because the file is read-only. - [Serializable] - public class FileReadOnlyException : UnauthorizedAccessException - { - /// Initializes a new instance of the class. - public FileReadOnlyException() : base(string.Format(CultureInfo.CurrentCulture, "({0}) The file is read-only.", Win32Errors.ERROR_FILE_READ_ONLY)) - { - } - - /// Initializes a new instance of the class. - /// The message. - public FileReadOnlyException(string message) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The file is read-only: [{1}]", Win32Errors.ERROR_FILE_READ_ONLY, message)) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public FileReadOnlyException(string message, Exception innerException) : base(string.Format(CultureInfo.CurrentCulture, "({0}) The file is read-only: [{1}]", Win32Errors.ERROR_FILE_READ_ONLY, message), innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected FileReadOnlyException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/InvalidTransactionException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/InvalidTransactionException.cs deleted file mode 100644 index caa737d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/InvalidTransactionException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The transaction handle associated with this operation is not valid. - [SerializableAttribute] - public class InvalidTransactionException : TransactionException - { - /// Initializes a new instance of the class. - public InvalidTransactionException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public InvalidTransactionException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public InvalidTransactionException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected InvalidTransactionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs deleted file mode 100644 index 7124206..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/NotAReparsePointException.cs +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The file or directory was not a reparse point. - [SerializableAttribute] - public class NotAReparsePointException : System.IO.IOException - { - private static readonly int s_errorCode = Win32Errors.GetHrFromWin32Error(Win32Errors.ERROR_NOT_A_REPARSE_POINT); - - /// Initializes a new instance of the class. - public NotAReparsePointException() - : base(Resources.Not_A_Reparse_Point, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - public NotAReparsePointException(string message) - : base(message, s_errorCode) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public NotAReparsePointException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The info. - /// The context. - protected NotAReparsePointException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyAbortedException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyAbortedException.cs deleted file mode 100644 index a6163ab..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyAbortedException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// It is too late to perform the requested operation, since the Transaction has already been aborted. - [SerializableAttribute] - public class TransactionAlreadyAbortedException : TransactionException - { - /// Initializes a new instance of the class. - public TransactionAlreadyAbortedException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public TransactionAlreadyAbortedException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public TransactionAlreadyAbortedException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The info. - /// The context. - protected TransactionAlreadyAbortedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyCommittedException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyCommittedException.cs deleted file mode 100644 index 99dcbe2..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionAlreadyCommittedException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// It is too late to perform the requested operation, since the Transaction has already been committed. - [SerializableAttribute] - public class TransactionAlreadyCommittedException : TransactionException - { - /// Initializes a new instance of the class. - public TransactionAlreadyCommittedException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public TransactionAlreadyCommittedException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public TransactionAlreadyCommittedException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The object that holds the serialized object data. - /// The contextual information about the source or destination. - protected TransactionAlreadyCommittedException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionException.cs deleted file mode 100644 index 972fdbb..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionException.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The exception that is thrown when an attempt to create a file or directory that already exists was made. - [SerializableAttribute] - public class TransactionException : SystemException - { - /// Initializes a new instance of the class. - public TransactionException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public TransactionException(string message) : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public TransactionException(string message, Exception innerException) : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The data for serializing or deserializing the object. - /// The source and destination for the object. - protected TransactionException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionalConflictException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionalConflictException.cs deleted file mode 100644 index 81d69c6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/TransactionalConflictException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The function attempted to use a name that is reserved for use by another transaction. - [SerializableAttribute] - public class TransactionalConflictException : TransactionException - { - /// Initializes a new instance of the class. - public TransactionalConflictException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public TransactionalConflictException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public TransactionalConflictException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The info. - /// The context. - protected TransactionalConflictException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs deleted file mode 100644 index 63aec51..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnrecognizedReparsePointException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The function attempted to use a name that is reserved for use by another transaction. - [SerializableAttribute] - public class UnrecognizedReparsePointException : System.IO.IOException - { - /// Initializes a new instance of the class. - public UnrecognizedReparsePointException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public UnrecognizedReparsePointException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public UnrecognizedReparsePointException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The info. - /// The context. - protected UnrecognizedReparsePointException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnsupportedRemoteTransactionException.cs b/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnsupportedRemoteTransactionException.cs deleted file mode 100644 index 8566508..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Exceptions/UnsupportedRemoteTransactionException.cs +++ /dev/null @@ -1,59 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.Serialization; - -namespace Alphaleonis.Win32.Filesystem -{ - /// The remote server or share does not support transacted file operations. - [SerializableAttribute] - public class UnsupportedRemoteTransactionException : TransactionException - { - /// Initializes a new instance of the class. - public UnsupportedRemoteTransactionException() - { - } - - /// Initializes a new instance of the class. - /// The message. - public UnsupportedRemoteTransactionException(string message) - : base(message) - { - } - - /// Initializes a new instance of the class. - /// The message. - /// The inner exception. - public UnsupportedRemoteTransactionException(string message, Exception innerException) - : base(message, innerException) - { - } - - /// Initializes a new instance of the class. - /// The object that holds the serialized object data. - /// The contextual information about the source or destination. - protected UnsupportedRemoteTransactionException(SerializationInfo info, StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.AppendText.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.AppendText.cs deleted file mode 100644 index de62be0..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.AppendText.cs +++ /dev/null @@ -1,194 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region AppendText - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or to a new - /// file if the specified file does not exist. - /// - /// The path to the file to append to. - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendText(string path) - { - return AppendTextCore(null, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The path to the file to append to. - /// Indicates the format of the path parameter(s). - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendText(string path, PathFormat pathFormat) - { - return AppendTextCore(null, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The path to the file to append to. - /// The character to use. - /// Indicates the format of the path parameter(s). - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendText(string path, Encoding encoding, PathFormat pathFormat) - { - return AppendTextCore(null, path, encoding, pathFormat); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The path to the file to append to. - /// The character to use. - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendText(string path, Encoding encoding) - { - return AppendTextCore(null, path, encoding, PathFormat.RelativePath); - } - - #region Transactional - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The transaction. - /// The path to the file to append to. - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendTextTransacted(KernelTransaction transaction, string path) - { - return AppendTextCore(transaction, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The transaction. - /// The path to the file to append to. - /// Indicates the format of the path parameter(s). - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendTextTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return AppendTextCore(transaction, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The transaction. - /// The path to the file to append to. - /// The character to use. - /// Indicates the format of the path parameter(s). - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendTextTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return AppendTextCore(transaction, path, encoding, pathFormat); - } - - /// - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or - /// to a new file if the specified file does not exist. - /// - /// The transaction. - /// The path to the file to append to. - /// The character to use. - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SecurityCritical] - public static StreamWriter AppendTextTransacted(KernelTransaction transaction, string path, Encoding encoding) - { - return AppendTextCore(transaction, path, encoding, PathFormat.RelativePath); - } - - #endregion // Transacted - - #endregion // AppendText - - #region Internal Methods - - /// Creates a that appends NativeMethods.DefaultFileEncoding encoded text to an existing file, or to a new file if the specified file does not exist. - /// - /// The transaction. - /// The path to the file to append to. - /// The character to use. - /// Indicates the format of the path parameter(s). - /// - /// A stream writer that appends NativeMethods.DefaultFileEncoding encoded text to the specified file or to a new file. - /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static StreamWriter AppendTextCore(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - FileStream fs = OpenCore(transaction, path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat); - - try - { - fs.Seek(0, SeekOrigin.End); - return new StreamWriter(fs, encoding); - } - catch (IOException) - { - fs.Close(); - throw; - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Compress.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Compress.cs deleted file mode 100644 index ac88380..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Compress.cs +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Compress - - /// [AlphaFS] Compresses a file using NTFS compression. - /// A path that describes a file to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Compress(string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(false, null, path, true, pathFormat); - } - - /// [AlphaFS] Compresses a file using NTFS compression. - /// A path that describes a file to compress. - [SecurityCritical] - public static void Compress(string path) - { - Device.ToggleCompressionCore(false, null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Compresses a file using NTFS compression. - /// The transaction. - /// A path that describes a file to compress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(false, transaction, path, true, pathFormat); - } - - - /// [AlphaFS] Compresses a file using NTFS compression. - /// The transaction. - /// A path that describes a file to compress. - [SecurityCritical] - public static void CompressTransacted(KernelTransaction transaction, string path) - { - Device.ToggleCompressionCore(false, transaction, path, true, PathFormat.RelativePath); - } - - #endregion - - #region Decompress - - /// [AlphaFS] Decompresses an NTFS compressed file. - /// A path that describes a file to decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decompress(string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(false, null, path, false, pathFormat); - } - - /// [AlphaFS] Decompresses an NTFS compressed file. - /// A path that describes a file to decompress. - [SecurityCritical] - public static void Decompress(string path) - { - Device.ToggleCompressionCore(false, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decompresses an NTFS compressed file. - /// The transaction. - /// A path that describes a file to decompress. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - Device.ToggleCompressionCore(false, transaction, path, false, pathFormat); - } - - /// [AlphaFS] Decompresses an NTFS compressed file. - /// The transaction. - /// A path that describes a file to decompress. - [SecurityCritical] - public static void DecompressTransacted(KernelTransaction transaction, string path) - { - Device.ToggleCompressionCore(false, transaction, path, false, PathFormat.RelativePath); - } - - #endregion - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CopyMove.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.CopyMove.cs deleted file mode 100644 index e2e44c8..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CopyMove.cs +++ /dev/null @@ -1,1324 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Copy - - #region .NET - - /// Copies an existing file to a new file. Overwriting a file of the same name is not allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory or an existing file. - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// Copies an existing file to a new file. Overwriting a file of the same name is allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// if the destination file should ignoring the read-only and hidden attributes and overwrite; otherwise, . - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, bool overwrite) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - #endregion // .NET - - - #region AlphaFS - - #region Non-Transactional - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is not allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// if the destination file should ignoring the read-only and hidden attributes and overwrite; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, bool overwrite, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - #endregion // Non-Transactional - - - #region Transactional - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is not allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory or an existing file. - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is not allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// if the destination file should ignoring the read-only and hidden attributes and overwrite; otherwise, . - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, bool overwrite) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. - /// - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// if the destination file should ignoring the read-only and hidden attributes and overwrite; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, bool overwrite, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, null, pathFormat); - } - - #endregion // Transactional - - #endregion // AlphaFS - - #endregion // Copy - - - #region Copy (CopyOptions) - - #region Non-Transactional - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, copyOptions, null, null, null, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, preserveDates, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, preserveDates, copyOptions, null, null, null, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, preserveDates, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Copy(string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, preserveDates, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Non-Transactional - - - #region Transactional - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, copyOptions, null, null, null, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, preserveDates, copyOptions, null, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, preserveDates, copyOptions, null, null, null, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, preserveDates, copyOptions, null, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Copies an existing file to a new file. Overwriting a file of the same name is allowed. can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with details of the Copy action. - /// - /// Option is recommended for very large file transfers. - /// The attributes of the original file are retained in the copied file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// The transaction. - /// The file to copy. - /// The name of the destination file. This cannot be a directory. - /// that specify how the file is to be copied. This parameter can be . - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - /// - /// - /// - /// - /// - /// - /// - [SecurityCritical] - public static void CopyTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, preserveDates, copyOptions, null, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Copy (CopyOptions) - - - #region Move - - #region .NET - - /// Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, MoveOptions.CopyAllowed, null, null, null, PathFormat.RelativePath); - } - - #endregion // .NET - - #region AlphaFS - - #region Non-Transactional - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, MoveOptions.CopyAllowed, null, null, null, pathFormat); - } - - #endregion // Non-Transactional - - #region Transactional - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, MoveOptions.CopyAllowed, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, MoveOptions.CopyAllowed, null, null, null, pathFormat); - } - - #endregion // Transactional - - #endregion // AlphaFS - - #endregion // Move - - - #region Move (MoveOptions) - - #region Non-Transactional - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName, MoveOptions moveOptions) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, moveOptions, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName, MoveOptions moveOptions, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, moveOptions, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// A class with the status of the Move action. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// A class with the status of the Move action. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Move(string sourceFileName, string destinationFileName, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, null, sourceFileName, destinationFileName, false, null, moveOptions, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Non-Transactional - - #region Transactional - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, MoveOptions moveOptions) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, moveOptions, null, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, MoveOptions moveOptions, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, moveOptions, null, null, null, pathFormat); - } - - - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// A class with the status of the Move action. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, moveOptions, progressHandler, userProgressData, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// A class with the status of the Move action. - /// - /// This method works across disk volumes, and it does not throw an exception if the source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into that directory, you get an . - /// You cannot use the Move method to overwrite an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The name of the file to move. - /// The new path for the file. - /// that specify how the file is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void MoveTransacted(KernelTransaction transaction, string sourceFileName, string destinationFileName, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - CopyMoveCore(false, transaction, sourceFileName, destinationFileName, false, null, moveOptions, progressHandler, userProgressData, null, pathFormat); - } - - #endregion // Transactional - - #endregion // Move (MoveOptions) - - - #region Internal Methods - - /// Determine the Copy or Move action. - internal static bool DetermineIsCopy(CopyOptions? copyOptions, MoveOptions? moveOptions) - { - // Determine Copy or Move action. - var isCopy = copyOptions != null; - var isMove = !isCopy && moveOptions != null; - - if ((!isCopy && !isMove) || (isCopy && isMove)) - throw new NotSupportedException(Resources.Cannot_Determine_Copy_Or_Move); - - return isCopy; - } - - - /// Copy/move a Non-/Transacted file or directory including its children to a new location, or can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// A class with the status of the Copy or Move action. - /// - /// Option is recommended for very large file transfers. - /// You cannot use the Move method to overwrite an existing file, unless - /// contains . - /// This Move method works across disk volumes, and it does not throw an exception if the - /// source and destination are the same. - /// Note that if you attempt to replace a file by moving a file of the same name into - /// that directory, you get an IOException. - /// - /// - /// - /// - /// - /// - /// - /// - /// Specifies that and are a file or directory. - /// The transaction. - /// The source directory path. - /// The destination directory path. - /// if original Timestamps must be preserved, otherwise. This parameter is ignored for move operations. - /// that specify how the file is to be copied. This parameter can be . - /// Flags that specify how the file or directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the file has been copied/moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SecurityCritical] - internal static CopyMoveResult CopyMoveCore(bool isFolder, KernelTransaction transaction, string sourceFileName, string destinationFileName, bool preserveDates, CopyOptions? copyOptions, MoveOptions? moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, CopyMoveResult copyMoveResult, PathFormat pathFormat) - { - #region Setup - - var sourceFileNameLp = sourceFileName; - var destFileNameLp = destinationFileName; - - if (pathFormat != PathFormat.LongFullPath) - { - Path.CheckSupportedPathFormat(sourceFileName, true, true); - Path.CheckSupportedPathFormat(destinationFileName, true, true); - - sourceFileNameLp = Path.GetExtendedLengthPathCore(transaction, sourceFileName, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator); - destFileNameLp = Path.GetExtendedLengthPathCore(transaction, destinationFileName, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator); - } - - - // Determine Copy or Move action. - var isCopy = DetermineIsCopy(copyOptions, moveOptions); - var isMove = !isCopy; - - var cmr = copyMoveResult ?? new CopyMoveResult(sourceFileName, destinationFileName, false, (int) Win32Errors.ERROR_SUCCESS); - - - // MSDN: If this flag is set to TRUE during the copy/move operation, the operation is canceled. - // Otherwise, the copy/move operation will continue to completion. - bool cancel; - - var raiseException = progressHandler == null; - - // Setup callback function for progress notifications. - var routine = !raiseException - ? (totalFileSize, totalBytesTransferred, streamSize, streamBytesTransferred, dwStreamNumber, dwCallbackReason, hSourceFile, hDestinationFile, lpData) => - progressHandler(totalFileSize, totalBytesTransferred, streamSize, streamBytesTransferred, dwStreamNumber, dwCallbackReason, userProgressData) - : (NativeMethods.NativeCopyMoveProgressRoutine) null; - - #endregion // Setup - - - startCopyMove: - - #region Win32 Copy/Move - - var success = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - ? isMove - // MoveFileWithProgress() / MoveFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-04-15: MSDN confirms LongPath usage. - - // CopyFileEx() / CopyFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-04-15: MSDN confirms LongPath usage. - - - // Note: The NativeMethod.MoveFileXxx() methods fail if one of the paths is a UNC path, even though both paths refer to the same volume. - // For example, src = C:\TempSrc and dst = \\localhost\C$\TempDst - - - ? NativeMethods.MoveFileWithProgress(sourceFileNameLp, destFileNameLp, routine, IntPtr.Zero, (MoveOptions) moveOptions) - : NativeMethods.CopyFileEx(sourceFileNameLp, destFileNameLp, routine, IntPtr.Zero, out cancel, (CopyOptions) copyOptions) - - : isMove - ? NativeMethods.MoveFileTransacted(sourceFileNameLp, destFileNameLp, routine, IntPtr.Zero, (MoveOptions) moveOptions, transaction.SafeHandle) - : NativeMethods.CopyFileTransacted(sourceFileNameLp, destFileNameLp, routine, IntPtr.Zero, out cancel, (CopyOptions) copyOptions, transaction.SafeHandle); - - - var lastError = (uint) Marshal.GetLastWin32Error(); - if (!success) - { - cmr.ErrorCode = (int) lastError; - - if (lastError == Win32Errors.ERROR_REQUEST_ABORTED) - { - // MSDN: - // - // If lpProgressRoutine returns PROGRESS_CANCEL due to the user canceling the operation, - // CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. - // In this case, the partially copied destination file is deleted. - // - // If lpProgressRoutine returns PROGRESS_STOP due to the user stopping the operation, - // CopyFileEx will return zero and GetLastError will return ERROR_REQUEST_ABORTED. - // In this case, the partially copied destination file is left intact. - - cmr.IsCanceled = true; - } - - else if (raiseException) - { - raiseException: - - #region Win32Errors - - switch (lastError) - { - case Win32Errors.ERROR_FILE_NOT_FOUND: - if (isFolder) - { - lastError = Win32Errors.ERROR_PATH_NOT_FOUND; - goto raiseException; - } - - // File.Copy() - // File.Move() - // MSDN: .NET 3.5+: FileNotFoundException: sourceFileName was not found. - NativeError.ThrowException(lastError, sourceFileNameLp); - break; - - case Win32Errors.ERROR_PATH_NOT_FOUND: - // File.Copy() - // File.Move() - // Directory.Move() - // MSDN: .NET 3.5+: DirectoryNotFoundException: The path specified in sourceFileName or destinationFileName is invalid (for example, it is on an unmapped drive). - NativeError.ThrowException(lastError, sourceFileNameLp); - break; - - case Win32Errors.ERROR_FILE_EXISTS: - // File.Copy() - // Directory.Copy() - NativeError.ThrowException(lastError, destFileNameLp); - break; - - default: - var destExists = ExistsCore(isFolder, transaction, destFileNameLp, PathFormat.LongFullPath); - - // For a number of error codes (sharing violation, path not found, etc) - // we don't know if the problem was with the source or destination file. - - // Check if destination directory already exists. - // Directory.Move() - // MSDN: .NET 3.5+: IOException: destDirName already exists. - if (isFolder && destExists) - NativeError.ThrowException(Win32Errors.ERROR_ALREADY_EXISTS, destFileNameLp); - - if (isMove) - { - // Ensure that the source file or directory exists. - // Directory.Move() - // MSDN: .NET 3.5+: DirectoryNotFoundException: The path specified by sourceDirName is invalid (for example, it is on an unmapped drive). - if (!ExistsCore(isFolder, transaction, sourceFileNameLp, PathFormat.LongFullPath)) - NativeError.ThrowException(isFolder ? Win32Errors.ERROR_PATH_NOT_FOUND : Win32Errors.ERROR_FILE_NOT_FOUND, sourceFileNameLp); - } - - - // Try reading the source file. - var fileNameLp = destFileNameLp; - - if (!isFolder) - { - using (var safeHandle = CreateFileCore(transaction, sourceFileNameLp, ExtendedFileAttributes.Normal, null, FileMode.Open, 0, FileShare.Read, false, PathFormat.LongFullPath)) - if (safeHandle != null && safeHandle.IsInvalid) - fileNameLp = sourceFileNameLp; - } - - if (lastError == Win32Errors.ERROR_ACCESS_DENIED) - { - // File.Copy() - // File.Move() - // MSDN: .NET 3.5+: IOException: An I/O error has occurred. - // Directory exists with the same name as the file. - if (!isFolder && destExists) - NativeError.ThrowException(lastError, string.Format(CultureInfo.CurrentCulture, Resources.Target_File_Is_A_Directory, destFileNameLp)); - - if (isMove) - { - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - FillAttributeInfoCore(transaction, destFileNameLp, ref data, false, true); - - if (data.dwFileAttributes != (FileAttributes) (-1)) - { - if ((data.dwFileAttributes & FileAttributes.ReadOnly) != 0) - { - // MSDN: .NET 3.5+: IOException: The directory specified by path is read-only. - if (((MoveOptions) moveOptions & MoveOptions.ReplaceExisting) != 0) - { - // Reset file system object attributes. - SetAttributesCore(isFolder, transaction, destFileNameLp, FileAttributes.Normal, PathFormat.LongFullPath); - - goto startCopyMove; - } - - - // MSDN: .NET 3.5+: UnauthorizedAccessException: destinationFileName is read-only. - // MSDN: Win32 CopyFileXxx: This function fails with ERROR_ACCESS_DENIED if the destination file already exists - // and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY attribute set. - throw new FileReadOnlyException(destFileNameLp); - } - - - // MSDN: Win32 CopyFileXxx: This function fails with ERROR_ACCESS_DENIED if the destination file already exists - // and has the FILE_ATTRIBUTE_HIDDEN or FILE_ATTRIBUTE_READONLY attribute set. - if ((data.dwFileAttributes & FileAttributes.Hidden) != 0) - NativeError.ThrowException(lastError, string.Format(CultureInfo.CurrentCulture, Resources.File_Is_Hidden, destFileNameLp)); - } - } - } - - - // MSDN: .NET 3.5+: An I/O error has occurred. - // File.Copy(): IOException: destinationFileName exists and overwrite is false. - // File.Move(): The destination file already exists or sourceFileName was not found. - NativeError.ThrowException(lastError, fileNameLp); - - break; - } - - #endregion // Win32Errors - } - } - - #endregion // Win32 Copy/Move - - - #region Transfer Timestamps - - // Apply original Timestamps if requested. - // MoveFileWithProgress() / MoveFileTransacted() automatically preserve Timestamps. - // File.Copy() - - if (success && preserveDates && isCopy) - { - // Currently preserveDates is only used with files. - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - var dataInitialised = FillAttributeInfoCore(transaction, sourceFileNameLp, ref data, false, true); - - if (dataInitialised == Win32Errors.ERROR_SUCCESS && data.dwFileAttributes != (FileAttributes) (-1)) - SetFsoDateTimeCore(false, transaction, destFileNameLp, DateTime.FromFileTimeUtc(data.ftCreationTime), - DateTime.FromFileTimeUtc(data.ftLastAccessTime), DateTime.FromFileTimeUtc(data.ftLastWriteTime), false, PathFormat.LongFullPath); - } - - #endregion // Transfer Timestamps - - - return cmr; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Create.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Create.cs deleted file mode 100644 index f1f2703..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Create.cs +++ /dev/null @@ -1,427 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using FileStream = System.IO.FileStream; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Non-Transactional - - /// Creates or overwrites a file in the specified path. - /// The path and name of the file to create. - /// A that provides read/write access to the file specified in . - [SecurityCritical] - public static FileStream Create(string path) - { - return CreateFileStreamCore(null, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, PathFormat.RelativePath); - } - - /// Creates or overwrites the specified file. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// - /// A with the specified buffer size that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream Create(string path, int bufferSize) - { - return CreateFileStreamCore(null, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// A new file with the specified buffer size. - [SecurityCritical] - public static FileStream Create(string path, int bufferSize, FileOptions options) - { - return CreateFileStreamCore(null, path, (ExtendedFileAttributes) options, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// - /// One of the values that determines the access control and audit security for the file. - /// - /// A new file with the specified buffer size, file options, and file security. - [SecurityCritical] - public static FileStream Create(string path, int bufferSize, FileOptions options, FileSecurity fileSecurity) - { - return CreateFileStreamCore(null, path, (ExtendedFileAttributes)options, fileSecurity, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// Creates or overwrites a file in the specified path. - /// The path and name of the file to create. - /// Indicates the format of the path parameter(s). - /// - /// A that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream Create(string path, PathFormat pathFormat) - { - return CreateFileStreamCore(null, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, pathFormat); - } - - /// Creates or overwrites the specified file. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// Indicates the format of the path parameter(s). - /// - /// A with the specified buffer size that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream Create(string path, int bufferSize, PathFormat pathFormat) - { - return CreateFileStreamCore(null, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The name of the file. - /// - /// The number of bytes buffered for reads and writes to the file. - /// - /// - /// One of the values that describes how to create or overwrite the - /// file. - /// - /// Indicates the format of the path parameter(s). - /// A new file with the specified buffer size. - [SecurityCritical] - public static FileStream Create(string path, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return CreateFileStreamCore(null, path, (ExtendedFileAttributes)options, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The name of the file. - /// - /// The number of bytes buffered for reads and writes to the file. - /// - /// - /// One of the values that describes how to create or overwrite the - /// file. - /// - /// - /// One of the values that determines the access control and audit - /// security for the file. - /// - /// Indicates the format of the path parameter(s). - /// - /// A new file with the specified buffer size, file options, and file security. - /// - [SecurityCritical] - public static FileStream Create(string path, int bufferSize, FileOptions options, FileSecurity fileSecurity, PathFormat pathFormat) - { - return CreateFileStreamCore(null, path, (ExtendedFileAttributes)options, fileSecurity, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - #endregion // .NET - - #region Transactional - - /// Creates or overwrites a file in the specified path. - /// The transaction. - /// The path and name of the file to create. - /// - /// A that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path) - { - return CreateFileStreamCore(transaction, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, PathFormat.RelativePath); - } - - /// Creates or overwrites the specified file. - /// The transaction. - /// The name of the file. - /// - /// The number of bytes buffered for reads and writes to the file. - /// - /// - /// A with the specified buffer size that provides read/write access - /// to the file specified in . - /// - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize) - { - return CreateFileStreamCore(transaction, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The transaction. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// A new file with the specified buffer size. - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize, FileOptions options) - { - return CreateFileStreamCore(transaction, path, (ExtendedFileAttributes)options, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The transaction. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// - /// One of the values that determines the access control and audit security for the file. - /// - /// A new file with the specified buffer size, file options, and file security. - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize, FileOptions options, FileSecurity fileSecurity) - { - return CreateFileStreamCore(transaction, path, (ExtendedFileAttributes)options, fileSecurity, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, PathFormat.RelativePath); - } - - /// Creates or overwrites a file in the specified path. - /// The transaction. - /// The path and name of the file to create. - /// Indicates the format of the path parameter(s). - /// - /// A that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return CreateFileStreamCore(transaction, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, pathFormat); - } - - /// Creates or overwrites the specified file. - /// The transaction. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// Indicates the format of the path parameter(s). - /// - /// A with the specified buffer size that provides read/write access to the file specified in - /// . - /// - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize, PathFormat pathFormat) - { - return CreateFileStreamCore(transaction, path, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The transaction. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// Indicates the format of the path parameter(s). - /// A new file with the specified buffer size. - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return CreateFileStreamCore(transaction, path, (ExtendedFileAttributes)options, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - /// - /// Creates or overwrites the specified file, specifying a buffer size and a - /// value that describes how to create or overwrite the file. - /// - /// The transaction. - /// The name of the file. - /// The number of bytes buffered for reads and writes to the file. - /// One of the values that describes how to create or overwrite the file. - /// - /// One of the values that determines the access control and audit security for the file. - /// - /// Indicates the format of the path parameter(s). - /// A new file with the specified buffer size, file options, and file security. - [SecurityCritical] - public static FileStream CreateTransacted(KernelTransaction transaction, string path, int bufferSize, FileOptions options, FileSecurity fileSecurity, PathFormat pathFormat) - { - return CreateFileStreamCore(transaction, path, (ExtendedFileAttributes)options, fileSecurity, FileMode.Create, FileAccess.ReadWrite, FileShare.None, bufferSize, pathFormat); - } - - #endregion - - #region Internal - - /// Creates or overwrites a file in the specified path. - /// The transaction. - /// The name of the file. - /// The additional advanced options to create a file. - /// - /// A instance that determines the access control and audit security for the file. - /// - /// The option gives you more precise control over how you want to create a file. - /// - /// The allow you additionally specify to default read/write capability - just write, bypassing any cache. - /// - /// - /// The option controls how you would like to share created file with other requesters. - /// - /// Indicates the format of the parameter. - /// The number of bytes buffered for reads and writes to the file. - /// A that provides read/write access to the file specified in path. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "False positive")] - [SecurityCritical] - internal static FileStream CreateFileStreamCore(KernelTransaction transaction, string path, ExtendedFileAttributes attributes, FileSecurity fileSecurity, FileMode mode, FileAccess access, FileShare share, int bufferSize, PathFormat pathFormat) - { - SafeFileHandle safeHandle = null; - - try - { - safeHandle = CreateFileCore(transaction, path, attributes, fileSecurity, mode, (FileSystemRights) access, share, true, pathFormat); - - return new FileStream(safeHandle, access, bufferSize, (attributes & ExtendedFileAttributes.Overlapped) != 0); - } - catch - { - if (safeHandle != null) - safeHandle.Dispose(); - - throw; - } - } - - /// Creates or opens a file, directory or I/O device. - /// A that provides read/write access to the file or directory specified by . - /// - /// To obtain a directory handle using CreateFile, specify the FILE_FLAG_BACKUP_SEMANTICS flag as part of dwFlagsAndAttributes. - /// The most commonly used I/O devices are as follows: file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. - /// - /// - /// - /// - /// The transaction. - /// The path and name of the file or directory to create. - /// One of the values that describes how to create or overwrite the file or directory. - /// A instance that determines the access control and audit security for the file or directory. - /// A constant that determines how to open or create the file or directory. - /// A constant that determines the access rights to use when creating access and audit rules for the file or directory. - /// A constant that determines how the file or directory will be shared by processes. - /// . - /// Indicates the format of the parameter. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Object needs to be disposed by caller.")] - [SecurityCritical] - internal static SafeFileHandle CreateFileCore(KernelTransaction transaction, string path, ExtendedFileAttributes attributes, FileSecurity fileSecurity, FileMode fileMode, FileSystemRights fileSystemRights, FileShare fileShare, bool checkPath, PathFormat pathFormat) - { - if (checkPath && pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - // When isFile == null, we're working with a device. - // When opening a VOLUME or removable media drive (for example, a floppy disk drive or flash memory thumb drive), - // the path string should be the following form: "\\.\X:" - // Do not use a trailing backslash (\), which indicates the root. - - var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); - - PrivilegeEnabler privilegeEnabler = null; - - - var isAppend = fileMode == FileMode.Append; - - - // CreateFileXxx() does not support FileMode.Append mode. - if (isAppend) - { - fileMode = FileMode.OpenOrCreate; - fileSystemRights &= FileSystemRights.AppendData; // Add right. - } - - - if (fileSecurity != null) - fileSystemRights |= (FileSystemRights) 0x1000000; // Set right. - - // AccessSystemSecurity = 0x1000000 AccessSystemAcl access type. - // MaximumAllowed = 0x2000000 MaximumAllowed access type. - - if ((fileSystemRights & (FileSystemRights) 0x1000000) != 0 || - (fileSystemRights & (FileSystemRights) 0x2000000) != 0) - privilegeEnabler = new PrivilegeEnabler(Privilege.Security); - - - using (privilegeEnabler) - using (var securityAttributes = new Security.NativeMethods.SecurityAttributes(fileSecurity)) - { - var handle = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // CreateFile() / CreateFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - ? NativeMethods.CreateFile(pathLp, fileSystemRights, fileShare, securityAttributes, fileMode, attributes, IntPtr.Zero) - : NativeMethods.CreateFileTransacted(pathLp, fileSystemRights, fileShare, securityAttributes, fileMode, attributes, IntPtr.Zero, transaction.SafeHandle, IntPtr.Zero, IntPtr.Zero); - - var lastError = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - handle.Close(); - NativeError.ThrowException(lastError, pathLp); - } - - - if (isAppend) - { - var stream = new FileStream(handle, FileAccess.Write, NativeMethods.DefaultFileBufferSize, (attributes & ExtendedFileAttributes.Overlapped) != 0); - stream.Seek(0, SeekOrigin.End); - } - - return handle; - } - } - - #endregion // CreateFileCore - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateHardlink.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateHardlink.cs deleted file mode 100644 index d359365..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateHardlink.cs +++ /dev/null @@ -1,129 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region CreateHardlink - - /// [AlphaFS] Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, and only for files, not directories. - /// The name of the new file. This parameter cannot specify the name of a directory. - /// The name of the existing file. This parameter cannot specify the name of a directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - [SecurityCritical] - public static void CreateHardlink(string fileName, string existingFileName, PathFormat pathFormat) - { - CreateHardlinkCore(null, fileName, existingFileName, pathFormat); - } - - /// [AlphaFS] Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, and only for files, not directories. - /// The name of the new file. This parameter cannot specify the name of a directory. - /// The name of the existing file. This parameter cannot specify the name of a directory. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - [SecurityCritical] - public static void CreateHardlink(string fileName, string existingFileName) - { - CreateHardlinkCore(null, fileName, existingFileName, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, - /// and only for files, not directories. - /// - /// The transaction. - /// The name of the new file. This parameter cannot specify the name of a directory. - /// The name of the existing file. This parameter cannot specify the name of a directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - [SecurityCritical] - public static void CreateHardlinkTransacted(KernelTransaction transaction, string fileName, string existingFileName, PathFormat pathFormat) - { - CreateHardlinkCore(transaction, fileName, existingFileName, pathFormat); - } - - /// - /// [AlphaFS] Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, - /// and only for files, not directories. - /// - /// The transaction. - /// The name of the new file. This parameter cannot specify the name of a directory. - /// The name of the existing file. This parameter cannot specify the name of a directory. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - [SecurityCritical] - public static void CreateHardlinkTransacted(KernelTransaction transaction, string fileName, string existingFileName) - { - CreateHardlinkCore(transaction, fileName, existingFileName, PathFormat.RelativePath); - } - - #endregion // CreateHardlink - - #region Internal Methods - - /// Establish a hard link between an existing file and a new file. This function - /// is only supported on the NTFS file system, and only for files, not directories. - /// - /// - /// The transaction. - /// The name of the new file. This parameter cannot specify the name of a directory. - /// The name of the existing file. This parameter cannot specify the name of a directory. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlink")] - [SecurityCritical] - internal static void CreateHardlinkCore(KernelTransaction transaction, string fileName, string existingFileName, PathFormat pathFormat) - { - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - - string fileNameLp = Path.GetExtendedLengthPathCore(transaction, fileName, pathFormat, options); - string existingFileNameLp = Path.GetExtendedLengthPathCore(transaction, existingFileName, pathFormat, options); - - if (!(transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // CreateHardLink() / CreateHardLinkTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - ? NativeMethods.CreateHardLink(fileNameLp, existingFileNameLp, IntPtr.Zero) - : NativeMethods.CreateHardLinkTransacted(fileNameLp, existingFileNameLp, IntPtr.Zero, transaction.SafeHandle))) - { - int lastError = Marshal.GetLastWin32Error(); - switch ((uint)lastError) - { - case Win32Errors.ERROR_INVALID_FUNCTION: - throw new NotSupportedException(Resources.HardLinks_Not_Supported); - - default: - NativeError.ThrowException(lastError, fileNameLp, existingFileName); - break; - } - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateSymbolicLink.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateSymbolicLink.cs deleted file mode 100644 index 173d772..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateSymbolicLink.cs +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - #region CreateSymbolicLink - - /// [AlphaFS] Creates a symbolic link. - /// See to run this method in an elevated state. - /// The name of the target for the symbolic link to be created. - /// The symbolic link to be created. - /// Indicates whether the link target, , is a file or directory. - /// Indicates the format of the path parameter(s). - /// - /// Several Exceptions possible. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "symlink")] - [SecurityCritical] - public static void CreateSymbolicLink(string symlinkFileName, string targetFileName, SymbolicLinkTarget targetType, PathFormat pathFormat) - { - CreateSymbolicLinkCore(null, symlinkFileName, targetFileName, targetType, pathFormat); - } - - /// [AlphaFS] Creates a symbolic link. - /// See to run this method in an elevated state. - /// The name of the target for the symbolic link to be created. - /// The symbolic link to be created. - /// Indicates whether the link target, , is a file or directory. - /// - /// Several Exceptions possible. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "symlink")] - [SecurityCritical] - public static void CreateSymbolicLink(string symlinkFileName, string targetFileName, SymbolicLinkTarget targetType) - { - CreateSymbolicLinkCore(null, symlinkFileName, targetFileName, targetType, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a symbolic link. - /// See to run this method in an elevated state. - /// The transaction. - /// The name of the target for the symbolic link to be created. - /// The symbolic link to be created. - /// Indicates whether the link target, , is a file or directory. - /// Indicates the format of the path parameter(s). - /// - /// Several Exceptions possible. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "symlink")] - [SecurityCritical] - public static void CreateSymbolicLinkTransacted(KernelTransaction transaction, string symlinkFileName, string targetFileName, SymbolicLinkTarget targetType, PathFormat pathFormat) - { - CreateSymbolicLinkCore(transaction, symlinkFileName, targetFileName, targetType, pathFormat); - } - - - /// [AlphaFS] Creates a symbolic link. - /// See to run this method in an elevated state. - /// The transaction. - /// The name of the target for the symbolic link to be created. - /// The symbolic link to be created. - /// Indicates whether the link target, , is a file or directory. - /// - /// Several Exceptions possible. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "symlink")] - [SecurityCritical] - public static void CreateSymbolicLinkTransacted(KernelTransaction transaction, string symlinkFileName, string targetFileName, SymbolicLinkTarget targetType) - { - CreateSymbolicLinkCore(transaction, symlinkFileName, targetFileName, targetType, PathFormat.RelativePath); - } - - #endregion // CreateSymbolicLink - - #region Internal Methods - - /// Creates a symbolic link. - /// See to run this method in an elevated state. - /// The transaction. - /// The name of the target for the symbolic link to be created. - /// The symbolic link to be created. - /// Indicates whether the link target, , is a file or directory. - /// Indicates the format of the path parameter(s). - /// - /// Several Exceptions possible. - [SecurityCritical] - internal static void CreateSymbolicLinkCore(KernelTransaction transaction, string symlinkFileName, string targetFileName, SymbolicLinkTarget targetType, PathFormat pathFormat) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - - string symlinkFileNameLp = Path.GetExtendedLengthPathCore(transaction, symlinkFileName, pathFormat, options); - string targetFileNameRp = Path.GetExtendedLengthPathCore(transaction, targetFileName, pathFormat, options); - - // Don't use long path notation, as it will be empty upon creation. - targetFileNameRp = Path.GetRegularPathCore(targetFileNameRp, GetFullPathOptions.None, false); - - - if (!(transaction == null - - // CreateSymbolicLink() / CreateSymbolicLinkTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-02-14: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - // 2015-07-17: This function does not support long paths. - - ? NativeMethods.CreateSymbolicLink(symlinkFileNameLp, targetFileNameRp, targetType) - : NativeMethods.CreateSymbolicLinkTransacted(symlinkFileNameLp, targetFileNameRp, targetType, transaction.SafeHandle))) - { - var lastError = Marshal.GetLastWin32Error(); - if (lastError != 0) - NativeError.ThrowException(lastError, symlinkFileNameLp, targetFileNameRp); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateText.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateText.cs deleted file mode 100644 index b73d06f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.CreateText.cs +++ /dev/null @@ -1,110 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; -using StreamWriter = System.IO.StreamWriter; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Public Methods - - /// Creates or opens a file for writing UTF-8 encoded text. - /// The file to be opened for writing. - /// A StreamWriter that writes to the specified file using UTF-8 encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamWriter CreateText(string path) - { - return CreateTextCore(null, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates or opens a file for writing UTF-8 encoded text. - /// The file to be opened for writing. - /// Indicates the format of the path parameter(s). - /// A StreamWriter that writes to the specified file using UTF-8 encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamWriter CreateText(string path, PathFormat pathFormat) - { - return CreateTextCore(null, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// [AlphaFS] Creates or opens a file for writing encoded text. - /// The file to be opened for writing. - /// The encoding that is applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// A StreamWriter that writes to the specified file using UTF-8 encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamWriter CreateText(string path, Encoding encoding, PathFormat pathFormat) - { - return CreateTextCore(null, path, encoding, pathFormat); - } - - /// [AlphaFS] Creates or opens a file for writing UTF-8 encoded text. - /// The transaction. - /// The file to be opened for writing. - /// A StreamWriter that writes to the specified file using UTF-8 encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamWriter CreateTextTransacted(KernelTransaction transaction, string path) - { - return CreateTextCore(transaction, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates or opens a file for writing encoded text. - /// The transaction. - /// The file to be opened for writing. - /// The encoding that is applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// A StreamWriter that writes to the specified file using UTF-8 encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamWriter CreateTextTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return CreateTextCore(transaction, path, encoding, pathFormat); - } - - #endregion - - #region Internal Methods - - /// Creates or opens a file for writing encoded text. - /// The transaction. - /// The file to be opened for writing. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// A that writes to the specified file using NativeMethods.DefaultFileBufferSize encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static StreamWriter CreateTextCore(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return new StreamWriter(CreateFileStreamCore(transaction, path, ExtendedFileAttributes.SequentialScan, null, FileMode.Create, FileAccess.Write, FileShare.Read, NativeMethods.DefaultFileBufferSize, pathFormat), encoding); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Delete.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Delete.cs deleted file mode 100644 index 9e375d6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Delete.cs +++ /dev/null @@ -1,238 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Delete - - /// Deletes the specified file. - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// The name of the file to be deleted. Wildcard characters are not supported. - /// - /// - /// - /// - /// - [SecurityCritical] - public static void Delete(string path) - { - DeleteFileCore(null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes the specified file. - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// The name of the file to be deleted. Wildcard characters are not supported. - /// - /// - /// overrides the read only of the file. - /// - /// Indicates the format of the path parameter(s). - /// - /// - /// - /// - [SecurityCritical] - public static void Delete(string path, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteFileCore(null, path, ignoreReadOnly, pathFormat); - } - - - /// [AlphaFS] Deletes the specified file. - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// The name of the file to be deleted. Wildcard characters are not supported. - /// - /// - /// overrides the read only of the file. - /// - /// - /// - /// - /// - [SecurityCritical] - public static void Delete(string path, bool ignoreReadOnly) - { - DeleteFileCore(null, path, ignoreReadOnly, PathFormat.RelativePath); - } - - #region Transactional - - /// [AlphaFS] Deletes the specified file. - /// If the file to be deleted does not exist, no exception is thrown. - /// The transaction. - /// - /// The name of the file to be deleted. Wildcard characters are not supported. - /// - /// - /// - /// - /// - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path) - { - DeleteFileCore(transaction, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Deletes the specified file. - /// The transaction. - /// The name of the file to be deleted. Wildcard characters are not supported. - /// overrides the read only of the file. - /// Indicates the format of the path parameter(s). - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// - /// - /// - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool ignoreReadOnly, PathFormat pathFormat) - { - DeleteFileCore(transaction, path, ignoreReadOnly, pathFormat); - } - - /// [AlphaFS] Deletes the specified file. - /// The transaction. - /// The name of the file to be deleted. Wildcard characters are not supported. - /// overrides the read only of the file. - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// - /// - /// - [SecurityCritical] - public static void DeleteTransacted(KernelTransaction transaction, string path, bool ignoreReadOnly) - { - DeleteFileCore(transaction, path, ignoreReadOnly, PathFormat.RelativePath); - } - - #endregion // Transacted - - #endregion // Delete - - #region Internal Methods - - /// Deletes a Non-/Transacted file. - /// If the file to be deleted does not exist, no exception is thrown. - /// - /// - /// - /// - /// The transaction. - /// The name of the file to be deleted. - /// overrides the read only of the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void DeleteFileCore(KernelTransaction transaction, string path, bool ignoreReadOnly, PathFormat pathFormat) - { - #region Setup - - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator); - - // If the path points to a symbolic link, the symbolic link is deleted, not the target. - - #endregion // Setup - - startDeleteFile: - - if (!(transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // DeleteFile() / DeleteFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - ? NativeMethods.DeleteFile(pathLp) - : NativeMethods.DeleteFileTransacted(pathLp, transaction.SafeHandle))) - { - int lastError = Marshal.GetLastWin32Error(); - switch ((uint)lastError) - { - case Win32Errors.ERROR_FILE_NOT_FOUND: - // MSDN: .NET 3.5+: If the file to be deleted does not exist, no exception is thrown. - return; - - case Win32Errors.ERROR_PATH_NOT_FOUND: - // MSDN: .NET 3.5+: DirectoryNotFoundException: The specified path is invalid (for example, it is on an unmapped drive). - NativeError.ThrowException(lastError, pathLp); - return; - - case Win32Errors.ERROR_SHARING_VIOLATION: - // MSDN: .NET 3.5+: IOException: The specified file is in use or there is an open handle on the file. - NativeError.ThrowException(lastError, pathLp); - break; - - case Win32Errors.ERROR_ACCESS_DENIED: - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - int dataInitialised = FillAttributeInfoCore(transaction, pathLp, ref data, false, true); - - if (data.dwFileAttributes != (FileAttributes)(-1)) - { - if ((data.dwFileAttributes & FileAttributes.Directory) != 0) - // MSDN: .NET 3.5+: UnauthorizedAccessException: Path is a directory. - throw new UnauthorizedAccessException(string.Format(CultureInfo.CurrentCulture, "({0}) {1}", - Win32Errors.ERROR_INVALID_PARAMETER, string.Format(CultureInfo.CurrentCulture, Resources.Target_File_Is_A_Directory, pathLp))); - - - if ((data.dwFileAttributes & FileAttributes.ReadOnly) != 0) - { - if (ignoreReadOnly) - { - // Reset file attributes. - SetAttributesCore(false, transaction, pathLp, FileAttributes.Normal, PathFormat.LongFullPath); - goto startDeleteFile; - } - - // MSDN: .NET 3.5+: UnauthorizedAccessException: Path specified a read-only file. - throw new FileReadOnlyException(pathLp); - } - } - - if (dataInitialised == Win32Errors.ERROR_SUCCESS) - // MSDN: .NET 3.5+: UnauthorizedAccessException: The caller does not have the required permission. - NativeError.ThrowException(lastError, pathLp); - - break; - } - - // MSDN: .NET 3.5+: IOException: - // The specified file is in use. - // There is an open handle on the file, and the operating system is Windows XP or earlier. - - NativeError.ThrowException(lastError, pathLp); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptDecrypt.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptDecrypt.cs deleted file mode 100644 index 835fa76..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptDecrypt.cs +++ /dev/null @@ -1,120 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Public Methods - - /// Decrypts a file that was encrypted by the current account using the Encrypt method. - /// A path that describes a file to decrypt. - [SecurityCritical] - public static void Decrypt(string path) - { - EncryptDecryptFileCore(false, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Decrypts a file that was encrypted by the current account using the Encrypt method. - /// A path that describes a file to decrypt. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Decrypt(string path, PathFormat pathFormat) - { - EncryptDecryptFileCore(false, path, false, pathFormat); - } - - /// Encrypts a file so that only the account used to encrypt the file can decrypt it. - /// A path that describes a file to encrypt. - [SecurityCritical] - public static void Encrypt(string path) - { - EncryptDecryptFileCore(false, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Encrypts a file so that only the account used to encrypt the file can decrypt it. - /// A path that describes a file to encrypt. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void Encrypt(string path, PathFormat pathFormat) - { - EncryptDecryptFileCore(false, path, true, pathFormat); - } - - #endregion - - - - - #region Internal Methods - - /// Decrypts/encrypts a file or directory so that only the account used to encrypt the file can decrypt it. - /// - /// Specifies that is a file or directory. - /// A path that describes a file to encrypt. - /// encrypt, decrypt. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void EncryptDecryptFileCore(bool isFolder, string path, bool encrypt, PathFormat pathFormat) - { - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - // Reset file/directory attributes. - // MSDN: If lpFileName specifies a read-only file, the function fails and GetLastError returns ERROR_FILE_READ_ONLY. - SetAttributesCore(isFolder, null, pathLp, FileAttributes.Normal, PathFormat.LongFullPath); - - // EncryptFile() / DecryptFile() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!(encrypt - ? NativeMethods.EncryptFile(pathLp) - : NativeMethods.DecryptFile(pathLp, 0))) - { - int lastError = Marshal.GetLastWin32Error(); - switch ((uint)lastError) - { - case Win32Errors.ERROR_ACCESS_DENIED: - string root = Path.GetPathRoot(pathLp, false); - if (!string.Equals("NTFS", new DriveInfo(root).DriveFormat, StringComparison.OrdinalIgnoreCase)) - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, "The drive does not support NTFS encryption: [{0}]", root)); - break; - - default: - if (lastError == Win32Errors.ERROR_FILE_NOT_FOUND && isFolder) - lastError = (int)Win32Errors.ERROR_PATH_NOT_FOUND; - - NativeError.ThrowException(lastError, pathLp); - break; - } - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptedFileRaw.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptedFileRaw.cs deleted file mode 100644 index faa5492..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EncryptedFileRaw.cs +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - #region Export - - /// [AlphaFS] Backs up (export) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// The file being backed up is not decrypted; it is backed up in its encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to export encrypted files. See - /// . - /// - /// - /// To backup an encrypted file call one of the - /// overloads and specify the file to backup - /// along with the destination stream of the backup data. - /// - /// - /// This function is intended for the backup of only encrypted files; see for backup - /// of unencrypted files. - /// - /// - /// The name of the file to be backed up. - /// The destination stream to which the backup data will be written. - /// - public static void ExportEncryptedFileRaw(string fileName, Stream outputStream) - { - ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, PathFormat.RelativePath, false); - } - - /// [AlphaFS] Backs up (export) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// The file being backed up is not decrypted; it is backed up in its encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to export encrypted files. See - /// . - /// - /// - /// To backup an encrypted file call one of the - /// overloads and specify the file to backup - /// along with the destination stream of the backup data. - /// - /// - /// This function is intended for the backup of only encrypted files; see for backup - /// of unencrypted files. - /// - /// - /// The name of the file to be backed up. - /// The destination stream to which the backup data will be written. - /// The path format of the parameter. - /// - public static void ExportEncryptedFileRaw(string fileName, Stream outputStream, PathFormat pathFormat) - { - ImportExportEncryptedFileDirectoryRawCore(true, false, outputStream, fileName, pathFormat, false); - } - - #endregion // Export - - #region Import - - /// [AlphaFS] Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to restore encrypted files. See - /// . - /// - /// - /// To restore an encrypted file call one of the - /// overloads and specify the file to restore - /// along with the destination stream of the restored data. - /// - /// - /// This function is intended for the restoration of only encrypted files; see for - /// backup of unencrypted files. - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination file to restore to. - /// - public static void ImportEncryptedFileRaw(Stream inputStream, string destinationFilePath) - { - ImportExportEncryptedFileDirectoryRawCore(false, false, inputStream, destinationFilePath, PathFormat.RelativePath, false); - } - - /// [AlphaFS] Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to restore encrypted files. See - /// . - /// - /// - /// To restore an encrypted file call one of the - /// overloads and specify the file to restore - /// along with the destination stream of the restored data. - /// - /// - /// This function is intended for the restoration of only encrypted files; see for - /// backup of unencrypted files. - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination file to restore to. - /// The path format of the parameter. - /// - public static void ImportEncryptedFileRaw(Stream inputStream, string destinationFilePath, PathFormat pathFormat) - { - ImportExportEncryptedFileDirectoryRawCore(false, false, inputStream, destinationFilePath, pathFormat, false); - } - - - /// [AlphaFS] Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to restore encrypted files. See - /// . - /// - /// - /// To restore an encrypted file call one of the - /// overloads and specify the file to restore - /// along with the destination stream of the restored data. - /// - /// - /// This function is intended for the restoration of only encrypted files; see for - /// backup of unencrypted files. - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination file to restore to. - /// If set to a hidden file will be overwritten on import. - /// - public static void ImportEncryptedFileRaw(Stream inputStream, string destinationFilePath, bool overwriteHidden) - { - ImportExportEncryptedFileDirectoryRawCore(false, false, inputStream, destinationFilePath, PathFormat.RelativePath, overwriteHidden); - } - - /// [AlphaFS] Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is - /// intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// - /// - /// If the caller does not have access to the key for the file, the caller needs - /// to restore encrypted files. See - /// . - /// - /// - /// To restore an encrypted file call one of the - /// overloads and specify the file to restore - /// along with the destination stream of the restored data. - /// - /// - /// This function is intended for the restoration of only encrypted files; see for - /// backup of unencrypted files. - /// - /// - /// The stream to read previously backed up data from. - /// The path of the destination file to restore to. - /// If set to a hidden file will be overwritten on import. - /// The path format of the parameter. - /// - public static void ImportEncryptedFileRaw(Stream inputStream, string destinationFilePath, bool overwriteHidden, PathFormat pathFormat) - { - ImportExportEncryptedFileDirectoryRawCore(false, false, inputStream, destinationFilePath, pathFormat, overwriteHidden); - } - - #endregion // Import - - - - - internal static void ImportExportEncryptedFileDirectoryRawCore(bool isExport, bool isFolder, Stream stream, string destinationPath, PathFormat pathFormat, bool overwriteHidden) - { - string destinationPathLp = Path.GetExtendedLengthPathCore(null, destinationPath, pathFormat, GetFullPathOptions.FullCheck | GetFullPathOptions.TrimEnd); - - NativeMethods.EncryptedFileRawMode mode = isExport - ? NativeMethods.EncryptedFileRawMode.CreateForExport - : NativeMethods.EncryptedFileRawMode.CreateForImport; - - if (isFolder) - mode = mode | NativeMethods.EncryptedFileRawMode.CreateForDir; - - if (overwriteHidden) - mode = mode | NativeMethods.EncryptedFileRawMode.OverwriteHidden; - - - // OpenEncryptedFileRaw() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2015-08-02: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - SafeEncryptedFileRawHandle context; - var lastError = NativeMethods.OpenEncryptedFileRaw(destinationPathLp, mode, out context); - - try - { - if (lastError != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(lastError, destinationPathLp); - - - lastError = isExport - ? NativeMethods.ReadEncryptedFileRaw((pbData, pvCallbackContext, length) => - { - try - { - var data = new byte[length]; - - Marshal.Copy(pbData, data, 0, (int) length); - - stream.Write(data, 0, (int) length); - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex) & NativeMethods.OverflowExceptionBitShift; - } - - return (int) Win32Errors.ERROR_SUCCESS; - - }, IntPtr.Zero, context) - - - : NativeMethods.WriteEncryptedFileRaw((IntPtr pbData, IntPtr pvCallbackContext, ref uint length) => - { - try - { - var data = new byte[length]; - - length = (uint) stream.Read(data, 0, (int) length); - if (length == 0) - return (int) Win32Errors.ERROR_SUCCESS; - - Marshal.Copy(data, 0, pbData, (int) length); - } - catch (Exception ex) - { - return Marshal.GetHRForException(ex) & NativeMethods.OverflowExceptionBitShift; - } - - return (int) Win32Errors.ERROR_SUCCESS; - - }, IntPtr.Zero, context); - - - if (lastError != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(lastError, destinationPathLp); - } - finally - { - if (context != null) - context.Dispose(); - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs deleted file mode 100644 index 788a67e..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateAlternateDataStreams.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. - /// The path to the file to enumerate streams of. - /// The streams of type :$DATA in the specified file. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreams(string path) - { - return EnumerateAlternateDataStreamsCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. - /// The path to the file to enumerate streams of. - /// Indicates the format of the path parameter(s). - /// The streams of type :$DATA in the specified file. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreams(string path, PathFormat pathFormat) - { - return EnumerateAlternateDataStreamsCore(null, path, pathFormat); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. - /// The transaction. - /// The path to the file to enumerate streams of. - /// The streams of type :$DATA in the specified file. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path) - { - return EnumerateAlternateDataStreamsCore(transaction, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file. - /// The transaction. - /// The path to the file to enumerate streams of. - /// Indicates the format of the path parameter(s). - /// The streams of type :$DATA in the specified file. - [SecurityCritical] - public static IEnumerable EnumerateAlternateDataStreamsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateAlternateDataStreamsCore(transaction, path, pathFormat); - } - - - - - #region Internal Methods - - /// [AlphaFS] Enumerates the streams of type :$DATA from the specified file or directory. - /// The transaction. - /// The path to the file or directory to enumerate streams of. - /// Indicates the format of the path parameter(s). - /// The streams of type :$DATA in the specified file or directory. - internal static IEnumerable EnumerateAlternateDataStreamsCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - using (var buffer = new SafeGlobalMemoryBufferHandle(Marshal.SizeOf(typeof(NativeMethods.WIN32_FIND_STREAM_DATA)))) - { - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, - GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars | - GetFullPathOptions.CheckAdditional); - - using (SafeFindFileHandle handle = transaction == null - ? NativeMethods.FindFirstStreamW(pathLp, NativeMethods.STREAM_INFO_LEVELS.FindStreamInfoStandard, buffer, 0) - : NativeMethods.FindFirstStreamTransactedW(pathLp, NativeMethods.STREAM_INFO_LEVELS.FindStreamInfoStandard, buffer, 0, transaction.SafeHandle)) - { - int errorCode = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - if (errorCode == Win32Errors.ERROR_HANDLE_EOF) - yield break; - - NativeError.ThrowException(errorCode); - } - - while (true) - { - yield return new AlternateDataStreamInfo(pathLp, buffer.PtrToStructure(0)); - - if (!NativeMethods.FindNextStreamW(handle, buffer)) - { - int lastError = Marshal.GetLastWin32Error(); - if (lastError == Win32Errors.ERROR_HANDLE_EOF) - break; - - NativeError.ThrowException(lastError, pathLp); - } - } - } - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateHardlinks.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateHardlinks.cs deleted file mode 100644 index e0edb6f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.EnumerateHardlinks.cs +++ /dev/null @@ -1,170 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region EnumerateHardlinks - - /// [AlphaFS] Creates an enumeration of all the hard links to the specified . - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// An enumerable collection of of all the hard links to the specified - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlinks")] - [SecurityCritical] - public static IEnumerable EnumerateHardlinks(string path, PathFormat pathFormat) - { - return EnumerateHardlinksCore(null, path, pathFormat); - } - - /// [AlphaFS] Creates an enumeration of all the hard links to the specified . - /// The name of the file. - /// An enumerable collection of of all the hard links to the specified - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlinks")] - [SecurityCritical] - public static IEnumerable EnumerateHardlinks(string path) - { - return EnumerateHardlinksCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates an enumeration of all the hard links to the specified . - /// The transaction. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// An enumerable collection of of all the hard links to the specified - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlinks")] - [SecurityCritical] - public static IEnumerable EnumerateHardlinksTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return EnumerateHardlinksCore(transaction, path, pathFormat); - } - - /// [AlphaFS] Creates an enumeration of all the hard links to the specified . - /// The transaction. - /// The name of the file. - /// An enumerable collection of of all the hard links to the specified - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Hardlinks")] - [SecurityCritical] - public static IEnumerable EnumerateHardlinksTransacted(KernelTransaction transaction, string path) - { - return EnumerateHardlinksCore(transaction, path, PathFormat.RelativePath); - } - - #endregion // EnumerateHardlinks - - #region Internal Methods - - /// [AlphaFS] Creates an enumeration of all the hard links to the specified . - /// - /// The transaction. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// An enumerable collection of of all the hard links to the specified - internal static IEnumerable EnumerateHardlinksCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - // Default buffer length, will be extended if needed, although this should not happen. - uint length = NativeMethods.MaxPathUnicode; - StringBuilder builder = new StringBuilder((int)length); - - - getFindFirstFileName: - - using (SafeFindFileHandle handle = transaction == null - - // FindFirstFileName() / FindFirstFileNameTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - ? NativeMethods.FindFirstFileName(pathLp, 0, out length, builder) - : NativeMethods.FindFirstFileNameTransacted(pathLp, 0, out length, builder, transaction.SafeHandle)) - { - int lastError = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - handle.Close(); - - switch ((uint) lastError) - { - case Win32Errors.ERROR_MORE_DATA: - builder = new StringBuilder((int) length); - goto getFindFirstFileName; - - default: - // If the function fails, the return value is INVALID_HANDLE_VALUE. - NativeError.ThrowException(lastError, pathLp); - break; - } - } - - yield return builder.ToString(); - - - //length = NativeMethods.MaxPathUnicode; - //builder = new StringBuilder((int)length); - - do - { - while (!NativeMethods.FindNextFileName(handle, out length, builder)) - { - lastError = Marshal.GetLastWin32Error(); - - switch ((uint) lastError) - { - // We've reached the end of the enumeration. - case Win32Errors.ERROR_HANDLE_EOF: - yield break; - - case Win32Errors.ERROR_MORE_DATA: - builder = new StringBuilder((int) length); - continue; - - default: - //If the function fails, the return value is zero (0). - NativeError.ThrowException(lastError); - break; - } - } - - yield return builder.ToString(); - - } while (true); - } - } - - #endregion // Internal Methods - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Exists.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Exists.cs deleted file mode 100644 index fa808cd..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Exists.cs +++ /dev/null @@ -1,228 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Public Methods - - /// Determines whether the specified file exists. - /// - /// MSDN: .NET 3.5+: Trailing spaces are removed from the end of the - /// parameter before checking whether the directory exists. - /// The Exists method returns if any error occurs while trying to - /// determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with - /// invalid characters or too many characters, a failing or missing disk, or if the caller does not have permission to read the - /// file. - /// The Exists method should not be used for path validation, - /// this method merely checks if the file specified in path exists. - /// Passing an invalid path to Exists returns false. - /// Be aware that another process can potentially do something with the file in - /// between the time you call the Exists method and perform another operation on the file, such as Delete. - /// - /// The file to check. - /// - /// Returns if the caller has the required permissions and - /// contains the name of an existing file; otherwise, - /// - /// - [SecurityCritical] - public static bool Exists(string path) - { - return ExistsCore(false, null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Determines whether the specified file exists. - /// - /// MSDN: .NET 3.5+: Trailing spaces are removed from the end of the - /// parameter before checking whether the directory exists. - /// The Exists method returns if any error occurs while trying to - /// determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with - /// invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the - /// file. - /// The Exists method should not be used for path validation, this method merely checks - /// if the file specified in path exists. - /// Passing an invalid path to Exists returns false. - /// Be aware that another process can potentially do something with the file in - /// between the time you call the Exists method and perform another operation on the file, such - /// as Delete. - /// - /// The file to check. - /// Indicates the format of the path parameter(s). - /// - /// Returns if the caller has the required permissions and - /// contains the name of an existing file; otherwise, - /// - /// - [SecurityCritical] - public static bool Exists(string path, PathFormat pathFormat) - { - return ExistsCore(false, null, path, pathFormat); - } - - #region Transactional - - /// - /// [AlphaFS] Determines whether the specified file exists. - /// - /// - /// MSDN: .NET 3.5+: Trailing spaces are removed from the end of the - /// parameter before checking whether the directory exists. - /// The Exists method returns if any error occurs while trying to - /// determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with - /// invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the - /// file. - /// The Exists method should not be used for path validation, - /// this method merely checks if the file specified in path exists. - /// Passing an invalid path to Exists returns false. - /// Be aware that another process can potentially do something with the file in - /// between - /// the time you call the Exists method and perform another operation on the file, such - /// as Delete. - /// - /// The transaction. - /// The file to check. - /// - /// Returns if the caller has the required permissions - /// and contains the name of an existing file; otherwise, - /// - /// - [SecurityCritical] - public static bool ExistsTransacted(KernelTransaction transaction, string path) - { - return ExistsCore(false, transaction, path, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Determines whether the specified file exists. - /// - /// - /// MSDN: .NET 3.5+: Trailing spaces are removed from the end of the - /// parameter before checking whether the directory exists. - /// The Exists method returns if any error occurs while trying to - /// determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with - /// invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the - /// file. - /// The Exists method should not be used for path validation, - /// this method merely checks if the file specified in path exists. - /// Passing an invalid path to Exists returns false. - /// Be aware that another process can potentially do something with the file in - /// between - /// the time you call the Exists method and perform another operation on the file, such - /// as Delete. - /// - /// The transaction. - /// The file to check. - /// Indicates the format of the path parameter(s). - /// - /// Returns if the caller has the required permissions - /// and contains the name of an existing file; otherwise, - /// - /// - [SecurityCritical] - public static bool ExistsTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return ExistsCore(false, transaction, path, pathFormat); - } - - #endregion // Transacted - - #endregion - - #region Internal Methods - - /// Determines whether the specified file or directory exists. - /// - /// MSDN: .NET 3.5+: Trailing spaces are removed from the end of the parameter before checking whether - /// the directory exists. - /// The Exists method returns if any error occurs while trying to determine if the specified file - /// exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// The Exists method should not be used for path validation, - /// this method merely checks if the file specified in path exists. - /// Passing an invalid path to Exists returns false. - /// Be aware that another process can potentially do something with the file in between - /// the time you call the Exists method and perform another operation on the file, such as Delete. - /// - /// Specifies that is a file or directory. - /// The transaction. - /// The file to check. - /// Indicates the format of the path parameter(s). - /// - /// Returns if the caller has the required permissions - /// and contains the name of an existing file or directory; otherwise, - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - internal static bool ExistsCore(bool isFolder, KernelTransaction transaction, string path, PathFormat pathFormat) - { - // Will be caught later and be thrown as an ArgumentException or ArgumentNullException. - // Let's take a shorter route, preventing an Exception from being thrown altogether. - if (Utils.IsNullOrWhiteSpace(path)) - return false; - - - // DriveInfo.IsReady() will fail. - // - //// After normalizing, check whether path ends in directory separator. - //// Otherwise, FillAttributeInfoCore removes it and we may return a false positive. - //string pathRp = Path.GetRegularPathCore(path, true, false, false, false); - - //if (pathRp.Length > 0 && Path.IsDVsc(pathRp[pathRp.Length - 1], false)) - // return false; - - - try - { - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars | GetFullPathOptions.ContinueOnNonExist); - - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - int dataInitialised = FillAttributeInfoCore(transaction, pathLp, ref data, false, true); - - return (dataInitialised == Win32Errors.ERROR_SUCCESS && - data.dwFileAttributes != (FileAttributes) (-1) && - (isFolder - ? (data.dwFileAttributes & FileAttributes.Directory) != 0 - : (data.dwFileAttributes & FileAttributes.Directory) == 0)); - } - catch - { - return false; - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs deleted file mode 100644 index 7ff60e6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAccessControl.cs +++ /dev/null @@ -1,255 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - /// Gets a object that encapsulates the access control list (ACL) entries for a specified file. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a file containing a object that describes the file's access control list (ACL) information. - [SecurityCritical] - public static FileSecurity GetAccessControl(string path) - { - return GetAccessControlCore(false, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.RelativePath); - } - - /// Gets a object that encapsulates the access control list (ACL) entries for a specified file. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a file containing a object that describes the file's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - [SecurityCritical] - public static FileSecurity GetAccessControl(string path, AccessControlSections includeSections) - { - return GetAccessControlCore(false, path, includeSections, PathFormat.RelativePath); - } - - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a file containing a object that describes the file's access control list (ACL) information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static FileSecurity GetAccessControl(string path, PathFormat pathFormat) - { - return GetAccessControlCore(false, path, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, pathFormat); - } - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// The path to a file containing a object that describes the file's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static FileSecurity GetAccessControl(string path, AccessControlSections includeSections, PathFormat pathFormat) - { - return GetAccessControlCore(false, path, includeSections, pathFormat); - } - - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file handle. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// A to a file containing a object that describes the file's access control list (ACL) information. - [SecurityCritical] - public static FileSecurity GetAccessControl(SafeFileHandle handle) - { - return GetAccessControlHandleCore(false, false, handle, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, SecurityInformation.None); - } - - /// [AlphaFS] Gets a object that encapsulates the access control list (ACL) entries for a specified file handle. - /// A object that encapsulates the access control rules for the file described by the parameter. - /// - /// - /// - /// A to a file containing a object that describes the file's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - [SecurityCritical] - public static FileSecurity GetAccessControl(SafeFileHandle handle, AccessControlSections includeSections) - { - return GetAccessControlHandleCore(false, false, handle, includeSections, SecurityInformation.None); - } - - - - - /// [AlphaFS] Gets an object for a particular file or directory. - /// An object that encapsulates the access control rules for the file or directory described by the parameter. - /// - /// - /// - /// Generic type parameter. - /// Specifies that is a file or directory. - /// The path to a file/directory containing a / object that describes the file's/directory's access control list (ACL) information. - /// One (or more) of the values that specifies the type of access control list (ACL) information to receive. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Disposing is controlled.")] - [SecurityCritical] - internal static T GetAccessControlCore(bool isFolder, string path, AccessControlSections includeSections, PathFormat pathFormat) - { - SecurityInformation securityInfo = CreateSecurityInformation(includeSections); - - - // We need the SE_SECURITY_NAME privilege enabled to be able to get the SACL descriptor. - // So we enable it here for the remainder of this function. - - PrivilegeEnabler privilege = null; - - if ((includeSections & AccessControlSections.Audit) != 0) - privilege = new PrivilegeEnabler(Privilege.Security); - - using (privilege) - { - IntPtr pSidOwner, pSidGroup, pDacl, pSacl; - SafeGlobalMemoryBufferHandle pSecurityDescriptor; - - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - - // Get/SetNamedSecurityInfo does not work with a handle but with a path, hence does not honor the privileges. - // It magically does since Windows Server 2012 / 8 but not in previous OS versions. - - uint lastError = Security.NativeMethods.GetNamedSecurityInfo(pathLp, ObjectType.FileObject, securityInfo, - out pSidOwner, out pSidGroup, out pDacl, out pSacl, out pSecurityDescriptor); - - - // When GetNamedSecurityInfo() fails with ACCESS_DENIED, try again using GetSecurityInfo(). - - if (lastError == Win32Errors.ERROR_ACCESS_DENIED) - using (SafeFileHandle handle = CreateFileCore(null, pathLp, ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, FileSystemRights.Read, FileShare.Read, false, PathFormat.LongFullPath)) - return GetAccessControlHandleCore(true, isFolder, handle, includeSections, securityInfo); - - return GetSecurityDescriptor(lastError, isFolder, pathLp, pSecurityDescriptor); - } - } - - - internal static T GetAccessControlHandleCore(bool internalCall, bool isFolder, SafeFileHandle handle, AccessControlSections includeSections, SecurityInformation securityInfo) - { - if (!internalCall) - securityInfo = CreateSecurityInformation(includeSections); - - - // We need the SE_SECURITY_NAME privilege enabled to be able to get the SACL descriptor. - // So we enable it here for the remainder of this function. - - PrivilegeEnabler privilege = null; - - if (!internalCall && (includeSections & AccessControlSections.Audit) != 0) - privilege = new PrivilegeEnabler(Privilege.Security); - - using (privilege) - { - IntPtr pSidOwner, pSidGroup, pDacl, pSacl; - SafeGlobalMemoryBufferHandle pSecurityDescriptor; - - uint lastError = Security.NativeMethods.GetSecurityInfo(handle, ObjectType.FileObject, securityInfo, - out pSidOwner, out pSidGroup, out pDacl, out pSacl, out pSecurityDescriptor); - - return GetSecurityDescriptor(lastError, isFolder, null, pSecurityDescriptor); - } - } - - - private static SecurityInformation CreateSecurityInformation(AccessControlSections includeSections) - { - var securityInfo = SecurityInformation.None; - - - if ((includeSections & AccessControlSections.Access) != 0) - securityInfo |= SecurityInformation.Dacl; - - if ((includeSections & AccessControlSections.Audit) != 0) - securityInfo |= SecurityInformation.Sacl; - - if ((includeSections & AccessControlSections.Group) != 0) - securityInfo |= SecurityInformation.Group; - - if ((includeSections & AccessControlSections.Owner) != 0) - securityInfo |= SecurityInformation.Owner; - - - return securityInfo; - } - - - private static T GetSecurityDescriptor(uint lastError, bool isFolder, string path, SafeGlobalMemoryBufferHandle securityDescriptor) - { - ObjectSecurity objectSecurity; - - using (securityDescriptor) - { - if (lastError == Win32Errors.ERROR_FILE_NOT_FOUND || lastError == Win32Errors.ERROR_PATH_NOT_FOUND) - lastError = isFolder ? Win32Errors.ERROR_PATH_NOT_FOUND : Win32Errors.ERROR_FILE_NOT_FOUND; - - - // If the function fails, the return value is zero. - if (lastError != Win32Errors.ERROR_SUCCESS) - { - if (!Utils.IsNullOrWhiteSpace(path)) - NativeError.ThrowException(lastError, path); - else - NativeError.ThrowException((int) lastError); - } - - if (!NativeMethods.IsValidHandle(securityDescriptor, false)) - throw new IOException(Resources.Returned_Invalid_Security_Descriptor); - - - uint length = Security.NativeMethods.GetSecurityDescriptorLength(securityDescriptor); - - // Seems not to work: Method .CopyTo: length > Capacity, so an Exception is thrown. - //byte[] managedBuffer = new byte[length]; - //pSecurityDescriptor.CopyTo(managedBuffer, 0, (int) length); - - byte[] managedBuffer = securityDescriptor.ToByteArray(0, (int) length); - - objectSecurity = isFolder ? (ObjectSecurity) new DirectorySecurity() : new FileSecurity(); - objectSecurity.SetSecurityDescriptorBinaryForm(managedBuffer); - } - - return (T) (object) objectSecurity; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAttributes.cs deleted file mode 100644 index b58248c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetAttributes.cs +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetAttributes - - /// Gets the of the file on the path. - /// The path to the file. - /// The of the file on the path. - [SecurityCritical] - public static FileAttributes GetAttributes(string path) - { - return GetAttributesExCore(null, path, PathFormat.RelativePath, true); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The path to the file. - /// Indicates the format of the path parameter(s). - /// The of the file on the path. - [SecurityCritical] - public static FileAttributes GetAttributes(string path, PathFormat pathFormat) - { - return GetAttributesExCore(null, path, pathFormat, true); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The transaction. - /// The path to the file. - /// The of the file on the path. - [SecurityCritical] - public static FileAttributes GetAttributesTransacted(KernelTransaction transaction, string path) - { - return GetAttributesExCore(transaction, path, PathFormat.RelativePath, true); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The transaction. - /// The path to the file. - /// Indicates the format of the path parameter(s). - /// The of the file on the path. - [SecurityCritical] - public static FileAttributes GetAttributesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetAttributesExCore(transaction, path, pathFormat, true); - } - - #endregion - - #region Internal Methods - - /// Gets the or of the specified file or directory. - /// The or of the specified file or directory. - /// - /// - /// Generic type parameter. - /// The transaction. - /// The path to the file or directory. - /// Indicates the format of the path parameter(s). - /// - [SuppressMessage("Microsoft.Interoperability", "CA1404:CallGetLastErrorImmediatelyAfterPInvoke", Justification = "Marshal.GetLastWin32Error() is manipulated.")] - [SecurityCritical] - internal static T GetAttributesExCore(KernelTransaction transaction, string path, PathFormat pathFormat, bool returnErrorOnNotFound) - { - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars); - - var data = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - int dataInitialised = FillAttributeInfoCore(transaction, pathLp, ref data, false, returnErrorOnNotFound); - - if (dataInitialised != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(dataInitialised, pathLp); - - return (T) (typeof (T) == typeof (FileAttributes) ? (object) data.dwFileAttributes : data); - } - - /// - /// Calls NativeMethods.GetFileAttributesEx to retrieve WIN32_FILE_ATTRIBUTE_DATA. - /// Note that classes should use -1 as the uninitialized state for dataInitialized when relying on this method. - /// - /// No path (null, empty string) checking or normalization is performed. - /// . - /// . - /// [in,out]. - /// . - /// . - /// 0 on success, otherwise a Win32 error code. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - internal static int FillAttributeInfoCore(KernelTransaction transaction, string pathLp, ref NativeMethods.WIN32_FILE_ATTRIBUTE_DATA win32AttrData, bool tryagain, bool returnErrorOnNotFound) - { - int dataInitialised = (int)Win32Errors.ERROR_SUCCESS; - - #region Try Again - - // Someone has a handle to the file open, or other error. - if (tryagain) - { - NativeMethods.WIN32_FIND_DATA findData; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - bool error = false; - - SafeFindFileHandle handle = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // FindFirstFileEx() / FindFirstFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - // A trailing backslash is not allowed. - ? NativeMethods.FindFirstFileEx(Path.RemoveTrailingDirectorySeparator(pathLp, false), NativeMethods.FindexInfoLevels, out findData, NativeMethods.FINDEX_SEARCH_OPS.SearchNameMatch, IntPtr.Zero, NativeMethods.LargeCache) - : NativeMethods.FindFirstFileTransacted(Path.RemoveTrailingDirectorySeparator(pathLp, false), NativeMethods.FindexInfoLevels, out findData, NativeMethods.FINDEX_SEARCH_OPS.SearchNameMatch, IntPtr.Zero, NativeMethods.LargeCache, transaction.SafeHandle); - - try - { - if (handle.IsInvalid) - { - error = true; - dataInitialised = Marshal.GetLastWin32Error(); - - if (dataInitialised == Win32Errors.ERROR_FILE_NOT_FOUND || - dataInitialised == Win32Errors.ERROR_PATH_NOT_FOUND || - dataInitialised == Win32Errors.ERROR_NOT_READY) // Floppy device not ready. - { - if (!returnErrorOnNotFound) - { - // Return default value for backward compatibility - dataInitialised = (int)Win32Errors.ERROR_SUCCESS; - win32AttrData.dwFileAttributes = (FileAttributes)(-1); - } - } - - return dataInitialised; - } - } - finally - { - try - { - if (handle != null) - handle.Close(); - } - catch - { - // If we're already returning an error, don't throw another one. - if (!error) - NativeError.ThrowException(dataInitialised, pathLp); - } - } - } - - // Copy the attribute information. - win32AttrData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(findData); - } - - #endregion // Try Again - - else - { - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - if (!(transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // GetFileAttributesEx() / GetFileAttributesTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - ? NativeMethods.GetFileAttributesEx(pathLp, NativeMethods.GetFileExInfoLevels.GetFileExInfoStandard, out win32AttrData) - : NativeMethods.GetFileAttributesTransacted(pathLp, NativeMethods.GetFileExInfoLevels.GetFileExInfoStandard, out win32AttrData, transaction.SafeHandle))) - { - dataInitialised = Marshal.GetLastWin32Error(); - - if (dataInitialised != Win32Errors.ERROR_FILE_NOT_FOUND && - dataInitialised != Win32Errors.ERROR_PATH_NOT_FOUND && - dataInitialised != Win32Errors.ERROR_NOT_READY) // Floppy device not ready. - { - // In case someone latched onto the file. Take the perf hit only for failure. - return FillAttributeInfoCore(transaction, pathLp, ref win32AttrData, true, returnErrorOnNotFound); - } - - if (!returnErrorOnNotFound) - { - // Return default value for backward compbatibility. - dataInitialised = (int)Win32Errors.ERROR_SUCCESS; - win32AttrData.dwFileAttributes = (FileAttributes)(-1); - } - } - } - } - - return dataInitialised; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs deleted file mode 100644 index cd50b43..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetChangeTime.cs +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetChangeTime - - /// [AlphaFS] Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// The file for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTime(string path, PathFormat pathFormat) - { - return GetChangeTimeCore(false, null, null, path, false, pathFormat); - } - - - /// [AlphaFS] Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// The file for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetChangeTime(string path) - { - return GetChangeTimeCore(false, null, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// An open handle to the file or directory from which to retrieve information. - [SecurityCritical] - public static DateTime GetChangeTime(SafeFileHandle safeHandle) - { - return GetChangeTimeCore(false, null, safeHandle, null, false, PathFormat.LongFullPath); - } - - /// [AlphaFS] Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// The transaction. - /// The file for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetChangeTimeCore(false, transaction, null, path, false, pathFormat); - } - - /// [AlphaFS] Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// The transaction. - /// The file for which to obtain creation date and time information. - [SecurityCritical] - public static DateTime GetChangeTimeTransacted(KernelTransaction transaction, string path) - { - return GetChangeTimeCore(false, transaction, null, path, false, PathFormat.RelativePath); - } - - #endregion // GetChangeTime - - #region GetChangeTimeUtc - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in UTC time. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeUtc(string path, PathFormat pathFormat) - { - return GetChangeTimeCore(false, null, null, path, true, pathFormat); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in UTC time. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetChangeTimeUtc(string path) - { - return GetChangeTimeCore(false, null, null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in UTC time. - /// An open handle to the file or directory from which to retrieve information. - [SecurityCritical] - public static DateTime GetChangeTimeUtc(SafeFileHandle safeHandle) - { - return GetChangeTimeCore(false, null, safeHandle, null, true, PathFormat.LongFullPath); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in UTC time. - /// The transaction. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetChangeTimeCore(false, transaction, null, path, true, pathFormat); - } - - /// [AlphaFS] Gets the change date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in UTC time. - /// The transaction. - /// The file for which to obtain change date and time information, in Coordinated Universal Time (UTC) format. - [SecurityCritical] - public static DateTime GetChangeTimeUtcTransacted(KernelTransaction transaction, string path) - { - return GetChangeTimeCore(false, transaction, null, path, true, PathFormat.RelativePath); - } - - #endregion // GetChangeTimeUtc - - #region Internal Methods - - /// Gets the change date and time of the specified file. - /// A structure set to the change date and time for the specified file. This value is expressed in local time. - /// Use either or , not both. - /// - /// - /// - /// Specifies that is a file or directory. - /// The transaction. - /// An open handle to the file or directory from which to retrieve information. - /// The file or directory for which to obtain creation date and time information. - /// gets the Coordinated Universal Time (UTC), gets the local time. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Disposing is under control.")] - [SecurityCritical] - internal static DateTime GetChangeTimeCore(bool isFolder, KernelTransaction transaction, SafeFileHandle safeHandle, string path, bool getUtc, PathFormat pathFormat) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - bool callerHandle = safeHandle != null; - if (!callerHandle) - { - if (pathFormat != PathFormat.LongFullPath && Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars); - - safeHandle = CreateFileCore(transaction, pathLp, isFolder ? ExtendedFileAttributes.BackupSemantics : ExtendedFileAttributes.Normal, null, FileMode.Open, FileSystemRights.ReadData, FileShare.ReadWrite, true, PathFormat.LongFullPath); - } - - - try - { - NativeMethods.IsValidHandle(safeHandle); - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(IntPtr.Size + Marshal.SizeOf(typeof(NativeMethods.FILE_BASIC_INFO)))) - { - NativeMethods.FILE_BASIC_INFO fbi; - - if (!NativeMethods.GetFileInformationByHandleEx_FileBasicInfo(safeHandle, NativeMethods.FileInfoByHandleClass.FileBasicInfo, out fbi, (uint)safeBuffer.Capacity)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - safeBuffer.StructureToPtr(fbi, true); - NativeMethods.FILETIME changeTime = safeBuffer.PtrToStructure(0).ChangeTime; - - return getUtc - ? DateTime.FromFileTimeUtc(changeTime) - : DateTime.FromFileTime(changeTime); - } - } - finally - { - // Handle is ours, dispose. - if (!callerHandle && safeHandle != null) - safeHandle.Close(); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCompressedSize.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCompressedSize.cs deleted file mode 100644 index e470195..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCompressedSize.cs +++ /dev/null @@ -1,134 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetCompressedSize - - /// [AlphaFS] Retrieves the actual number of bytes of disk storage used to store a specified file. - /// - /// If the file is located on a volume that supports compression and the file is compressed, the value obtained is the compressed size - /// of the specified file. If the file is located on a volume that supports sparse files and the file is a sparse file, the value - /// obtained is the sparse size of the specified file. - /// - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// The actual number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetCompressedSize(string path, PathFormat pathFormat) - { - return GetCompressedSizeCore(null, path, pathFormat); - } - - /// [AlphaFS] Retrieves the actual number of bytes of disk storage used to store a specified file. - /// - /// If the file is located on a volume that supports compression and the file is compressed, the value obtained is the compressed size - /// of the specified file. If the file is located on a volume that supports sparse files and the file is a sparse file, the value - /// obtained is the sparse size of the specified file. - /// - /// The name of the file. - /// The actual number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetCompressedSize(string path) - { - return GetCompressedSizeCore(null, path, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Retrieves the actual number of bytes of disk storage used to store a specified file as part of a transaction. If the file - /// is located on a volume that supports compression and the file is compressed, the value obtained is the compressed size of the - /// specified file. If the file is located on a volume that supports sparse files and the file is a sparse file, the value obtained is - /// the sparse size of the specified file. - /// - /// The transaction. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// The actual number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetCompressedSizeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetCompressedSizeCore(transaction, path, pathFormat); - } - - /// - /// [AlphaFS] Retrieves the actual number of bytes of disk storage used to store a specified file as part of a transaction. If the file - /// is located on a volume that supports compression and the file is compressed, the value obtained is the compressed size of the - /// specified file. If the file is located on a volume that supports sparse files and the file is a sparse file, the value obtained is - /// the sparse size of the specified file. - /// - /// The transaction. - /// The name of the file. - /// The actual number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetCompressedSizeTransacted(KernelTransaction transaction, string path) - { - return GetCompressedSizeCore(transaction, path, PathFormat.RelativePath); - } - - #endregion // GetCompressedSize - - #region Internal Methods - - /// Retrieves the actual number of bytes of disk storage used to store a - /// specified file as part of a transaction. If the file is located on a volume that supports compression and the file is compressed, - /// the value obtained is the compressed size of the specified file. If the file is located on a volume that supports sparse files and - /// the file is a sparse file, the value obtained is the sparse size of the specified file. - /// - /// - /// The transaction. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// The actual number of bytes of disk storage used to store the specified file. - [SecurityCritical] - internal static long GetCompressedSizeCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - if (pathFormat != PathFormat.LongFullPath && Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - uint fileSizeHigh; - uint fileSizeLow = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // GetCompressedFileSize() / GetCompressedFileSizeTransacted() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - ? NativeMethods.GetCompressedFileSize(pathLp, out fileSizeHigh) - : NativeMethods.GetCompressedFileSizeTransacted(pathLp, out fileSizeHigh, transaction.SafeHandle); - - // If the function fails, and lpFileSizeHigh is NULL, the return value is INVALID_FILE_SIZE. - if (fileSizeLow == Win32Errors.ERROR_INVALID_FILE_SIZE && fileSizeHigh == 0) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - return NativeMethods.ToLong(fileSizeHigh, fileSizeLow); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCreationTime.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCreationTime.cs deleted file mode 100644 index e9029cb..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetCreationTime.cs +++ /dev/null @@ -1,184 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetCreationTime - - /// Gets the creation date and time of the specified file. - /// The file for which to obtain creation date and time information. - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in - /// local time. - /// - [SecurityCritical] - public static DateTime GetCreationTime(string path) - { - return GetCreationTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the creation date and time of the specified file. - /// The file for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in - /// local time. - /// - [SecurityCritical] - public static DateTime GetCreationTime(string path, PathFormat pathFormat) - { - return GetCreationTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - #region Transactional - - /// [AlphaFS] Gets the creation date and time of the specified file. - /// The transaction. - /// The file for which to obtain creation date and time information. - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in - /// local time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path) - { - return GetCreationTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the creation date and time of the specified file. - /// The transaction. - /// The file for which to obtain creation date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in - /// local time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetCreationTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - #endregion // Transacted - - #endregion - - #region GetCreationTimeUtc - - /// Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// - /// The file for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in UTC - /// time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeUtc(string path) - { - return GetCreationTimeCore(null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// - /// The file for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in UTC - /// time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeUtc(string path, PathFormat pathFormat) - { - return GetCreationTimeCore(null, path, true, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// The transaction. - /// - /// The file for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in UTC - /// time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path) - { - return GetCreationTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) format, of the specified file. - /// The transaction. - /// - /// The file for which to obtain creation date and time information, in Coordinated Universal Time (UTC) format. - /// - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the creation date and time for the specified file. This value is expressed in UTC - /// time. - /// - [SecurityCritical] - public static DateTime GetCreationTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetCreationTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transacted - - #endregion // GetCreationTimeUtc - - #region Internal Methods - - /// - /// [AlphaFS] Gets the creation date and time, in Coordinated Universal Time (UTC) or local time, of the specified file or directory. - /// - /// The transaction. - /// The file or directory for which to obtain creation date and time information. - /// - /// gets the Coordinated Universal Time (UTC), gets the local time. - /// - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the creation date and time for the specified file or directory. Depending on - /// this value is expressed in UTC- or local time. - /// - [SecurityCritical] - internal static DateTime GetCreationTimeCore(KernelTransaction transaction, string path, bool returnUtc, PathFormat pathFormat) - { - NativeMethods.FILETIME creationTime = GetAttributesExCore(transaction, path, pathFormat, false).ftCreationTime; - - return returnUtc - ? DateTime.FromFileTimeUtc(creationTime) - : DateTime.FromFileTime(creationTime); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetEncryptionStatus.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetEncryptionStatus.cs deleted file mode 100644 index 3bdb7dc..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetEncryptionStatus.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// [AlphaFS] Retrieves the encryption status of the specified file. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// The of the specified . - [SecurityCritical] - public static FileEncryptionStatus GetEncryptionStatus(string path, PathFormat pathFormat) - { - return GetEncryptionStatusCore(path, pathFormat); - } - - - /// [AlphaFS] Retrieves the encryption status of the specified file. - /// The name of the file. - /// The of the specified . - [SecurityCritical] - public static FileEncryptionStatus GetEncryptionStatus(string path) - { - return GetEncryptionStatusCore(path, PathFormat.RelativePath); - } - - /// Retrieves the encryption status of the specified file. - /// The name of the file. - /// Indicates the format of the path parameter(s). - /// The of the specified . - [SecurityCritical] - internal static FileEncryptionStatus GetEncryptionStatusCore(string path, PathFormat pathFormat) - { - if (pathFormat != PathFormat.LongFullPath && Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - FileEncryptionStatus status; - - // FileEncryptionStatus() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!NativeMethods.FileEncryptionStatus(pathLp, out status)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - return status; - } - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandleC.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandleC.cs deleted file mode 100644 index de5a585..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileInfoByHandleC.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// [AlphaFS] Retrieves file information for the specified . - /// A connected to the open file from which to retrieve the information. - /// A object containing the requested information. - [SecurityCritical] - public static ByHandleFileInfo GetFileInfoByHandle(SafeFileHandle handle) - { - NativeMethods.IsValidHandle(handle); - - NativeMethods.BY_HANDLE_FILE_INFORMATION info; - - if (!NativeMethods.GetFileInformationByHandle(handle, out info)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - return new ByHandleFileInfo(info); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileSystemEntryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileSystemEntryInfo.cs deleted file mode 100644 index b30e4ec..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetFileSystemEntryInfo.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetFileSystemEntry - - /// [AlphaFS] Gets the of the file on the path. - /// The instance of the file or directory. - /// The path to the file or directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static FileSystemEntryInfo GetFileSystemEntryInfo(string path, PathFormat pathFormat) - { - return GetFileSystemEntryInfoCore(false, null, path, false, pathFormat); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The instance of the file or directory. - /// The path to the file or directory. - [SecurityCritical] - public static FileSystemEntryInfo GetFileSystemEntryInfo(string path) - { - return GetFileSystemEntryInfoCore(false, null, path, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The instance of the file or directory. - /// The transaction. - /// The path to the file or directory. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static FileSystemEntryInfo GetFileSystemEntryInfoTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetFileSystemEntryInfoCore(false, transaction, path, false, pathFormat); - } - - /// [AlphaFS] Gets the of the file on the path. - /// The instance of the file or directory. - /// The transaction. - /// The path to the file or directory. - [SecurityCritical] - public static FileSystemEntryInfo GetFileSystemEntryInfoTransacted(KernelTransaction transaction, string path) - { - return GetFileSystemEntryInfoCore(false, transaction, path, false, PathFormat.RelativePath); - } - - #endregion // GetFileSystemEntry - - #region Internal Methods - - /// Gets a FileSystemEntryInfo from a Non-/Transacted directory/file. - /// The instance of the file or directory, or null on Exception when is true. - /// BasicSearch and LargeCache are used by default, if possible. - /// - /// - /// Specifies that is a file or directory. - /// The transaction. - /// The path to the file or directory. - /// - /// true suppress any Exception that might be thrown as a result from a failure, - /// such as ACLs protected directories or non-accessible reparse points. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static FileSystemEntryInfo GetFileSystemEntryInfoCore(bool isFolder, KernelTransaction transaction, string path, bool continueOnException, PathFormat pathFormat) - { - // Enable BasicSearch and LargeCache by default. - var options = DirectoryEnumerationOptions.BasicSearch | DirectoryEnumerationOptions.LargeCache | (continueOnException ? DirectoryEnumerationOptions.ContinueOnException : 0); - - return (new FindFileSystemEntryInfo(isFolder, transaction, path, Path.WildcardStarMatchAll, options, typeof(FileSystemEntryInfo), pathFormat)).Get(); - } - - #endregion // Internal Methods - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetHash.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetHash.cs deleted file mode 100644 index 68da5d3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetHash.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Globalization; -using System.IO; -using System.Security; -using System.Text; -using Alphaleonis.Win32.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// [AlphaFS] Calculates the hash/checksum for the given . - /// The name of the file. - /// One of the values. - [SecurityCritical] - public static string GetHash(string fileFullPath, HashType hashType) - { - return GetHashCore(null, fileFullPath, hashType, PathFormat.RelativePath); - } - - - /// [AlphaFS] Calculates the hash/checksum for the given . - /// The name of the file. - /// One of the values. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static string GetHash(string fileFullPath, HashType hashType, PathFormat pathFormat) - { - return GetHashCore(null, fileFullPath, hashType, pathFormat); - } - - - /// [AlphaFS] Calculates the hash/checksum for the given . - /// The transaction. - /// The name of the file. - /// One of the values. - [SecurityCritical] - public static string GetHash(KernelTransaction transaction, string fileFullPath, HashType hashType) - { - return GetHashCore(transaction, fileFullPath, hashType, PathFormat.RelativePath); - } - - - /// [AlphaFS] Calculates the hash/checksum for the given . - /// The transaction. - /// The name of the file. - /// One of the values. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static string GetHash(KernelTransaction transaction, string fileFullPath, HashType hashType, PathFormat pathFormat) - { - return GetHashCore(transaction, fileFullPath, hashType, pathFormat); - } - - - - - /// [AlphaFS] Calculates the hash/checksum for the given . - /// The transaction. - /// One of the values. - /// The name of the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static string GetHashCore(KernelTransaction transaction, string fileFullPath, HashType hashType, PathFormat pathFormat) - { - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - var fileNameLp = Path.GetExtendedLengthPathCore(transaction, fileFullPath, pathFormat, options); - - byte[] hash = null; - - - using (var fs = OpenCore(transaction, fileNameLp, FileMode.Open, FileAccess.Read, FileShare.Read, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath)) - { - switch (hashType) - { - case HashType.CRC32: - using (var hType = new Crc32()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.CRC64ISO3309: - using (var hType = new Crc64()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.MD5: - using (var hType = System.Security.Cryptography.MD5.Create()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.RIPEMD160: - using (var hType = System.Security.Cryptography.RIPEMD160.Create()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.SHA1: - using (var hType = System.Security.Cryptography.SHA1.Create()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.SHA256: - using (var hType = System.Security.Cryptography.SHA256.Create()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.SHA384: - using (var hType = System.Security.Cryptography.SHA384.Create()) - hash = hType.ComputeHash(fs); - break; - - - case HashType.SHA512: - using (var hType = System.Security.Cryptography.SHA512.Create()) - hash = hType.ComputeHash(fs); - break; - } - } - - - if (null != hash) - { - var sb = new StringBuilder(hash.Length); - - foreach (byte b in hash) - sb.Append(b.ToString("X2", CultureInfo.InvariantCulture)); - - return sb.ToString().ToUpperInvariant(); - } - - return string.Empty; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastAccessTime.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastAccessTime.cs deleted file mode 100644 index 4779752..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastAccessTime.cs +++ /dev/null @@ -1,180 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetLastAccessTime - - /// Gets the date and time that the specified file was last accessed. - /// The file for which to obtain access date and time information. - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTime(string path) - { - return GetLastAccessTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified file was last accessed. - /// The file for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTime(string path, PathFormat pathFormat) - { - return GetLastAccessTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - - #region Transactional - - /// [AlphaFS] Gets the date and time that the specified file was last accessed. - /// The transaction. - /// The file for which to obtain access date and time information. - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeTransacted(KernelTransaction transaction, string path) - { - return GetLastAccessTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified file was last accessed. - /// The transaction. - /// The file for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetLastAccessTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - - #endregion // Transacted - - #endregion - - #region GetLastAccessTimeUtc - - /// Gets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The file for which to obtain access date and time information. - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeUtc(string path) - { - return GetLastAccessTimeCore(null, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The file for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeUtc(string path, PathFormat pathFormat) - { - return GetLastAccessTimeCore(null, path, true, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The transaction. - /// The file for which to obtain access date and time information. - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path) - { - return GetLastAccessTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The transaction. - /// The file for which to obtain access date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last accessed. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetLastAccessTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transacted - - #endregion // GetLastAccessTimeUtc - - #region Internal Methods - - /// - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) or local time, that the specified file or directory was last - /// accessed. - /// - /// The transaction. - /// The file or directory for which to obtain access date and time information. - /// - /// gets the Coordinated Universal Time (UTC), gets the local time. - /// - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file or directory was last accessed. - /// Depending on this value is expressed in UTC- or local time. - /// - [SecurityCritical] - internal static DateTime GetLastAccessTimeCore(KernelTransaction transaction, string path, bool returnUtc, PathFormat pathFormat) - { - NativeMethods.FILETIME lastAccessTime = GetAttributesExCore(transaction, path, pathFormat, false).ftLastAccessTime; - - return returnUtc - ? DateTime.FromFileTimeUtc(lastAccessTime) - : DateTime.FromFileTime(lastAccessTime); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastWriteTime.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastWriteTime.cs deleted file mode 100644 index 76a4e1d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLastWriteTime.cs +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetLastWriteTime - - /// Gets the date and time that the specified file was last written to. - /// The file for which to obtain write date and time information. - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTime(string path) - { - return GetLastWriteTimeCore(null, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified file was last written to. - /// The file for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTime(string path, PathFormat pathFormat) - { - return GetLastWriteTimeCore(null, path, false, pathFormat).ToLocalTime(); - } - - - #region Transactional - - /// [AlphaFS] Gets the date and time that the specified file was last written to. - /// The transaction. - /// The file for which to obtain write date and time information. - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeTransacted(KernelTransaction transaction, string path) - { - return GetLastWriteTimeCore(transaction, path, false, PathFormat.RelativePath).ToLocalTime(); - } - - /// [AlphaFS] Gets the date and time that the specified file was last written to. - /// The transaction. - /// The file for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in local time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetLastWriteTimeCore(transaction, path, false, pathFormat).ToLocalTime(); - } - - - #endregion // Transacted - - - #endregion // GetLastWriteTime - - #region GetLastWriteTimeUtc - - /// Gets the date and time, in coordinated universal time (UTC) time, that the specified file was last written to. - /// The file for which to obtain write date and time information. - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeUtc(string path) - { - return GetLastWriteTimeCore(null, path, true, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified file was last written to. - /// - /// The file for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeUtc(string path, PathFormat pathFormat) - { - return GetLastWriteTimeCore(null, path, true, pathFormat); - } - - - #region Transactional - - /// - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified file was last written to. - /// - /// The transaction. - /// The file for which to obtain write date and time information. - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path) - { - return GetLastWriteTimeCore(transaction, path, true, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) time, that the specified file was last written to. - /// - /// The transaction. - /// The file for which to obtain write date and time information. - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file was last written to. This value is - /// expressed in UTC time. - /// - [SecurityCritical] - public static DateTime GetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetLastWriteTimeCore(transaction, path, true, pathFormat); - } - - #endregion // Transacted - - - #endregion // GetLastWriteTimeUtc - - #region Internal Methods - - /// - /// [AlphaFS] Gets the date and time, in coordinated universal time (UTC) or local time, that the specified file or directory was last - /// written to. - /// - /// The transaction. - /// The file or directory for which to obtain write date and time information. - /// - /// gets the Coordinated Universal Time (UTC), gets the local time. - /// - /// Indicates the format of the path parameter(s). - /// - /// A structure set to the date and time that the specified file or directory was last written to. - /// Depending on this value is expressed in UTC- or local time. - /// - [SecurityCritical] - internal static DateTime GetLastWriteTimeCore(KernelTransaction transaction, string path, bool getUtc, PathFormat pathFormat) - { - NativeMethods.FILETIME lastWriteTime = GetAttributesExCore(transaction, path, pathFormat, false).ftLastWriteTime; - - return getUtc - ? DateTime.FromFileTimeUtc(lastWriteTime) - : DateTime.FromFileTime(lastWriteTime); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLinkTargetInfo.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLinkTargetInfo.cs deleted file mode 100644 index 4697547..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetLinkTargetInfo.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetLinkTargetInfo - - /// [AlphaFS] Gets information about the target of a mount point or symbolic link on an NTFS file system. - /// The path to the reparse point. - /// Indicates the format of the path parameter(s). - /// - /// An instance of or containing information about the symbolic link - /// or mount point pointed to by . - /// - [SecurityCritical] - public static LinkTargetInfo GetLinkTargetInfo(string path, PathFormat pathFormat) - { - return GetLinkTargetInfoCore(null, path, pathFormat); - } - - /// [AlphaFS] Gets information about the target of a mount point or symbolic link on an NTFS file system. - /// The path to the reparse point. - /// - /// An instance of or containing information about the symbolic link - /// or mount point pointed to by . - /// - [SecurityCritical] - public static LinkTargetInfo GetLinkTargetInfo(string path) - { - return GetLinkTargetInfoCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Gets information about the target of a mount point or symbolic link on an NTFS file system. - /// The transaction. - /// The path to the reparse point. - /// Indicates the format of the path parameter(s). - /// - /// An instance of or containing information about the symbolic link - /// or mount point pointed to by . - /// - [SecurityCritical] - public static LinkTargetInfo GetLinkTargetInfoTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetLinkTargetInfoCore(transaction, path, pathFormat); - } - - /// [AlphaFS] Gets information about the target of a mount point or symbolic link on an NTFS file system. - /// The transaction. - /// The path to the reparse point. - /// - /// An instance of or containing information about the symbolic link - /// or mount point pointed to by . - /// - [SecurityCritical] - public static LinkTargetInfo GetLinkTargetInfoTransacted(KernelTransaction transaction, string path) - { - return GetLinkTargetInfoCore(transaction, path, PathFormat.RelativePath); - } - - #endregion // GetLinkTargetInfo - - #region GetLinkTargetInfoCore - - /// Gets information about the target of a mount point or symbolic link on an NTFS file system. - /// The transaction. - /// The path to the reparse point. - /// Indicates the format of the path parameter(s). - /// - /// An instance of or containing information about the symbolic link - /// or mount point pointed to by . - /// - [SecurityCritical] - internal static LinkTargetInfo GetLinkTargetInfoCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - using (SafeFileHandle safeHandle = CreateFileCore(transaction, path, ExtendedFileAttributes.OpenReparsePoint | ExtendedFileAttributes.BackupSemantics, null, FileMode.Open, 0, FileShare.ReadWrite, true, pathFormat)) - return Device.GetLinkTargetInfoCore(safeHandle); - } - - #endregion // GetLinkTargetInfoCore - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetSize.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetSize.cs deleted file mode 100644 index 95ea703..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.GetSize.cs +++ /dev/null @@ -1,125 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region GetSize - - /// [AlphaFS] Retrieves the file size, in bytes to store a specified file. - /// The path to the file. - /// Indicates the format of the path parameter(s). - /// The file size, in bytes. - [SecurityCritical] - public static long GetSize(string path, PathFormat pathFormat) - { - return GetSizeCore(null, null, path, pathFormat); - } - - /// [AlphaFS] Retrieves the file size, in bytes to store a specified file. - /// The path to the file. - /// The file size, in bytes. - [SecurityCritical] - public static long GetSize(string path) - { - return GetSizeCore(null, null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Retrieves the file size, in bytes to store a specified file. - /// The to the file. - /// The file size, in bytes. - [SecurityCritical] - public static long GetSize(SafeFileHandle handle) - { - return GetSizeCore(null, handle, null, PathFormat.LongFullPath); - } - - /// [AlphaFS] Retrieves the file size, in bytes to store a specified file. - /// The transaction. - /// The path to the file. - /// Indicates the format of the path parameter(s). - /// The number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetSizeTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return GetSizeCore(transaction, null, path, pathFormat); - } - - /// [AlphaFS] Retrieves the file size, in bytes to store a specified file. - /// The transaction. - /// The path to the file. - /// The number of bytes of disk storage used to store the specified file. - [SecurityCritical] - public static long GetSizeTransacted(KernelTransaction transaction, string path) - { - return GetSizeCore(transaction, null, path, PathFormat.RelativePath); - } - - #endregion // GetSize - - #region Internal Methods - - /// Retrieves the file size, in bytes to store a specified file. - /// Use either or , not both. - /// The transaction. - /// The to the file. - /// The path to the file. - /// Indicates the format of the path parameter(s). - /// The number of bytes of disk storage used to store the specified file. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static long GetSizeCore(KernelTransaction transaction, SafeFileHandle safeHandle, string path, PathFormat pathFormat) - { - bool callerHandle = safeHandle != null; - if (!callerHandle) - { - string pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - safeHandle = CreateFileCore(transaction, pathLp, ExtendedFileAttributes.Normal, null, FileMode.Open, FileSystemRights.ReadData, FileShare.Read, true, PathFormat.LongFullPath); - } - - - long fileSize; - - try - { - NativeMethods.GetFileSizeEx(safeHandle, out fileSize); - } - finally - { - // Handle is ours, dispose. - if (!callerHandle && safeHandle != null) - safeHandle.Close(); - } - - return fileSize; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.IsLocked.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.IsLocked.cs deleted file mode 100644 index a2f83c9..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.IsLocked.cs +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - /// [AlphaFS] Determines whether the specified file is in use (locked). - /// Returns if the specified file is in use (locked); otherwise, - /// - /// - /// The file to check. - [SecurityCritical] - public static bool IsLocked(string path) - { - return IsLockedCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Determines whether the specified file is in use (locked). - /// Returns if the specified file is in use (locked); otherwise, - /// - /// - /// - /// The file to check. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static bool IsLocked(string path, PathFormat pathFormat) - { - return IsLockedCore(null, path, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Determines whether the specified file is in use (locked). - /// Returns if the specified file is in use (locked); otherwise, - /// - /// - /// - /// The transaction. - /// The file to check. - [SecurityCritical] - public static bool IsLockedTransacted(KernelTransaction transaction, string path) - { - return IsLockedCore(transaction, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Determines whether the specified file is in use (locked). - /// Returns if the specified file is in use (locked); otherwise, - /// - /// - /// - /// The transaction. - /// The file to check. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static bool IsLockedTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return IsLockedCore(transaction, path, pathFormat); - } - - #endregion // Transactional - - /// [AlphaFS] Determines whether the specified file is in use (locked). - /// Returns if the specified file is in use (locked); otherwise, - /// - /// - /// - /// The transaction. - /// The file to check. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static bool IsLockedCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - try - { - // Use FileAccess.Read since FileAccess.ReadWrite always fails when file is read-only. - using (OpenCore(transaction, path, FileMode.Open, FileAccess.Read, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat)) {} - } - catch (IOException ex) - { - int lastError = Marshal.GetHRForException(ex) & NativeMethods.OverflowExceptionBitShift; - if (lastError == Win32Errors.ERROR_SHARING_VIOLATION || lastError == Win32Errors.ERROR_LOCK_VIOLATION) - return true; - - throw; - } - catch (Exception ex) - { - NativeError.ThrowException(Marshal.GetHRForException(ex) & NativeMethods.OverflowExceptionBitShift); - } - - return false; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Open.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Open.cs deleted file mode 100644 index 5f19df6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Open.cs +++ /dev/null @@ -1,1016 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.IO; -using System.Security; -using System.Security.AccessControl; -using FileStream = System.IO.FileStream; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - #region Using FileAccess - - /// Opens a on the specified path with read/write access. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A opened in the specified mode and path, with read/write access and not shared. - [SecurityCritical] - public static FileStream Open(string path, FileMode mode) - { - return OpenCore(null, path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - /// Opens a on the specified path, with the specified mode and access. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A value that specifies the operations that can be performed on the file. - /// An unshared that provides access to the specified file, with the specified mode and access. - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access) - { - return OpenCore(null, path, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - /// Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// A on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - - /// [AlphaFS] Opens a on the specified path with read/write access. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// Indicates the format of the path parameter(s). - /// A opened in the specified mode and path, with read/write access and not shared. - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, PathFormat pathFormat) - { - return OpenCore(null, path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path, with the specified mode and access. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// Indicates the format of the path parameter(s). - /// - /// An unshared that provides access to the specified file, with the specified mode and access. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// Indicates the format of the path parameter(s). - /// - /// A on the specified path, having the specified mode with read, write, or read/write access and the - /// specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// The extended attributes. - /// Indicates the format of the path parameter(s). - /// - /// A on the specified path, having the specified mode with read, write, or read/write access and the - /// specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, extendedAttributes, null, null, pathFormat); - } - - // New below - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The default buffer size is 4096. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Specifies whether to use asynchronous I/O or synchronous I/O. However, note that the - /// underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be - /// opened synchronously depending on the platform. When opened asynchronously, the BeginRead and BeginWrite methods - /// perform better on large reads or writes, but they might be much slower for small reads or writes. If the - /// application is designed to take advantage of asynchronous I/O, set the useAsync parameter to true. Using - /// asynchronous I/O correctly can speed up applications by as much as a factor of 10, but using it without - /// redesigning the application for asynchronous I/O can decrease performance by as much as a factor of 10. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal | (useAsync ? ExtendedFileAttributes.Overlapped : ExtendedFileAttributes.Normal), bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) - { - return OpenCore(null, path, mode, access, share, (ExtendedFileAttributes) options, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// The extended attributes specifying additional options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes) - { - return OpenCore(null, path, mode, access, share, extendedAttributes, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal, bufferSize, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Specifies whether to use asynchronous I/O or synchronous I/O. However, note that the - /// underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be - /// opened synchronously depending on the platform. When opened asynchronously, the BeginRead and BeginWrite methods - /// perform better on large reads or writes, but they might be much slower for small reads or writes. If the - /// application is designed to take advantage of asynchronous I/O, set the useAsync parameter to true. Using - /// asynchronous I/O correctly can speed up applications by as much as a factor of 10, but using it without - /// redesigning the application for asynchronous I/O can decrease performance by as much as a factor of 10. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, ExtendedFileAttributes.Normal | (useAsync ? ExtendedFileAttributes.Overlapped : ExtendedFileAttributes.Normal), bufferSize, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, (ExtendedFileAttributes) options, bufferSize, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// The extended attributes specifying additional options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(null, path, mode, access, share, extendedAttributes, bufferSize, null, pathFormat); - } - - #endregion // Using FileAccess - - #region Using FileSystemRights - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options) - { - return OpenCore(null, path, mode, rights, share, (ExtendedFileAttributes)options, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes) - { - return OpenCore(null, path, mode, rights, share, extendedAttributes, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// A value that determines the access control and audit security for the file. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity security) - { - return OpenCore(null, path, mode, rights, share, (ExtendedFileAttributes)options, bufferSize, security, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// A value that determines the access control and audit security for the file. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, FileSecurity security) - { - return OpenCore(null, path, mode, rights, share, extendedAttributes, bufferSize, security, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return OpenCore(null, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(null, path, mode, rights, share, extendedAttributes, bufferSize, null, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// A value that determines the access control and audit security for the file. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity security, PathFormat pathFormat) - { - return OpenCore(null, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, security, pathFormat); - } - - /// [AlphaFS] Opens a on the specified path using the specified creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// A value that determines the access control and audit security for the file. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream Open(string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, FileSecurity security, PathFormat pathFormat) - { - return OpenCore(null, path, mode, rights, share, extendedAttributes, bufferSize, security, pathFormat); - } - - #endregion // Using FileSystemRights - - - #region Transactional - - /// [AlphaFS] (Transacted) Opens a on the specified path with read/write access. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A opened in the specified mode and path, with read/write access and not shared. - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode) - { - return OpenCore(transaction, path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path with read/write access. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// Indicates the format of the path parameter(s). - /// A opened in the specified mode and path, with read/write access and not shared. - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, mode == FileMode.Append ? FileAccess.Write : FileAccess.ReadWrite, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - #region Using FileAccess - - /// [AlphaFS] (Transacted) Opens a on the specified path, with the specified mode and access. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// - /// An unshared that provides access to the specified file, with the specified mode and access. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access) - { - return OpenCore(transaction, path, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// - /// A on the specified path, having the specified mode with read, write, or read/write access and the - /// specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path, with the specified mode and access. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// Indicates the format of the path parameter(s). - /// - /// An unshared that provides access to the specified file, with the specified mode and access. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The transaction. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// Indicates the format of the path parameter(s). - /// A on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal, null, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path, having the specified mode with read, write, or read/write access and the specified sharing option. - /// The transaction. - /// The file to open. - /// - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents - /// of existing files are retained or overwritten. - /// - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// The extended attributes. - /// Indicates the format of the path parameter(s). - /// - /// A on the specified path, having the specified mode with read, write, or read/write access and the - /// specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, extendedAttributes, null, null, pathFormat); - } - - // New below - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Specifies whether to use asynchronous I/O or synchronous I/O. However, note that the - /// underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be - /// opened synchronously depending on the platform. When opened asynchronously, the BeginRead and BeginWrite methods - /// perform better on large reads or writes, but they might be much slower for small reads or writes. If the - /// application is designed to take advantage of asynchronous I/O, set the useAsync parameter to true. Using - /// asynchronous I/O correctly can speed up applications by as much as a factor of 10, but using it without - /// redesigning the application for asynchronous I/O can decrease performance by as much as a factor of 10. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal | (useAsync ? ExtendedFileAttributes.Overlapped : ExtendedFileAttributes.Normal), bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) - { - return OpenCore(transaction, path, mode, access, share, (ExtendedFileAttributes) options, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// The extended attributes specifying additional options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes) - { - return OpenCore(transaction, path, mode, access, share, extendedAttributes, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal, bufferSize, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Specifies whether to use asynchronous I/O or synchronous I/O. However, note that the - /// underlying operating system might not support asynchronous I/O, so when specifying true, the handle might be - /// opened synchronously depending on the platform. When opened asynchronously, the BeginRead and BeginWrite methods - /// perform better on large reads or writes, but they might be much slower for small reads or writes. If the - /// application is designed to take advantage of asynchronous I/O, set the useAsync parameter to true. Using - /// asynchronous I/O correctly can speed up applications by as much as a factor of 10, but using it without - /// redesigning the application for asynchronous I/O can decrease performance by as much as a factor of 10. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, bool useAsync, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, ExtendedFileAttributes.Normal | (useAsync ? ExtendedFileAttributes.Overlapped : ExtendedFileAttributes.Normal), bufferSize, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, (ExtendedFileAttributes) options, bufferSize, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// The extended attributes specifying additional options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, access, share, extendedAttributes, bufferSize, null, pathFormat); - } - - #endregion // Using FileAccess - - #region Using FileSystemRights - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options) - { - return OpenCore(transaction, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes) - { - return OpenCore(transaction, path, mode, rights, share, extendedAttributes, bufferSize, null, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// A value that determines the access control and audit security for the file. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity security) - { - return OpenCore(transaction, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, security, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// A value that determines the access control and audit security for the file. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, FileSecurity security) - { - return OpenCore(transaction, path, mode, rights, share, extendedAttributes, bufferSize, security, PathFormat.RelativePath); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, read/write and sharing permission, and buffer size. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, rights, share, extendedAttributes, bufferSize, null, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// A value that specifies additional file options. - /// A value that determines the access control and audit security for the file. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, FileOptions options, FileSecurity security, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, rights, share, (ExtendedFileAttributes) options, bufferSize, security, pathFormat); - } - - /// [AlphaFS] (Transacted) Opens a on the specified path using the specified creation mode, access rights and sharing permission, the buffer size, additional file options, access control and audit security. - /// The transaction. - /// The file to open. - /// A constant that determines how to open or create the file. - /// A value that specifies the operations that can be performed on the - /// file. - /// A constant that determines how the file will be shared by processes. - /// A positive value greater than 0 indicating the buffer size. The - /// default buffer size is 4096. - /// Extended attributes specifying additional options. - /// A value that determines the access control and audit security for the file. - /// Indicates the format of the path parameter. - /// - /// A on the specified path, having the specified mode with read, write, or read/write - /// access and the specified sharing option. - /// - [SecurityCritical] - public static FileStream OpenTransacted(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, int bufferSize, ExtendedFileAttributes extendedAttributes, FileSecurity security, PathFormat pathFormat) - { - return OpenCore(transaction, path, mode, rights, share, extendedAttributes, bufferSize, security, pathFormat); - } - - #endregion // Using FileSystemRights - - #endregion // Transacted - - - #region Internal Methods - - /// [AlphaFS] Opens a on the specified path, having the specified mode with read, write, or read/write access, the specified sharing option and additional options specified. - /// The transaction. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A value that specifies the operations that can be performed on the file. - /// A value specifying the type of access other threads have to the file. - /// Advanced options for this file. - /// A positive value greater than 0 indicating the buffer size. The default buffer size is 4096. - /// The security. - /// Indicates the format of the path parameter(s). - /// - /// A instance on the specified path, having the specified mode with - /// read, write, or read/write access and the specified sharing option. - /// - internal static FileStream OpenCore(KernelTransaction transaction, string path, FileMode mode, FileAccess access, FileShare share, ExtendedFileAttributes attributes, int? bufferSize, FileSecurity security, PathFormat pathFormat) - { - var rights = access == FileAccess.Read - ? FileSystemRights.Read - : (access == FileAccess.Write ? FileSystemRights.Write : FileSystemRights.Read | FileSystemRights.Write); - - - return OpenCore(transaction, path, mode, rights, share, attributes, bufferSize, security, pathFormat); - } - - /// Opens a on the specified path, having the specified mode with read, write, or read/write access, the specified sharing option and additional options specified. - /// The transaction. - /// The file to open. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options. - /// A value specifying the type of access other threads have to the file. - /// Advanced options for this file. - /// A positive value greater than 0 indicating the buffer size. The default buffer size is 4096. - /// The security. - /// Indicates the format of the path parameter(s). - /// - /// A instance on the specified path, having the specified mode with - /// read, write, or read/write access and the specified sharing option. - /// - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - internal static FileStream OpenCore(KernelTransaction transaction, string path, FileMode mode, FileSystemRights rights, FileShare share, ExtendedFileAttributes attributes, int? bufferSize, FileSecurity security, PathFormat pathFormat) - { - var access = ((rights & FileSystemRights.ReadData) != 0 ? FileAccess.Read : 0) | - ((rights & FileSystemRights.WriteData) != 0 || (rights & FileSystemRights.AppendData) != 0 - ? FileAccess.Write - : 0); - - - SafeFileHandle safeHandle = null; - - try - { - safeHandle = CreateFileCore(transaction, path, attributes, security, mode, rights, share, true, pathFormat); - - return new FileStream(safeHandle, access, bufferSize ?? NativeMethods.DefaultFileBufferSize, (attributes & ExtendedFileAttributes.Overlapped) != 0); - } - catch - { - if (safeHandle != null) - safeHandle.Dispose(); - - throw; - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs deleted file mode 100644 index 6922530..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenBackupRead.cs +++ /dev/null @@ -1,70 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes. - /// The file path to open. - /// Indicates the format of the path parameter(s). - /// A on the specified path, having the read-only mode and sharing options. - [SecurityCritical] - public static FileStream OpenBackupRead(string path, PathFormat pathFormat) - { - return OpenCore(null, path, FileMode.Open, FileSystemRights.ReadData, FileShare.None, ExtendedFileAttributes.BackupSemantics | ExtendedFileAttributes.SequentialScan | ExtendedFileAttributes.ReadOnly, null, null, pathFormat); - } - - /// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes. This method is simpler to use then BackupFileStream to read only file's data stream. - /// The file path to open. - /// A on the specified path, having the read-only mode and sharing options. - [SecurityCritical] - public static FileStream OpenBackupRead(string path) - { - return OpenCore(null, path, FileMode.Open, FileSystemRights.ReadData, FileShare.None, ExtendedFileAttributes.BackupSemantics | ExtendedFileAttributes.SequentialScan | ExtendedFileAttributes.ReadOnly, null, null, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes. - /// The transaction. - /// The file path to open. - /// Indicates the format of the path parameter(s). - /// A on the specified path, having the read-only mode and sharing options. - [SecurityCritical] - public static FileStream OpenBackupReadTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return OpenCore(transaction, path, FileMode.Open, FileSystemRights.ReadData, FileShare.None, ExtendedFileAttributes.BackupSemantics | ExtendedFileAttributes.SequentialScan | ExtendedFileAttributes.ReadOnly, null, null, pathFormat); - } - - /// [AlphaFS] Opens the specified file for reading purposes bypassing security attributes. - /// The transaction. - /// The file path to open. - /// A on the specified path, having the read-only mode and sharing options. - [SecurityCritical] - public static FileStream OpenBackupReadTransacted(KernelTransaction transaction, string path) - { - return OpenCore(transaction, path, FileMode.Open, FileSystemRights.ReadData, FileShare.None, ExtendedFileAttributes.BackupSemantics | ExtendedFileAttributes.SequentialScan | ExtendedFileAttributes.ReadOnly, null, null, PathFormat.RelativePath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenRead.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenRead.cs deleted file mode 100644 index 1688f6a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenRead.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; -using FileStream = System.IO.FileStream; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// Opens an existing file for reading. - /// The file to be opened for reading. - /// A read-only on the specified path. - /// - /// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a - /// value of Open, a value of Read and a value of Read. - /// - [SecurityCritical] - public static FileStream OpenRead(string path) - { - return Open(path, FileMode.Open, FileAccess.Read); - } - - /// [AlphaFS] Opens an existing file for reading. - /// The file to be opened for reading. - /// Indicates the format of the path parameter(s). - /// A read-only on the specified path. - /// - /// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a - /// value of Open, a value of Read and a value of Read. - /// - [SecurityCritical] - public static FileStream OpenRead(string path, PathFormat pathFormat) - { - return Open(path, FileMode.Open, FileAccess.Read, pathFormat); - } - - /// [AlphaFS] Opens an existing file for reading. - /// The transaction. - /// The file to be opened for reading. - /// A read-only on the specified path. - /// - /// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a - /// value of Open, a value of Read and a value of Read. - /// - [SecurityCritical] - public static FileStream OpenReadTransacted(KernelTransaction transaction, string path) - { - return OpenTransacted(transaction, path, FileMode.Open, FileAccess.Read); - } - - /// [AlphaFS] Opens an existing file for reading. - /// The transaction. - /// The file to be opened for reading. - /// Indicates the format of the path parameter(s). - /// A read-only on the specified path. - /// - /// This method is equivalent to the (string, FileMode, FileAccess, FileShare) constructor overload with a - /// value of Open, a value of Read and a value of Read. - /// - [SecurityCritical] - public static FileStream OpenReadTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return OpenTransacted(transaction, path, FileMode.Open, FileAccess.Read, pathFormat); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenText.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenText.cs deleted file mode 100644 index 45ca276..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenText.cs +++ /dev/null @@ -1,128 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// Opens an existing UTF-8 encoded text file for reading. - /// The file to be opened for reading. - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamReader OpenText(string path) - { - return new StreamReader(OpenRead(path), NativeMethods.DefaultFileEncoding); - } - - /// [AlphaFS] Opens an existing UTF-8 encoded text file for reading. - /// The file to be opened for reading. - /// Indicates the format of the path parameter(s). - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamReader OpenText(string path, PathFormat pathFormat) - { - return new StreamReader(OpenRead(path, pathFormat), NativeMethods.DefaultFileEncoding); - } - - /// [AlphaFS] Opens an existing encoded text file for reading. - /// The file to be opened for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamReader OpenText(string path, Encoding encoding, PathFormat pathFormat) - { - return new StreamReader(OpenRead(path, pathFormat), encoding); - } - - - /// [AlphaFS] Opens an existing encoded text file for reading. - /// The file to be opened for reading. - /// The applied to the contents of the file. - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public static StreamReader OpenText(string path, Encoding encoding) - { - return new StreamReader(OpenRead(path), encoding); - } - - /// [AlphaFS] Opens an existing UTF-8 encoded text file for reading. - /// The transaction. - /// The file to be opened for reading. - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static StreamReader OpenTextTransacted(KernelTransaction transaction, string path) - { - return new StreamReader(OpenReadTransacted(transaction, path), NativeMethods.DefaultFileEncoding); - } - - /// [AlphaFS] Opens an existing UTF-8 encoded text file for reading. - /// The transaction. - /// The file to be opened for reading. - /// Indicates the format of the path parameter(s). - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static StreamReader OpenTextTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return new StreamReader(OpenReadTransacted(transaction, path, pathFormat), NativeMethods.DefaultFileEncoding); - } - - /// [AlphaFS] Opens an existing encoded text file for reading. - /// The transaction. - /// The file to be opened for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static StreamReader OpenTextTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return new StreamReader(OpenReadTransacted(transaction, path, pathFormat), encoding); - } - - /// [AlphaFS] Opens an existing encoded text file for reading. - /// The transaction. - /// The file to be opened for reading. - /// The applied to the contents of the file. - /// A on the specified path. - /// This method is equivalent to the (String) constructor overload. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - public static StreamReader OpenTextTransacted(KernelTransaction transaction, string path, Encoding encoding) - { - return new StreamReader(OpenReadTransacted(transaction, path), encoding); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenWrite.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenWrite.cs deleted file mode 100644 index 7e3d140..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.OpenWrite.cs +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - /// Opens an existing file or creates a new file for writing. - /// The file to be opened for writing. - /// An unshared object on the specified path with access. - /// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None. - [SecurityCritical] - public static FileStream OpenWrite(string path) - { - return Open(path, FileMode.OpenOrCreate, FileAccess.Write); - } - - /// [AlphaFS] Opens an existing file or creates a new file for writing. - /// The file to be opened for writing. - /// Indicates the format of the path parameter(s). - /// An unshared object on the specified path with access. - /// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None. - [SecurityCritical] - public static FileStream OpenWrite(string path, PathFormat pathFormat) - { - return Open(path, FileMode.OpenOrCreate, FileAccess.Write, pathFormat); - } - - /// [AlphaFS] Opens an existing file or creates a new file for writing. - /// The transaction. - /// The file to be opened for writing. - /// An unshared object on the specified path with access. - /// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None. - [SecurityCritical] - public static FileStream OpenWriteTransacted(KernelTransaction transaction, string path) - { - return OpenTransacted(transaction, path, FileMode.OpenOrCreate, FileAccess.Write); - } - - /// [AlphaFS] Opens an existing file or creates a new file for writing. - /// The transaction. - /// The file to be opened for writing. - /// Indicates the format of the path parameter(s). - /// An unshared object on the specified path with access. - /// This method is equivalent to the (String, FileMode, FileAccess, FileShare) constructor overload with file mode set to OpenOrCreate, the access set to Write, and the share mode set to None. - [SecurityCritical] - public static FileStream OpenWriteTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return OpenTransacted(transaction, path, FileMode.OpenOrCreate, FileAccess.Write, pathFormat); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs deleted file mode 100644 index 47ec283..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllBytes.cs +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Globalization; -using System.IO; -using System.Security; -using FileStream = System.IO.FileStream; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region ReadAllBytes - - /// Opens a binary file, reads the contents of the file into a byte array, and then closes the file. - /// The file to open for reading. - /// A byte array containing the contents of the file. - [SecurityCritical] - public static byte[] ReadAllBytes(string path) - { - return ReadAllBytesCore(null, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a binary file, reads the contents of the file into a byte array, and then closes the file. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// A byte array containing the contents of the file. - [SecurityCritical] - public static byte[] ReadAllBytes(string path, PathFormat pathFormat) - { - return ReadAllBytesCore(null, path, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Opens a binary file, reads the contents of the file into a byte array, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// A byte array containing the contents of the file. - [SecurityCritical] - public static byte[] ReadAllBytesTransacted(KernelTransaction transaction, string path) - { - return ReadAllBytesCore(transaction, path, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a binary file, reads the contents of the file into a byte array, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// A byte array containing the contents of the file. - [SecurityCritical] - public static byte[] ReadAllBytesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return ReadAllBytesCore(transaction, path, pathFormat); - } - - #endregion // Transacted - - #endregion // ReadAllBytes - - #region Internal Methods - - /// Opens a binary file, reads the contents of the file into a byte array, and then closes the file. - /// - /// The transaction. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// A byte array containing the contents of the file. - [SecurityCritical] - internal static byte[] ReadAllBytesCore(KernelTransaction transaction, string path, PathFormat pathFormat) - { - byte[] buffer; - - using (FileStream fs = OpenReadTransacted(transaction, path, pathFormat)) - { - int offset = 0; - long length = fs.Length; - - if (length > int.MaxValue) - throw new IOException(string.Format(CultureInfo.CurrentCulture, "File larger than 2GB: [{0}]", path)); - - int count = (int)length; - buffer = new byte[count]; - while (count > 0) - { - int n = fs.Read(buffer, offset, count); - if (n == 0) - throw new IOException("Unexpected end of file found"); - offset += n; - count -= n; - } - } - return buffer; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllLines.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllLines.cs deleted file mode 100644 index 0633df6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllLines.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Security; -using System.Text; -using StreamReader = System.IO.StreamReader; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region ReadAllLines - - /// Opens a text file, reads all lines of the file, and then closes the file. - /// The file to open for reading. - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLines(string path) - { - return ReadAllLinesCore(null, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath).ToArray(); - } - - /// Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The file to open for reading. - /// The applied to the contents of the file. - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLines(string path, Encoding encoding) - { - return ReadAllLinesCore(null, path, encoding, PathFormat.RelativePath).ToArray(); - } - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLines(string path, PathFormat pathFormat) - { - return ReadAllLinesCore(null, path, NativeMethods.DefaultFileEncoding, pathFormat).ToArray(); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLines(string path, Encoding encoding, PathFormat pathFormat) - { - return ReadAllLinesCore(null, path, encoding, pathFormat).ToArray(); - } - - #region Transactional - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLinesTransacted(KernelTransaction transaction, string path) - { - return ReadAllLinesCore(transaction, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath).ToArray(); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLinesTransacted(KernelTransaction transaction, string path, Encoding encoding) - { - return ReadAllLinesCore(transaction, path, encoding, PathFormat.RelativePath).ToArray(); - } - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLinesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return ReadAllLinesCore(transaction, path, NativeMethods.DefaultFileEncoding, pathFormat).ToArray(); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string[] ReadAllLinesTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return ReadAllLinesCore(transaction, path, encoding, pathFormat).ToArray(); - } - - #endregion // Transacted - - #endregion // ReadAllLines - - #region Internal Methods - - /// Opens a file, read all lines of the file with the specified encoding, and then close the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// An IEnumerable string containing all lines of the file. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static IEnumerable ReadAllLinesCore(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - using (StreamReader sr = new StreamReader(OpenCore(transaction, path, FileMode.Open, FileAccess.Read, FileShare.Read, ExtendedFileAttributes.SequentialScan, null, null, pathFormat), encoding)) - { - string line; - while ((line = sr.ReadLine()) != null) - yield return line; - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllText.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllText.cs deleted file mode 100644 index 938a55a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadAllText.cs +++ /dev/null @@ -1,143 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; -using StreamReader = System.IO.StreamReader; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region ReadAllText - - /// Opens a text file, reads all lines of the file, and then closes the file. - /// The file to open for reading. - /// All lines of the file. - [SecurityCritical] - public static string ReadAllText(string path) - { - return ReadAllTextCore(null, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The file to open for reading. - /// The applied to the contents of the file. - /// All lines of the file. - [SecurityCritical] - public static string ReadAllText(string path, Encoding encoding) - { - return ReadAllTextCore(null, path, encoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string ReadAllText(string path, PathFormat pathFormat) - { - return ReadAllTextCore(null, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string ReadAllText(string path, Encoding encoding, PathFormat pathFormat) - { - return ReadAllTextCore(null, path, encoding, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// All lines of the file. - [SecurityCritical] - public static string ReadAllTextTransacted(KernelTransaction transaction, string path) - { - return ReadAllTextCore(transaction, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// All lines of the file. - [SecurityCritical] - public static string ReadAllTextTransacted(KernelTransaction transaction, string path, Encoding encoding) - { - return ReadAllTextCore(transaction, path, encoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Opens a text file, reads all lines of the file, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string ReadAllTextTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return ReadAllTextCore(transaction, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// [AlphaFS] Opens a file, reads all lines of the file with the specified encoding, and then closes the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SecurityCritical] - public static string ReadAllTextTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return ReadAllTextCore(transaction, path, encoding, pathFormat); - } - - #endregion // Transacted - - #endregion // ReadAllText - - #region Internal Methods - - /// Open a file, read all lines of the file with the specified encoding, and then close the file. - /// The transaction. - /// The file to open for reading. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All lines of the file. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static string ReadAllTextCore(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - using (StreamReader sr = new StreamReader(OpenCore(transaction, path, FileMode.Open, FileAccess.Read, FileShare.Read, ExtendedFileAttributes.SequentialScan, null, null, pathFormat), encoding)) - return sr.ReadToEnd(); - } - - #endregion // Internal Methods - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadLines.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadLines.cs deleted file mode 100644 index e5ac433..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.ReadLines.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; -using StreamReader = System.IO.StreamReader; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region ReadLines - - /// Reads the lines of a file. - /// The file to read. - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLines(string path) - { - return ReadLinesCore(null, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// Read the lines of a file that has a specified encoding. - /// The file to read. - /// The encoding that is applied to the contents of the file. - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLines(string path, Encoding encoding) - { - return ReadLinesCore(null, path, encoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Reads the lines of a file. - /// The file to read. - /// Indicates the format of the path parameter(s). - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLines(string path, PathFormat pathFormat) - { - return ReadLinesCore(null, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// [AlphaFS] Read the lines of a file that has a specified encoding. - /// The file to read. - /// The encoding that is applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLines(string path, Encoding encoding, PathFormat pathFormat) - { - return ReadLinesCore(null, path, encoding, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Reads the lines of a file. - /// The transaction. - /// The file to read. - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLinesTransacted(KernelTransaction transaction, string path) - { - return ReadLinesCore(transaction, path, NativeMethods.DefaultFileEncoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Read the lines of a file that has a specified encoding. - /// The transaction. - /// The file to read. - /// The encoding that is applied to the contents of the file. - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLinesTransacted(KernelTransaction transaction, string path, Encoding encoding) - { - return ReadLinesCore(transaction, path, encoding, PathFormat.RelativePath); - } - - /// [AlphaFS] Reads the lines of a file. - /// The transaction. - /// The file to read. - /// Indicates the format of the path parameter(s). - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLinesTransacted(KernelTransaction transaction, string path, PathFormat pathFormat) - { - return ReadLinesCore(transaction, path, NativeMethods.DefaultFileEncoding, pathFormat); - } - - /// [AlphaFS] Read the lines of a file that has a specified encoding. - /// The transaction. - /// The file to read. - /// The encoding that is applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All the lines of the file, or the lines that are the result of a query. - [SecurityCritical] - public static IEnumerable ReadLinesTransacted(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - return ReadLinesCore(transaction, path, encoding, pathFormat); - } - - #endregion // Transacted - - #endregion // ReadLines - - #region Internal Methods - - /// Reads the lines of a file that has a specified encoding. - /// The transaction. - /// The file to read. - /// The encoding that is applied to the contents of the file. - /// Indicates the format of the path parameter(s). - /// All the lines of the file, or the lines that are the result of a query. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - internal static IEnumerable ReadLinesCore(KernelTransaction transaction, string path, Encoding encoding, PathFormat pathFormat) - { - using (StreamReader sr = new StreamReader(OpenCore(transaction, path, FileMode.Open, FileAccess.Read, FileShare.Read, ExtendedFileAttributes.SequentialScan, null, null, pathFormat), encoding)) - { - string line; - while ((line = sr.ReadLine()) != null) - yield return line; - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Replace.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.Replace.cs deleted file mode 100644 index 47c5aed..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.Replace.cs +++ /dev/null @@ -1,182 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region Replace - - /// - /// Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of - /// the replaced file. - /// - /// - /// The Replace method replaces the contents of a specified file with the contents of another file. It also creates a backup of the - /// file that was replaced. - /// - /// - /// If the and are on different volumes, this method will - /// raise an exception. If the is on a different volume from the source file, the backup - /// file will be deleted. - /// - /// - /// Pass null to the parameter if you do not want to create a backup of the file being - /// replaced. - /// - /// The name of a file that replaces the file specified by . - /// The name of the file being replaced. - /// The name of the backup file. - [SecurityCritical] - public static void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName) - { - ReplaceCore(sourceFileName, destinationFileName, destinationBackupFileName, false, PathFormat.RelativePath); - } - - /// - /// Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a backup of - /// the replaced file and optionally ignores merge errors. - /// - /// - /// The Replace method replaces the contents of a specified file with the contents of another file. It also creates a backup of the - /// file that was replaced. - /// - /// - /// If the and are on different volumes, this method will - /// raise an exception. If the is on a different volume from the source file, the backup - /// file will be deleted. - /// - /// - /// Pass null to the parameter if you do not want to create a backup of the file being - /// replaced. - /// - /// The name of a file that replaces the file specified by . - /// The name of the file being replaced. - /// The name of the backup file. - /// - /// to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the - /// replacement file; otherwise, . - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest")] - [SecurityCritical] - public static void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) - { - ReplaceCore(sourceFileName, destinationFileName, destinationBackupFileName, ignoreMetadataErrors, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Replaces the contents of a specified file with the contents of another file, deleting the original file, and creating a - /// backup of the replaced file and optionally ignores merge errors. - /// - /// - /// The Replace method replaces the contents of a specified file with the contents of another file. It also creates a backup of the - /// file that was replaced. - /// - /// - /// If the and are on different volumes, this method will - /// raise an exception. If the is on a different volume from the source file, the backup - /// file will be deleted. - /// - /// - /// Pass null to the parameter if you do not want to create a backup of the file being - /// replaced. - /// - /// The name of a file that replaces the file specified by . - /// The name of the file being replaced. - /// The name of the backup file. - /// - /// to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the - /// replacement file; otherwise, . - /// - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dest")] - [SecurityCritical] - public static void Replace(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors, PathFormat pathFormat) - { - ReplaceCore(sourceFileName, destinationFileName, destinationBackupFileName, ignoreMetadataErrors, pathFormat); - } - - #endregion // Replace - - #region ReplaceCore - - /// Replaces the contents of a specified file with the contents of another file, deleting - /// the original file, and creating a backup of the replaced file and optionally ignores merge errors. - /// - /// - /// The Replace method replaces the contents of a specified file with the contents of another file. It also creates a backup of the - /// file that was replaced. - /// - /// - /// If the and are on different volumes, this method will - /// raise an exception. If the is on a different volume from the source file, the backup - /// file will be deleted. - /// - /// - /// Pass null to the parameter if you do not want to create a backup of the file being - /// replaced. - /// - /// The name of a file that replaces the file specified by . - /// The name of the file being replaced. - /// The name of the backup file. - /// - /// to ignore merge errors (such as attributes and access control lists (ACLs)) from the replaced file to the - /// replacement file; otherwise, . - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void ReplaceCore(string sourceFileName, string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors, PathFormat pathFormat) - { - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - - string sourceFileNameLp = Path.GetExtendedLengthPathCore(null, sourceFileName, pathFormat, options); - string destinationFileNameLp = Path.GetExtendedLengthPathCore(null, destinationFileName, pathFormat, options); - - // Pass null to the destinationBackupFileName parameter if you do not want to create a backup of the file being replaced. - string destinationBackupFileNameLp = destinationBackupFileName == null - ? null - : Path.GetExtendedLengthPathCore(null, destinationBackupFileName, pathFormat, options); - - const int replacefileWriteThrough = 1; - const int replacefileIgnoreMergeErrors = 2; - - FileSystemRights dwReplaceFlags = (FileSystemRights) replacefileWriteThrough; - if (ignoreMetadataErrors) - dwReplaceFlags |= (FileSystemRights) replacefileIgnoreMergeErrors; - - // ReplaceFile() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!NativeMethods.ReplaceFile(destinationFileNameLp, sourceFileNameLp, destinationBackupFileNameLp, dwReplaceFlags, IntPtr.Zero, IntPtr.Zero)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), sourceFileNameLp, destinationFileNameLp); - } - - #endregion // ReplaceCore - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAccessControl.cs deleted file mode 100644 index 611ad78..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAccessControl.cs +++ /dev/null @@ -1,264 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class File - { - /// Applies access control list (ACL) entries described by a FileSecurity object to the specified file. - /// - /// - /// - /// A file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the file described by the parameter. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, FileSecurity fileSecurity) - { - SetAccessControlCore(path, null, fileSecurity, AccessControlSections.All, PathFormat.RelativePath); - } - - /// Applies access control list (ACL) entries described by a object to the specified directory. - /// - /// - /// - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, FileSecurity fileSecurity, AccessControlSections includeSections) - { - SetAccessControlCore(path, null, fileSecurity, includeSections, PathFormat.RelativePath); - } - - - /// [AlphaFS] Applies access control list (ACL) entries described by a FileSecurity object to the specified file. - /// - /// - /// - /// A file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the file described by the parameter. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, FileSecurity fileSecurity, PathFormat pathFormat) - { - SetAccessControlCore(path, null, fileSecurity, AccessControlSections.All, pathFormat); - } - - /// [AlphaFS] Applies access control list (ACL) entries described by a object to the specified directory. - /// - /// - /// - /// A directory to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the directory described by the path parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(string path, FileSecurity fileSecurity, AccessControlSections includeSections, PathFormat pathFormat) - { - SetAccessControlCore(path, null, fileSecurity, includeSections, pathFormat); - } - - - /// Applies access control list (ACL) entries described by a FileSecurity object to the specified file. - /// - /// - /// - /// A to a file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the file described by the parameter. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(SafeFileHandle handle, FileSecurity fileSecurity) - { - SetAccessControlCore(null, handle, fileSecurity, AccessControlSections.All, PathFormat.LongFullPath); - } - - /// Applies access control list (ACL) entries described by a FileSecurity object to the specified file. - /// - /// - /// - /// A to a file to add or remove access control list (ACL) entries from. - /// A object that describes an ACL entry to apply to the file described by the parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public static void SetAccessControl(SafeFileHandle handle, FileSecurity fileSecurity, AccessControlSections includeSections) - { - SetAccessControlCore(null, handle, fileSecurity, includeSections, PathFormat.LongFullPath); - } - - - - - /// [AlphaFS] Applies access control list (ACL) entries described by a / object to the specified file or directory. - /// Use either or , not both. - /// - /// - /// - /// A file/directory to add or remove access control list (ACL) entries from. This parameter This parameter may be . - /// A to add or remove access control list (ACL) entries from. This parameter This parameter may be . - /// A / object that describes an ACL entry to apply to the file/directory described by the / parameter. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - [SecurityCritical] - internal static void SetAccessControlCore(string path, SafeFileHandle handle, ObjectSecurity objectSecurity, AccessControlSections includeSections, PathFormat pathFormat) - { - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - if (objectSecurity == null) - throw new ArgumentNullException("objectSecurity"); - - - byte[] managedDescriptor = objectSecurity.GetSecurityDescriptorBinaryForm(); - - using (var safeBuffer = new SafeGlobalMemoryBufferHandle(managedDescriptor.Length)) - { - string pathLp = Path.GetExtendedLengthPathCore(null, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars); - - safeBuffer.CopyFrom(managedDescriptor, 0, managedDescriptor.Length); - - SecurityDescriptorControl control; - uint revision; - - if (!Security.NativeMethods.GetSecurityDescriptorControl(safeBuffer, out control, out revision)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - - PrivilegeEnabler privilegeEnabler = null; - - try - { - var securityInfo = SecurityInformation.None; - IntPtr pDacl = IntPtr.Zero; - - if ((includeSections & AccessControlSections.Access) != 0) - { - bool daclDefaulted, daclPresent; - - if (!Security.NativeMethods.GetSecurityDescriptorDacl(safeBuffer, out daclPresent, out pDacl, out daclDefaulted)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - if (daclPresent) - { - securityInfo |= SecurityInformation.Dacl; - securityInfo |= (control & SecurityDescriptorControl.DaclProtected) != 0 - ? SecurityInformation.ProtectedDacl - : SecurityInformation.UnprotectedDacl; - } - } - - - IntPtr pSacl = IntPtr.Zero; - - if ((includeSections & AccessControlSections.Audit) != 0) - { - bool saclDefaulted, saclPresent; - - if (!Security.NativeMethods.GetSecurityDescriptorSacl(safeBuffer, out saclPresent, out pSacl, out saclDefaulted)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - if (saclPresent) - { - securityInfo |= SecurityInformation.Sacl; - securityInfo |= (control & SecurityDescriptorControl.SaclProtected) != 0 - ? SecurityInformation.ProtectedSacl - : SecurityInformation.UnprotectedSacl; - - privilegeEnabler = new PrivilegeEnabler(Privilege.Security); - } - } - - - IntPtr pOwner = IntPtr.Zero; - - if ((includeSections & AccessControlSections.Owner) != 0) - { - bool ownerDefaulted; - - if (!Security.NativeMethods.GetSecurityDescriptorOwner(safeBuffer, out pOwner, out ownerDefaulted)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - if (pOwner != IntPtr.Zero) - securityInfo |= SecurityInformation.Owner; - } - - - IntPtr pGroup = IntPtr.Zero; - - if ((includeSections & AccessControlSections.Group) != 0) - { - bool groupDefaulted; - - if (!Security.NativeMethods.GetSecurityDescriptorGroup(safeBuffer, out pGroup, out groupDefaulted)) - NativeError.ThrowException(Marshal.GetLastWin32Error(), pathLp); - - if (pGroup != IntPtr.Zero) - securityInfo |= SecurityInformation.Group; - } - - - uint lastError; - - if (!Utils.IsNullOrWhiteSpace(pathLp)) - { - // SetNamedSecurityInfo() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - lastError = Security.NativeMethods.SetNamedSecurityInfo(pathLp, ObjectType.FileObject, securityInfo, pOwner, pGroup, pDacl, pSacl); - - if (lastError != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(lastError, pathLp); - } - else - { - if (NativeMethods.IsValidHandle(handle)) - { - lastError = Security.NativeMethods.SetSecurityInfo(handle, ObjectType.FileObject, securityInfo, pOwner, pGroup, pDacl, pSacl); - - if (lastError != Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException((int) lastError); - } - } - } - finally - { - if (privilegeEnabler != null) - privilegeEnabler.Dispose(); - } - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAttributes.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAttributes.cs deleted file mode 100644 index c8b3afb..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetAttributes.cs +++ /dev/null @@ -1,168 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region SetAttributes - - /// Sets the specified of the file or directory on the specified path. - /// - /// Certain file attributes, such as and , can be combined. - /// Other attributes, such as , must be used alone. - /// - /// - /// It is not possible to change the status of a File object using this method. - /// - /// The path to the file or directory. - /// A bitwise combination of the enumeration values. - /// Sets the specified of the file or directory on the specified path. - [SecurityCritical] - public static void SetAttributes(string path, FileAttributes fileAttributes) - { - SetAttributesCore(false, null, path, fileAttributes, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the specified of the file or directory on the specified path. - /// - /// Certain file attributes, such as and , can be combined. - /// Other attributes, such as , must be used alone. - /// - /// - /// It is not possible to change the status of a File object using this method. - /// - /// The path to the file or directory. - /// A bitwise combination of the enumeration values. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetAttributes(string path, FileAttributes fileAttributes, PathFormat pathFormat) - { - SetAttributesCore(false, null, path, fileAttributes, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Sets the specified of the file on the specified path. - /// - /// Certain file attributes, such as and , can be combined. - /// Other attributes, such as , must be used alone. - /// - /// - /// It is not possible to change the status of a File object using this method. - /// - /// The transaction. - /// The path to the file. - /// A bitwise combination of the enumeration values. - [SecurityCritical] - public static void SetAttributesTransacted(KernelTransaction transaction, string path, FileAttributes fileAttributes) - { - SetAttributesCore(false, transaction, path, fileAttributes, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the specified of the file on the specified path. - /// - /// Certain file attributes, such as and , can be combined. - /// Other attributes, such as , must be used alone. - /// - /// - /// It is not possible to change the status of a File object using this method. - /// - /// The transaction. - /// The path to the file. - /// A bitwise combination of the enumeration values. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetAttributesTransacted(KernelTransaction transaction, string path, FileAttributes fileAttributes, PathFormat pathFormat) - { - SetAttributesCore(false, transaction, path, fileAttributes, pathFormat); - } - - #endregion // Transacted - - #endregion // SetAttributes - - #region Internal Methods - - /// Sets the attributes for a Non-/Transacted file/directory. - /// - /// Certain file attributes, such as and , can be combined. - /// Other attributes, such as , must be used alone. - /// - /// - /// It is not possible to change the status of a File object using the SetAttributes method. - /// - /// - /// Specifies that is a file or directory. - /// The transaction. - /// The name of the file or directory whose attributes are to be set. - /// - /// The attributes to set for the file or directory. Note that all other values override . - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void SetAttributesCore(bool isFolder, KernelTransaction transaction, string path, FileAttributes fileAttributes, PathFormat pathFormat) - { - var pathLp = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - var success = transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // SetFileAttributes() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - ? NativeMethods.SetFileAttributes(pathLp, fileAttributes) - : NativeMethods.SetFileAttributesTransacted(pathLp, fileAttributes, transaction.SafeHandle); - - - var lastError = (uint) Marshal.GetLastWin32Error(); - if (!success) - { - switch (lastError) - { - // MSDN: .NET 3.5+: ArgumentException: FileSystemInfo().Attributes - case Win32Errors.ERROR_INVALID_PARAMETER: - throw new ArgumentException(Resources.Invalid_File_Attribute); - - case Win32Errors.ERROR_FILE_NOT_FOUND: - if (isFolder) - lastError = (int) Win32Errors.ERROR_PATH_NOT_FOUND; - - // MSDN: .NET 3.5+: DirectoryNotFoundException: The specified path is invalid, (for example, it is on an unmapped drive). - // MSDN: .NET 3.5+: FileNotFoundException: The file cannot be found. - NativeError.ThrowException(lastError, pathLp); - break; - } - - NativeError.ThrowException(lastError, pathLp); - } - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetFileTime.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetFileTime.cs deleted file mode 100644 index 30862d4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.SetFileTime.cs +++ /dev/null @@ -1,886 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region SetCreationTime - - /// Sets the date and time the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTime(string path, DateTime creationTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), null, null, modifyReparsePoint, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Sets the date and time the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeTransacted(KernelTransaction transaction, string path, DateTime creationTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), null, null, modifyReparsePoint, pathFormat); - } - - - #endregion // Transacted - - #endregion // SetCreationTime - - #region SetCreationTimeUtc - - /// Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtc(string path, DateTime creationTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, null, null, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, null, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, null, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the file was created. - /// The transaction. - /// The file for which to set the creation date and time information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetCreationTimeUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, null, null, modifyReparsePoint, pathFormat); - } - - #endregion // Transacted - - #endregion // SetCreationTimeUtc - - #region SetLastAccessTime - - /// Sets the date and time that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTime.ToUniversalTime(), null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTime.ToUniversalTime(), null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTime(string path, DateTime lastAccessTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTime.ToUniversalTime(), null, modifyReparsePoint, pathFormat); - } - - - #region Transaction - - /// [AlphaFS] Sets the date and time that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTime.ToUniversalTime(), null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTime.ToUniversalTime(), null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeTransacted(KernelTransaction transaction, string path, DateTime lastAccessTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTime.ToUniversalTime(), null, modifyReparsePoint, pathFormat); - } - - - #endregion // Transaction - - #endregion // SetLastAccessTime - - #region SetLastAccessTimeUtc - - /// Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTimeUtc, null, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTimeUtc, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtc(string path, DateTime lastAccessTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, lastAccessTimeUtc, null, modifyReparsePoint, pathFormat); - } - - - #region Transactional - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTimeUtc, null, false, PathFormat.RelativePath); - } - - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTimeUtc, null, false, pathFormat); - } - - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last accessed. - /// The transaction. - /// The file for which to set the access date and time information. - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastAccessTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastAccessTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, lastAccessTimeUtc, null, modifyReparsePoint, pathFormat); - } - - - #endregion // Transacted - - #endregion // SetLastAccessTimeUtc - - #region SetLastWriteTime - - /// Sets the date and time that the specified file was last written to. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified file was last written to. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified file was last written to. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTime(string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// [AlphaFS] Sets the date and time that the specified file was last written to. - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets the date and time that the specified file was last written to. - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets the date and time that the specified file was last written to. - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeTransacted(KernelTransaction transaction, string path, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - - #endregion // Transacted - - #endregion // SetLastWriteTime - - #region SetLastWriteTimeUtc - - /// Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTimeUtc, false, pathFormat); - } - - /// - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtc(string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #region Transactional - - /// - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTimeUtc, false, pathFormat); - } - - /// - /// [AlphaFS] Sets the date and time, in coordinated universal time (UTC), that the specified file was last written to. - /// - /// The transaction. - /// The file for which to set the date and time information. - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetLastWriteTimeUtcTransacted(KernelTransaction transaction, string path, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, null, null, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - - #endregion // Transacted - - - #endregion // SetLastWriteTimeUtc - - #region SetTimestamps - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestamps(string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in local time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in local time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in local time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsTransacted(KernelTransaction transaction, string path, DateTime creationTime, DateTime lastAccessTime, DateTime lastWriteTime, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTime.ToUniversalTime(), lastAccessTime.ToUniversalTime(), lastWriteTime.ToUniversalTime(), modifyReparsePoint, pathFormat); - } - - #endregion // SetTimestamps - - #region SetTimestampsUtc - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtc(string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, null, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, pathFormat); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Sets all the date and time stamps, in coordinated universal time (UTC), for the specified file, at once. - /// The transaction. - /// The file for which to set the dates and times information. - /// - /// A containing the value to set for the creation date and time of . This value - /// is expressed in UTC time. - /// - /// - /// A containing the value to set for the last access date and time of . This - /// value is expressed in UTC time. - /// - /// - /// A containing the value to set for the last write date and time of . This value - /// is expressed in UTC time. - /// - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void SetTimestampsUtcTransacted(KernelTransaction transaction, string path, DateTime creationTimeUtc, DateTime lastAccessTimeUtc, DateTime lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - SetFsoDateTimeCore(false, transaction, path, creationTimeUtc, lastAccessTimeUtc, lastWriteTimeUtc, modifyReparsePoint, pathFormat); - } - - #endregion // SetTimestampsUtc - - #region Internal Methods - - /// Set the date and time, in coordinated universal time (UTC), that the file or directory was created and/or last accessed and/or written to. - /// - /// - /// Specifies that is a file or directory. - /// The transaction. - /// The file or directory for which to set the date and time information. - /// A containing the value to set for the creation date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last access date and time of . This value is expressed in UTC time. - /// A containing the value to set for the last write date and time of . This value is expressed in UTC time. - /// If , the date and time information will apply to the reparse point (symlink or junction) and not the file or directory linked to. No effect if does not refer to a reparse point. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void SetFsoDateTimeCore(bool isFolder, KernelTransaction transaction, string path, DateTime? creationTimeUtc, DateTime? lastAccessTimeUtc, DateTime? lastWriteTimeUtc, bool modifyReparsePoint, PathFormat pathFormat) - { - // Because we already check here, use false for CreateFileCore() to prevent another check. - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, false, false); - - var attributes = isFolder ? ExtendedFileAttributes.BackupSemantics : ExtendedFileAttributes.Normal; - - if (modifyReparsePoint) - attributes |= ExtendedFileAttributes.OpenReparsePoint; - - using (var creationTime = SafeGlobalMemoryBufferHandle.FromLong(creationTimeUtc.HasValue ? creationTimeUtc.Value.ToFileTimeUtc() : (long?)null)) - using (var lastAccessTime = SafeGlobalMemoryBufferHandle.FromLong(lastAccessTimeUtc.HasValue ? lastAccessTimeUtc.Value.ToFileTimeUtc() : (long?)null)) - using (var lastWriteTime = SafeGlobalMemoryBufferHandle.FromLong(lastWriteTimeUtc.HasValue ? lastWriteTimeUtc.Value.ToFileTimeUtc() : (long?)null)) - using (var safeHandle = CreateFileCore(transaction, path, attributes, null, FileMode.Open, FileSystemRights.WriteAttributes, FileShare.Delete | FileShare.Write, false, pathFormat)) - if (!NativeMethods.SetFileTime(safeHandle, creationTime, lastAccessTime, lastWriteTime)) - NativeError.ThrowException(path); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.TransferTimestamps.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.TransferTimestamps.cs deleted file mode 100644 index 7e54d41..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.TransferTimestamps.cs +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region TransferTimestamps - - /// [AlphaFS] Transfers the date and time stamps for the specified files. - /// This method does not change last access time for the source file. - /// The source file to get the date and time stamps from. - /// The destination file to set the date and time stamps. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void TransferTimestamps(string sourcePath, string destinationPath, PathFormat pathFormat) - { - TransferTimestampsCore(false, null, sourcePath, destinationPath, pathFormat); - } - - /// [AlphaFS] Transfers the date and time stamps for the specified files. - /// This method does not change last access time for the source file. - /// The source file to get the date and time stamps from. - /// The destination file to set the date and time stamps. - [SecurityCritical] - public static void TransferTimestamps(string sourcePath, string destinationPath) - { - TransferTimestampsCore(false, null, sourcePath, destinationPath, PathFormat.RelativePath); - } - - /// [AlphaFS] Transfers the date and time stamps for the specified files. - /// This method does not change last access time for the source file. - /// The transaction. - /// The source file to get the date and time stamps from. - /// The destination file to set the date and time stamps. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void TransferTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat) - { - TransferTimestampsCore(false, transaction, sourcePath, destinationPath, pathFormat); - } - - /// [AlphaFS] Transfers the date and time stamps for the specified files. - /// This method does not change last access time for the source file. - /// The transaction. - /// The source file to get the date and time stamps from. - /// The destination file to set the date and time stamps. - [SecurityCritical] - public static void TransferTimestampsTransacted(KernelTransaction transaction, string sourcePath, string destinationPath) - { - TransferTimestampsCore(false, transaction, sourcePath, destinationPath, PathFormat.RelativePath); - } - - - #endregion // TransferTimestamps - - #region Internal Methods - - /// Transfer the date and time stamps for the specified files and directories. - /// - /// This method does not change last access time for the source file. - /// This method uses BackupSemantics flag to get Timestamp changed for directories. - /// - /// Specifies that and are a file or directory. - /// The transaction. - /// The source path. - /// The destination path. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - internal static void TransferTimestampsCore(bool isFolder, KernelTransaction transaction, string sourcePath, string destinationPath, PathFormat pathFormat) - { - NativeMethods.WIN32_FILE_ATTRIBUTE_DATA attrs = GetAttributesExCore(transaction, sourcePath, pathFormat, true); - - SetFsoDateTimeCore(isFolder, transaction, destinationPath, DateTime.FromFileTimeUtc(attrs.ftCreationTime), DateTime.FromFileTimeUtc(attrs.ftLastAccessTime), DateTime.FromFileTimeUtc(attrs.ftLastWriteTime), false, pathFormat); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteAllBytes.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteAllBytes.cs deleted file mode 100644 index c12c28f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteAllBytes.cs +++ /dev/null @@ -1,119 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using FileStream = System.IO.FileStream; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region WriteAllBytes - - /// - /// Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is - /// overwritten. - /// - /// The file to write to. - /// The bytes to write to the file. - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bytes")] - [SecurityCritical] - public static void WriteAllBytes(string path, byte[] bytes) - { - WriteAllBytesCore(null, path, bytes, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already - /// exists, it is overwritten. - /// - /// The file to write to. - /// The bytes to write to the file. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bytes")] - [SecurityCritical] - public static void WriteAllBytes(string path, byte[] bytes, PathFormat pathFormat) - { - WriteAllBytesCore(null, path, bytes, pathFormat); - } - - #region Transactional - - /// - /// [AlphaFS] Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already - /// exists, it is overwritten. - /// - /// The transaction. - /// The file to write to. - /// The bytes to write to the file. - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bytes")] - [SecurityCritical] - public static void WriteAllBytesTransacted(KernelTransaction transaction, string path, byte[] bytes) - { - WriteAllBytesCore(transaction, path, bytes, PathFormat.RelativePath); - } - - /// - /// [AlphaFS] Creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already - /// exists, it is overwritten. - /// - /// The transaction. - /// The file to write to. - /// The bytes to write to the file. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bytes")] - [SecurityCritical] - public static void WriteAllBytesTransacted(KernelTransaction transaction, string path, byte[] bytes, PathFormat pathFormat) - { - WriteAllBytesCore(transaction, path, bytes, pathFormat); - } - - #endregion // Transacted - - #endregion // WriteAllBytes - - #region Internal Methods - - /// Creates a new file as part of a transaction, writes the specified byte array to - /// the file, and then closes the file. If the target file already exists, it is overwritten. - /// - /// - /// The transaction. - /// The file to write to. - /// The bytes to write to the file. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "bytes")] - [SecurityCritical] - internal static void WriteAllBytesCore(KernelTransaction transaction, string path, byte[] bytes, PathFormat pathFormat) - { - if (bytes == null) - throw new ArgumentNullException("bytes"); - - using (FileStream fs = OpenCore(transaction, path, FileMode.Create, FileAccess.Write, FileShare.Read, ExtendedFileAttributes.Normal, null, null, pathFormat)) - fs.Write(bytes, 0, bytes.Length); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteText.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteText.cs deleted file mode 100644 index 29be618..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.WriteText.cs +++ /dev/null @@ -1,1009 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Security.AccessControl; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class File - { - #region AppendAllLines - - #region .NET - - /// Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, writes the - /// specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - [SecurityCritical] - public static void AppendAllLines(string path, IEnumerable contents) - { - WriteAppendAllLinesCore(null, path, contents, NativeMethods.DefaultFileEncoding, true, true, PathFormat.RelativePath); - } - - /// Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, writes the - /// specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - /// The character to use. - [SecurityCritical] - public static void AppendAllLines(string path, IEnumerable contents, Encoding encoding) - { - WriteAppendAllLinesCore(null, path, contents, encoding, true, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, - /// writes the specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllLines(string path, IEnumerable contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, NativeMethods.DefaultFileEncoding, true, false, pathFormat); - } - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not - /// exist, this method creates a file, writes the specified lines to the file, and then closes - /// the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. - /// Therefore, the value of the path parameter must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the lines to. The file is created if it doesn't already exist. - /// - /// The lines to append to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllLines(string path, IEnumerable contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, encoding, true, false, pathFormat); - } - - #region Transactional - - #region .NET - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, - /// writes the specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - [SecurityCritical] - public static void AppendAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents) - { - WriteAppendAllLinesCore(transaction, path, contents, NativeMethods.DefaultFileEncoding, true, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, - /// writes the specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - /// The character to use. - [SecurityCritical] - public static void AppendAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, Encoding encoding) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, true, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, writes the - /// specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, NativeMethods.DefaultFileEncoding, true, false, pathFormat); - } - - /// [AlphaFS] Appends lines to a file, and then closes the file. If the specified file does not exist, this method creates a file, - /// writes the specified lines to the file, and then closes the file. - /// - /// - /// The method creates the file if it doesn't exist, but it doesn't create new directories. Therefore, the value of the path parameter - /// must contain existing directories. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the lines to. The file is created if it doesn't already exist. - /// The lines to append to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, true, false, pathFormat); - } - - #endregion // Transactional - - #endregion // AppendAllLines - - #region AppendAllText - - #region .NET - - /// Appends the specified stringto the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the specified string to. - /// The string to append to the file. - [SecurityCritical] - public static void AppendAllText(string path, string contents) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, NativeMethods.DefaultFileEncoding, true, false, PathFormat.RelativePath); - } - - /// Appends the specified string to the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the specified string to. - /// The string to append to the file. - /// The character to use. - [SecurityCritical] - public static void AppendAllText(string path, string contents, Encoding encoding) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, encoding, true, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Appends the specified stringto the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the specified string to. - /// The string to append to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllText(string path, string contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, NativeMethods.DefaultFileEncoding, true, false, pathFormat); - } - - /// [AlphaFS] Appends the specified string to the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to append the specified string to. - /// The string to append to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllText(string path, string contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, encoding, true, false, pathFormat); - } - - #region Transactional - - #region .NET - - /// [AlphaFS] Appends the specified stringto the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the specified string to. - /// The string to append to the file. - [SecurityCritical] - public static void AppendAllTextTransacted(KernelTransaction transaction, string path, string contents) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, NativeMethods.DefaultFileEncoding, true, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Appends the specified string to the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the specified string to. - /// The string to append to the file. - /// The character to use. - [SecurityCritical] - public static void AppendAllTextTransacted(KernelTransaction transaction, string path, string contents, Encoding encoding) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, encoding, true, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Appends the specified stringto the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the specified string to. - /// The string to append to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllTextTransacted(KernelTransaction transaction, string path, string contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, NativeMethods.DefaultFileEncoding, true, false, pathFormat); - } - - /// [AlphaFS] Appends the specified string to the file, creating the file if it does not already exist. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to append the specified string to. - /// The string to append to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void AppendAllTextTransacted(KernelTransaction transaction, string path, string contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, encoding, true, false, pathFormat); - } - - #endregion // Transactional - - #endregion // AppendAllText - - #region WriteAllLines - - #region .NET - - /// Creates a new file, writes a collection of strings to the file, and then closes the file. - /// The default behavior of the method is to write out data by using UTF-8 encoding without a byte order mark (BOM). - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The lines to write to the file. - [SecurityCritical] - public static void WriteAllLines(string path, IEnumerable contents) - { - WriteAppendAllLinesCore(null, path, contents, new UTF8Encoding(false, true), false, true, PathFormat.RelativePath); - } - - /// Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// The file to write to. - /// The string array to write to the file. - [SecurityCritical] - public static void WriteAllLines(string path, string[] contents) - { - WriteAppendAllLinesCore(null, path, contents, new UTF8Encoding(false, true), false, true, PathFormat.RelativePath); - } - - /// Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The lines to write to the file. - /// The character to use. - [SecurityCritical] - public static void WriteAllLines(string path, IEnumerable contents, Encoding encoding) - { - WriteAppendAllLinesCore(null, path, contents, encoding, false, true, PathFormat.RelativePath); - } - - /// Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string array to write to the file. - /// The character to use. - [SecurityCritical] - public static void WriteAllLines(string path, string[] contents, Encoding encoding) - { - WriteAppendAllLinesCore(null, path, contents, encoding, false, true, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Creates a new file, writes a collection of strings to the file, and then closes the file. - /// The default behavior of the method is to write out data by using UTF-8 encoding without a byte order mark (BOM). - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The lines to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLines(string path, IEnumerable contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, new UTF8Encoding(false, true), false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string array to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLines(string path, string[] contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, new UTF8Encoding(false, true), false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The lines to write to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLines(string path, IEnumerable contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, encoding, false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string array to write to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLines(string path, string[] contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, contents, encoding, false, true, pathFormat); - } - - #region Transactional - - #region .NET - - /// [AlphaFS] Creates a new file, writes a collection of strings to the file, and then closes the file. - /// The default behavior of the method is to write out data by using UTF-8 encoding without a byte order mark (BOM). - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The lines to write to the file. - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents) - { - WriteAppendAllLinesCore(transaction, path, contents, new UTF8Encoding(false, true), false, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new file, writes a collection of strings to the file, and then closes the file. - /// The default behavior of the method is to write out data by using UTF-8 encoding without a byte order mark (BOM). - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string array to write to the file. - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, string[] contents) - { - WriteAppendAllLinesCore(transaction, path, contents, new UTF8Encoding(false, true), false, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The lines to write to the file. - /// The character to use. - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, Encoding encoding) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, false, true, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string array to write to the file. - /// The character to use. - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, string[] contents, Encoding encoding) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, false, true, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Creates a new file, writes a collection of strings to the file, and then closes the file. - /// The default behavior of the method is to write out data by using UTF-8 encoding without a byte order mark (BOM). - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The lines to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, new UTF8Encoding(false, true), false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string array to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, string[] contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, new UTF8Encoding(false, true), false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The lines to write to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, IEnumerable contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, false, true, pathFormat); - } - - /// [AlphaFS] Creates a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string array to write to the file. - /// The character to use. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllLinesTransacted(KernelTransaction transaction, string path, string[] contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, contents, encoding, false, true, pathFormat); - } - - #endregion // Transactional - - #endregion // WriteAllLines - - #region WriteAllText - - #region .NET - - /// Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten. - /// This method uses UTF-8 encoding without a Byte-Order Mark (BOM) - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string to write to the file. - [SecurityCritical] - public static void WriteAllText(string path, string contents) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, new UTF8Encoding(false, true), false, false, PathFormat.RelativePath); - } - - /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. - /// The file to write to. - /// The string to write to the file. - /// The applied to the contents of the file. - [SecurityCritical] - public static void WriteAllText(string path, string contents, Encoding encoding) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, encoding, false, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Creates a new file, writes the specified string to the file, and then closes the file. If the target file already exists, it is overwritten. - /// This method uses UTF-8 encoding without a Byte-Order Mark (BOM) - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllText(string path, string contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, new UTF8Encoding(false, true), false, false, pathFormat); - } - - /// [AlphaFS] Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The file to write to. - /// The string to write to the file. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllText(string path, string contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(null, path, new[] { contents }, encoding, false, false, pathFormat); - } - - #region Transactional - - #region .NET - - /// [AlphaFS] Creates a new file as part of a transaction, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten. - /// This method uses UTF-8 encoding without a Byte-Order Mark (BOM) - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string to write to the file. - [SecurityCritical] - public static void WriteAllTextTransacted(KernelTransaction transaction, string path, string contents) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, new UTF8Encoding(false, true), false, false, PathFormat.RelativePath); - } - - /// [AlphaFS] Creates a new file as part of a transaction, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string to write to the file. - /// The applied to the contents of the file. - [SecurityCritical] - public static void WriteAllTextTransacted(KernelTransaction transaction, string path, string contents, Encoding encoding) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, encoding, false, false, PathFormat.RelativePath); - } - - #endregion // .NET - - /// [AlphaFS] Creates a new file as part of a transaction, write the contents to the file, and then closes the file. If the target file already exists, it is overwritten. - /// This method uses UTF-8 encoding without a Byte-Order Mark (BOM) - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string to write to the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllTextTransacted(KernelTransaction transaction, string path, string contents, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, new UTF8Encoding(false, true), false, false, pathFormat); - } - - /// [AlphaFS] Creates a new file as part of a transaction, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The string to write to the file. - /// The applied to the contents of the file. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public static void WriteAllTextTransacted(KernelTransaction transaction, string path, string contents, Encoding encoding, PathFormat pathFormat) - { - WriteAppendAllLinesCore(transaction, path, new[] { contents }, encoding, false, false, pathFormat); - } - - #endregion // Transactional - - #endregion // WriteAllText - - #region Internal Method - - /// Creates/appends a new file by using the specified encoding, writes a collection of strings to the file, and then closes the file. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The transaction. - /// The file to write to. - /// The lines to write to the file. - /// The character to use. - /// for file Append, for file Write. - /// to a line terminator, to ommit the line terminator. - /// Indicates the format of the path parameter(s). - [SuppressMessage("Microsoft.Usage", "CA2202:Do not dispose objects multiple times", Justification = "Disposing is controlled.")] - [SecurityCritical] - internal static void WriteAppendAllLinesCore(KernelTransaction transaction, string path, IEnumerable contents, Encoding encoding, bool isAppend, bool addNewLine, PathFormat pathFormat) - { - if (contents == null) - throw new ArgumentNullException("contents"); - - if (encoding == null) - throw new ArgumentNullException("encoding"); - - - using (FileStream stream = OpenCore(transaction, path, (isAppend ? FileMode.OpenOrCreate : FileMode.Create), FileSystemRights.AppendData, FileShare.ReadWrite, ExtendedFileAttributes.Normal, null, null, pathFormat)) - { - if (isAppend) - stream.Seek(0, SeekOrigin.End); - - using (var writer = new StreamWriter(stream, encoding)) - { - if (addNewLine) - foreach (string line in contents) - writer.WriteLine(line); - - else - foreach (string line in contents) - writer.Write(line); - } - } - } - - #endregion // Method - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/File Class/File.cs b/FolderMonitor/AlphaFS/Filesystem/File Class/File.cs deleted file mode 100644 index 27ac688..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/File Class/File.cs +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides static methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of objects. - /// This class cannot be inherited. - /// - [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] - public static partial class File - { - // This file only exists for the documentation. - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileIdBothDirectoryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FileIdBothDirectoryInfo.cs deleted file mode 100644 index f9dae48..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileIdBothDirectoryInfo.cs +++ /dev/null @@ -1,204 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Contains information about files in the specified directory. Used for directory handles. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dir")] - [Serializable] - [SecurityCritical] - public sealed class FileIdBothDirectoryInfo - { - #region Constructor - - #region FileIdBothDirectoryInfo - - internal FileIdBothDirectoryInfo(NativeMethods.FILE_ID_BOTH_DIR_INFO fibdi, string fileName) - { - CreationTimeUtc = DateTime.FromFileTimeUtc(fibdi.CreationTime); - LastAccessTimeUtc = DateTime.FromFileTimeUtc(fibdi.LastAccessTime); - LastWriteTimeUtc = DateTime.FromFileTimeUtc(fibdi.LastWriteTime); - ChangeTimeUtc = DateTime.FromFileTimeUtc(fibdi.ChangeTime); - - AllocationSize = fibdi.AllocationSize; - EndOfFile = fibdi.EndOfFile; - ExtendedAttributesSize = fibdi.EaSize; - - FileAttributes = fibdi.FileAttributes; - FileId = fibdi.FileId; - FileIndex = fibdi.FileIndex; - FileName = fileName; - - // ShortNameLength is the number of bytes in the short name; since we have a unicode string we must divide that by 2. - ShortName = new string(fibdi.ShortName, 0, fibdi.ShortNameLength / 2); - } - - #endregion // FileIdBothDirectoryInfo - - #endregion // Constructor - - #region Properties - - #region AllocationSize - - /// The number of bytes that are allocated for the file. This value is usually a multiple of the sector or cluster size of the underlying physical device. - public long AllocationSize { get; set; } - - #endregion // AllocationSize - - #region ChangeTime - - /// Gets the time this entry was changed. - /// The time this entry was changed. - public DateTime ChangeTime - { - get { return ChangeTimeUtc.ToLocalTime(); } - } - - #endregion // ChangeTime - - #region ChangeTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was changed. - /// The time, in coordinated universal time (UTC), this entry was changed. - public DateTime ChangeTimeUtc { get; set; } - - #endregion // ChangeTimeUtc - - #region CreationTime - - /// Gets the time this entry was created. - /// The time this entry was created. - public DateTime CreationTime - { - get { return CreationTimeUtc.ToLocalTime(); } - } - - #endregion // CreationTime - - #region CreationTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was created. - /// The time, in coordinated universal time (UTC), this entry was created. - public DateTime CreationTimeUtc { get; set; } - - #endregion // CreationTimeUtc - - #region EaSize - - /// The size of the extended attributes for the file. - public int ExtendedAttributesSize { get; set; } - - #endregion // EaSize - - #region EndOfFile - - /// The absolute new end-of-file position as a byte offset from the start of the file to the end of the file. - /// Because this value is zero-based, it actually refers to the first free byte in the file. In other words, EndOfFile is the offset to - /// the byte that immediately follows the last valid byte in the file. - /// - public long EndOfFile { get; set; } - - #endregion // EndOfFile - - #region FileAttributes - - /// The file attributes. - public FileAttributes FileAttributes { get; set; } - - #endregion FileAttributes - - #region FileId - - /// The file ID. - public long FileId { get; set; } - - #endregion // FileId - - #region FileIndex - - /// The byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, - /// in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. - /// - public long FileIndex { get; set; } - - #endregion // FileIndex - - #region FileName - - /// The name of the file. - public string FileName { get; set; } - - #endregion // FileName - - #region LastAccessTime - - /// Gets the time this entry was last accessed. - /// The time this entry was last accessed. - public DateTime LastAccessTime - { - get { return LastAccessTimeUtc.ToLocalTime(); } - } - - #endregion // LastAccessTime - - #region LastAccessTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was last accessed. - /// The time, in coordinated universal time (UTC), this entry was last accessed. - public DateTime LastAccessTimeUtc { get; set; } - - #endregion // LastAccessTimeUtc - - #region LastWriteTime - - /// Gets the time this entry was last modified. - /// The time this entry was last modified. - public DateTime LastWriteTime - { - get { return LastWriteTimeUtc.ToLocalTime(); } - } - - #endregion // LastWriteTime - - #region LastWriteTimeUtc - - /// Gets the time, in coordinated universal time (UTC), this entry was last modified. - /// The time, in coordinated universal time (UTC), this entry was last modified. - public DateTime LastWriteTimeUtc { get; set; } - - #endregion // LastWriteTimeUtc - - #region ShortName - - /// The short 8.3 file naming convention (for example, FILENAME.TXT) name of the file. - public string ShortName { get; set; } - - #endregion // ShortName - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs deleted file mode 100644 index 0a3033d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.AppendText.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Creates a that appends text to the file represented by this instance of the . - /// A new - [SecurityCritical] - public StreamWriter AppendText() - { - return File.AppendTextCore(Transaction, LongFullName, NativeMethods.DefaultFileEncoding, PathFormat.LongFullPath); - } - - /// Creates a that appends text to the file represented by this instance of the . - /// The character to use. - /// A new - [SecurityCritical] - public StreamWriter AppendText(Encoding encoding) - { - return File.AppendTextCore(Transaction, LongFullName, encoding, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Compress.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Compress.cs deleted file mode 100644 index f9db672..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Compress.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region AlphaFS - - /// [AlphaFS] Compresses a file using NTFS compression. - [SecurityCritical] - public void Compress() - { - Device.ToggleCompressionCore(false, Transaction, LongFullName, true, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CopyToMoveTo.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CopyToMoveTo.cs deleted file mode 100644 index 78cbe79..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CopyToMoveTo.cs +++ /dev/null @@ -1,631 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region CopyTo - - #region .NET - - /// Copies an existing file to a new file, disallowing the overwriting of an existing file. - /// A new instance with a fully qualified path. - /// - /// Use this method to prevent overwriting of an existing file by default. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - [SecurityCritical] - public FileInfo CopyTo(string destinationPath) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, CopyOptions.FailIfExists, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// Copies an existing file to a new file, allowing the overwriting of an existing file. - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// to allow an existing file to be overwritten; otherwise, . - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, bool overwrite) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - #endregion // .NET - - - #region AlphaFS - - /// [AlphaFS] Copies an existing file to a new file, disallowing the overwriting of an existing file. - /// - /// Use this method to prevent overwriting of an existing file by default. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, CopyOptions.FailIfExists, null, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file. - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// to allow an existing file to be overwritten; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, bool overwrite, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, overwrite ? CopyOptions.None : CopyOptions.FailIfExists, null, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, copyOptions, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, copyOptions, null, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// if original Timestamps must be preserved, otherwise. - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, preserveDates, copyOptions, null, null, null, out destinationPathLp, PathFormat.RelativePath); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A new instance with a fully qualified path. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// if original Timestamps must be preserved, otherwise. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, preserveDates, copyOptions, null, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, false, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, false, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, pathFormat); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, preserveDates, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - /// [AlphaFS] Copies an existing file to a new file, allowing the overwriting of an existing file, can be specified. - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Option is recommended for very large file transfers. - /// Use this method to allow or prevent overwriting of an existing file. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Copy action. - /// - /// - /// - /// - /// - /// - /// - /// The name of the new file to copy to. - /// that specify how the file is to be copied. - /// if original Timestamps must be preserved, otherwise. - /// A callback function that is called each time another portion of the file has been copied. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public CopyMoveResult CopyTo(string destinationPath, CopyOptions copyOptions, bool preserveDates, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, preserveDates, copyOptions, null, progressHandler, userProgressData, out destinationPathLp, pathFormat); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - #endregion // AlphaFS - - #endregion // CopyTo - - - #region MoveTo - - #region .NET - - /// Moves a specified file to a new location, providing the option to specify a new file name. - /// - /// Use this method to prevent overwriting of an existing file by default. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with details of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath) - { - string destinationPathLp; - var copyMoveResult = CopyToMoveToCore(destinationPath, false, null, MoveOptions.CopyAllowed, null, null, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - - return copyMoveResult; - } - - #endregion // .NET - - - #region AlphaFS - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name. - /// Returns a new instance with a fully qualified path when successfully moved, - /// - /// Use this method to prevent overwriting of an existing file by default. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable - /// behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo MoveTo(string destinationPath, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, null, MoveOptions.CopyAllowed, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, can be specified. - /// Returns a new instance with a fully qualified path when successfully moved, - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable - /// behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - /// that specify how the directory is to be moved. This parameter can be . - [SecurityCritical] - public FileInfo MoveTo(string destinationPath, MoveOptions moveOptions) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, null, moveOptions, null, null, out destinationPathLp, PathFormat.RelativePath); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, can be specified. - /// Returns a new instance with a fully qualified path when successfully moved, - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable - /// behavior. - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - /// that specify how the directory is to be moved. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo MoveTo(string destinationPath, MoveOptions moveOptions, PathFormat pathFormat) - { - string destinationPathLp; - CopyToMoveToCore(destinationPath, false, null, moveOptions, null, null, out destinationPathLp, pathFormat); - return new FileInfo(Transaction, destinationPathLp, PathFormat.LongFullPath); - } - - - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, can be specified, - /// and the possibility of notifying the application of its progress through a callback function. - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with the status of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, false, null, moveOptions, progressHandler, userProgressData, out destinationPathLp, PathFormat.RelativePath); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - /// [AlphaFS] Moves a specified file to a new location, providing the option to specify a new file name, can be specified. - /// - /// Use this method to allow or prevent overwriting of an existing file. - /// This method works across disk volumes. - /// For example, the file c:\MyFile.txt can be moved to d:\public and renamed NewFile.txt. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with the status of the Move action. - /// - /// - /// - /// - /// - /// - /// - /// The path to move the file to, which can specify a different file name. - /// that specify how the directory is to be moved. This parameter can be . - /// A callback function that is called each time another portion of the directory has been moved. This parameter can be . - /// The argument to be passed to the callback function. This parameter can be . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public CopyMoveResult MoveTo(string destinationPath, MoveOptions moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, PathFormat pathFormat) - { - string destinationPathLp; - var cmr = CopyToMoveToCore(destinationPath, false, null, moveOptions, progressHandler, userProgressData, out destinationPathLp, pathFormat); - CopyToMoveToCoreRefresh(destinationPath, destinationPathLp); - return cmr; - } - - #endregion // AlphaFS - - #endregion // MoveTo - - - #region Internal Methods - - /// Copy/move an existing file to a new file, allowing the overwriting of an existing file. - /// - /// Option is recommended for very large file transfers. - /// Whenever possible, avoid using short file names (such as XXXXXX~1.XXX) with this method. - /// If two files have equivalent short file names then this method may fail and raise an exception and/or result in undesirable behavior. - /// - /// - /// A class with the status of the Copy or Move action. - /// A full path string to the destination directory - /// if original Timestamps must be preserved, otherwise. - /// This parameter can be . Use to specify how the file is to be copied. - /// This parameter can be . Use that specify how the file is to be moved. - /// This parameter can be . A callback function that is called each time another portion of the file has been copied. - /// This parameter can be . The argument to be passed to the callback function. - /// [out] Returns the retrieved long full path. - /// Indicates the format of the path parameter(s). - /// - /// - /// - /// - /// - /// - [SecurityCritical] - private CopyMoveResult CopyToMoveToCore(string destinationPath, bool preserveDates, CopyOptions? copyOptions, MoveOptions? moveOptions, CopyMoveProgressRoutine progressHandler, object userProgressData, out string longFullPath, PathFormat pathFormat) - { - var destinationPathLp = Path.GetExtendedLengthPathCore(Transaction, destinationPath, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - longFullPath = destinationPathLp; - - // Returns false when CopyMoveProgressResult is PROGRESS_CANCEL or PROGRESS_STOP. - return File.CopyMoveCore(false, Transaction, LongFullName, destinationPathLp, preserveDates, copyOptions, moveOptions, progressHandler, userProgressData, null, PathFormat.LongFullPath); - } - - - private void CopyToMoveToCoreRefresh(string destinationPath, string destinationPathLp) - { - LongFullName = destinationPathLp; - FullPath = Path.GetRegularPathCore(destinationPathLp, GetFullPathOptions.None, false); - - OriginalPath = destinationPath; - DisplayPath = Path.GetRegularPathCore(OriginalPath, GetFullPathOptions.None, false); - - _name = Path.GetFileName(destinationPathLp, true); - - // Flush any cached information about the file. - Reset(); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs deleted file mode 100644 index 0a36e19..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Create.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Creates a file. - /// A new file. - [SecurityCritical] - public FileStream Create() - { - return File.CreateFileStreamCore(Transaction, LongFullName, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs deleted file mode 100644 index 492769f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.CreateText.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Creates a instance that writes a new text file. - /// A new - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public StreamWriter CreateText() - { - return new StreamWriter(File.CreateFileStreamCore(Transaction, LongFullName, ExtendedFileAttributes.Normal, null, FileMode.Create, FileAccess.ReadWrite, FileShare.None, NativeMethods.DefaultFileBufferSize, PathFormat.LongFullPath), NativeMethods.DefaultFileEncoding); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decompress.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decompress.cs deleted file mode 100644 index e79b470..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decompress.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region AlphaFS - - /// [AlphaFS] Decompresses an NTFS compressed file. - [SecurityCritical] - public void Decompress() - { - Device.ToggleCompressionCore(false, Transaction, LongFullName, false, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decrypt.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decrypt.cs deleted file mode 100644 index 600f8db..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Decrypt.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Decrypts a file that was encrypted by the current account using the Encrypt method. - [SecurityCritical] - public void Decrypt() - { - File.EncryptDecryptFileCore(false, LongFullName, false, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Delete.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Delete.cs deleted file mode 100644 index 122c6b8..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Delete.cs +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Permanently deletes a file. - /// If the file does not exist, this method does nothing. - /// - /// - public override void Delete() - { - File.DeleteFileCore(Transaction, LongFullName, false, PathFormat.LongFullPath); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Permanently deletes a file. - /// If the file does not exist, this method does nothing. - /// overrides the read only of the file. - public void Delete(bool ignoreReadOnly) - { - File.DeleteFileCore(Transaction, LongFullName, ignoreReadOnly, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Encrypt.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Encrypt.cs deleted file mode 100644 index e26a0a4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Encrypt.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Encrypts a file so that only the account used to encrypt the file can decrypt it. - [SecurityCritical] - public void Encrypt() - { - File.EncryptDecryptFileCore(false, LongFullName, true, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs deleted file mode 100644 index c7202a9..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.EnumerateAlternateDataStreams.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Collections.Generic; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - /// [AlphaFS] Returns an enumerable collection of instances for the file. - /// An enumerable collection of instances for the file. - [SecurityCritical] - public IEnumerable EnumerateAlternateDataStreams() - { - return File.EnumerateAlternateDataStreamsCore(Transaction, LongFullName, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetAccessControl.cs deleted file mode 100644 index 93ab75f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetAccessControl.cs +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Gets a object that encapsulates the access control list (ACL) entries for the file described by the current object. - /// A FileSecurity object that encapsulates the access control rules for the current file. - [SecurityCritical] - public FileSecurity GetAccessControl() - { - return File.GetAccessControlCore(false, LongFullName, AccessControlSections.Access | AccessControlSections.Group | AccessControlSections.Owner, PathFormat.LongFullPath); - } - - /// Gets a object that encapsulates the specified type of access control list (ACL) entries for the file described by the current FileInfo object. - /// object that encapsulates the specified type of access control list (ACL) entries for the file described by the current FileInfo object. - /// One of the values that specifies which group of access control entries to retrieve. - [SecurityCritical] - public FileSecurity GetAccessControl(AccessControlSections includeSections) - { - return File.GetAccessControlCore(false, LongFullName, includeSections, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetHash.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetHash.cs deleted file mode 100644 index 448d794..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.GetHash.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region AlphaFS - - /// [AlphaFS] Calculates the hash/checksum. - /// One of the values. - public string GetHash(HashType hashType) - { - return File.GetHashCore(Transaction, LongFullName, hashType, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs deleted file mode 100644 index 8930685..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Open.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Opens a file in the specified mode. - /// A file opened in the specified mode, with read/write access and unshared. - /// A constant specifying the mode (for example, Open or Append) in which to open the file. - [SecurityCritical] - public FileStream Open(FileMode mode) - { - return File.OpenCore(Transaction, LongFullName, mode, FileAccess.Read, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - /// Opens a file in the specified mode with read, write, or read/write access. - /// A object opened in the specified mode and access, and unshared. - /// A constant specifying the mode (for example, Open or Append) in which to open the file. - /// A constant specifying whether to open the file with Read, Write, or ReadWrite file access. - [SecurityCritical] - public FileStream Open(FileMode mode, FileAccess access) - { - return File.OpenCore(Transaction, LongFullName, mode, access, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - /// Opens a file in the specified mode with read, write, or read/write access and the specified sharing option. - /// A object opened with the specified mode, access, and sharing options. - /// A constant specifying the mode (for example, Open or Append) in which to open the file. - /// A constant specifying whether to open the file with Read, Write, or ReadWrite file access. - /// A constant specifying the type of access other objects have to this file. - [SecurityCritical] - public FileStream Open(FileMode mode, FileAccess access, FileShare share) - { - return File.OpenCore(Transaction, LongFullName, mode, access, share, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Opens a file in the specified mode with read, write, or read/write access. - /// A object opened in the specified mode and access, and unshared. - /// A constant specifying the mode (for example, Open or Append) in which to open the file. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options. - [SecurityCritical] - public FileStream Open(FileMode mode, FileSystemRights rights) - { - return File.OpenCore(Transaction, LongFullName, mode, rights, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - /// [AlphaFS] Opens a file in the specified mode with read, write, or read/write access and the specified sharing option. - /// A object opened with the specified mode, access, and sharing options. - /// A constant specifying the mode (for example, Open or Append) in which to open the file. - /// A value that specifies whether a file is created if one does not exist, and determines whether the contents of existing files are retained or overwritten along with additional options. - /// A constant specifying the type of access other objects have to this file. - [SecurityCritical] - public FileStream Open(FileMode mode, FileSystemRights rights, FileShare share) - { - return File.OpenCore(Transaction, LongFullName, mode, rights, share, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs deleted file mode 100644 index b36478a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenRead.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - /// Creates a read-only . - /// A new read-only object. - /// This method returns a read-only object with the mode set to Read. - [SecurityCritical] - public FileStream OpenRead() - { - return File.OpenCore(Transaction, LongFullName, FileMode.Open, FileAccess.Read, FileShare.Read, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs deleted file mode 100644 index 9a1afe8..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenText.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - /// Creates a with NativeMethods.DefaultFileEncoding encoding that reads from an existing text file. - /// A new with NativeMethods.DefaultFileEncoding encoding. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public StreamReader OpenText() - { - return new StreamReader(File.OpenCore(Transaction, LongFullName, FileMode.Open, FileAccess.Read, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath), NativeMethods.DefaultFileEncoding); - } - - - /// [AlphaFS] Creates a with that reads from an existing text file. - /// A new with the specified . - /// The applied to the contents of the file. - [SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] - [SecurityCritical] - public StreamReader OpenText(Encoding encoding) - { - return new StreamReader(File.OpenCore(Transaction, LongFullName, FileMode.Open, FileAccess.Read, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath), encoding); - } - - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs deleted file mode 100644 index 9482818..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.OpenWrite.cs +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Creates a write-only . - /// A write-only unshared object for a new or existing file. - [SecurityCritical] - public FileStream OpenWrite() - { - return File.OpenCore(Transaction, LongFullName, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None, ExtendedFileAttributes.Normal, null, null, PathFormat.LongFullPath); - } - - #endregion // .NET - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Refresh.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Refresh.cs deleted file mode 100644 index 6687387..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Refresh.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Refreshes the state of the object. - [SecurityCritical] - public new void Refresh() - { - base.Refresh(); - } - - #endregion // .NET - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.RefreshEntryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.RefreshEntryInfo.cs deleted file mode 100644 index 8bc93d6..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.RefreshEntryInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region AlphaFS - - /// Refreshes the state of the EntryInfo instance. - [SecurityCritical] - public new void RefreshEntryInfo() - { - base.RefreshEntryInfo(); - } - - #endregion // AlphaFS - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs deleted file mode 100644 index c72e784..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.Replace.cs +++ /dev/null @@ -1,122 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - #region .NET - - /// Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. - /// A object that encapsulates information about the file described by the parameter. - /// - /// The Replace method replaces the contents of a specified file with the contents of the file described by the current - /// object. It also creates a backup of the file that was replaced. Finally, it returns a new - /// object that describes the overwritten file. - /// - /// Pass null to the parameter if you do not want to create a backup of the file being replaced. - /// The name of a file to replace with the current file. - /// The name of a file with which to create a backup of the file described by the parameter. - [SecurityCritical] - public FileInfo Replace(string destinationFileName, string destinationBackupFileName) - { - return Replace(destinationFileName, destinationBackupFileName, false, PathFormat.RelativePath); - } - - /// Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors. - /// A object that encapsulates information about the file described by the parameter. - /// - /// The Replace method replaces the contents of a specified file with the contents of the file described by the current - /// object. It also creates a backup of the file that was replaced. Finally, it returns a new - /// object that describes the overwritten file. - /// - /// Pass null to the parameter if you do not want to create a backup of the file being replaced. - /// The name of a file to replace with the current file. - /// The name of a file with which to create a backup of the file described by the parameter. - /// to ignore merge errors (such as attributes and ACLs) from the replaced file to the replacement file; otherwise, . - [SecurityCritical] - public FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors) - { - return Replace(destinationFileName, destinationBackupFileName, ignoreMetadataErrors, PathFormat.RelativePath); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors. - /// A object that encapsulates information about the file described by the parameter. - /// - /// The Replace method replaces the contents of a specified file with the contents of the file described by the current - /// object. It also creates a backup of the file that was replaced. Finally, it returns a new - /// object that describes the overwritten file. - /// - /// Pass null to the parameter if you do not want to create a backup of the file being replaced. - /// The name of a file to replace with the current file. - /// The name of a file with which to create a backup of the file described by the parameter. - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo Replace(string destinationFileName, string destinationBackupFileName, PathFormat pathFormat) - { - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - - string destinationFileNameLp = Path.GetExtendedLengthPathCore(Transaction, destinationFileName, pathFormat, options); - string destinationBackupFileNameLp = destinationBackupFileName != null - ? Path.GetExtendedLengthPathCore(Transaction, destinationBackupFileName, pathFormat, options) - : null; - - File.ReplaceCore(LongFullName, destinationFileNameLp, destinationBackupFileNameLp, false, PathFormat.LongFullPath); - - return new FileInfo(Transaction, destinationFileNameLp, PathFormat.LongFullPath); - } - - /// [AlphaFS] Replaces the contents of a specified file with the file described by the current object, deleting the original file, and creating a backup of the replaced file. Also specifies whether to ignore merge errors. - /// A object that encapsulates information about the file described by the parameter. - /// - /// The Replace method replaces the contents of a specified file with the contents of the file described by the current - /// object. It also creates a backup of the file that was replaced. Finally, it returns a new - /// object that describes the overwritten file. - /// - /// Pass null to the parameter if you do not want to create a backup of the file being replaced. - /// The name of a file to replace with the current file. - /// The name of a file with which to create a backup of the file described by the parameter. - /// to ignore merge errors (such as attributes and ACLs) from the replaced file to the replacement file; otherwise, . - /// Indicates the format of the path parameter(s). - [SecurityCritical] - public FileInfo Replace(string destinationFileName, string destinationBackupFileName, bool ignoreMetadataErrors, PathFormat pathFormat) - { - const GetFullPathOptions options = GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck; - - string destinationFileNameLp = Path.GetExtendedLengthPathCore(Transaction, destinationFileName, pathFormat, options); - string destinationBackupFileNameLp = destinationBackupFileName != null - ? Path.GetExtendedLengthPathCore(Transaction, destinationBackupFileName, pathFormat, options) - : null; - - File.ReplaceCore(LongFullName, destinationFileNameLp, destinationBackupFileNameLp, ignoreMetadataErrors, PathFormat.LongFullPath); - - return new FileInfo(Transaction, destinationFileNameLp, PathFormat.LongFullPath); - } - - #endregion // AlphaFS - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.SetAccessControl.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.SetAccessControl.cs deleted file mode 100644 index 6f85888..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.SetAccessControl.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - /// Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileInfo object. - /// - /// The SetAccessControl method applies access control list (ACL) entries to the current file that represents the noninherited ACL - /// list. Use the SetAccessControl method whenever you need to add or remove ACL entries from a file. - /// - /// A object that describes an access control list (ACL) entry to apply to the current file. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void SetAccessControl(FileSecurity fileSecurity) - { - File.SetAccessControlCore(LongFullName, null, fileSecurity, AccessControlSections.All, PathFormat.LongFullPath); - } - - /// Applies access control list (ACL) entries described by a FileSecurity object to the file described by the current FileInfo object. - /// - /// The SetAccessControl method applies access control list (ACL) entries to the current file that represents the noninherited ACL - /// list. Use the SetAccessControl method whenever you need to add or remove ACL entries from a file. - /// - /// A object that describes an access control list (ACL) entry to apply to the current file. - /// One or more of the values that specifies the type of access control list (ACL) information to set. - [SuppressMessage("Microsoft.Design", "CA1011:ConsiderPassingBaseTypesAsParameters")] - [SecurityCritical] - public void SetAccessControl(FileSecurity fileSecurity, AccessControlSections includeSections) - { - File.SetAccessControlCore(LongFullName, null, fileSecurity, includeSections, PathFormat.LongFullPath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.ToString.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.ToString.cs deleted file mode 100644 index b826686..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.ToString.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - partial class FileInfo - { - /// Returns the path as a string. - /// The path. - public override string ToString() - { - return DisplayPath; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs deleted file mode 100644 index 89fa10f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileInfo Class/FileInfo.cs +++ /dev/null @@ -1,250 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files, and aids in the creation of objects. This class cannot be inherited. - [SerializableAttribute] - public sealed partial class FileInfo : FileSystemInfo - { - #region Constructors - - #region .NET - - /// Initializes a new instance of the class, which acts as a wrapper for a file path. - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - public FileInfo(string fileName) : this(null, fileName, PathFormat.RelativePath) - { - } - - #endregion // .NET - - #region AlphaFS - - #region Non-Transactional - - /// [AlphaFS] Initializes a new instance of the class, which acts as a wrapper for a file path. - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - /// Indicates the format of the path parameter(s). - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - public FileInfo(string fileName, PathFormat pathFormat) : this(null, fileName, pathFormat) - { - } - - #endregion // Non-Transactional - - #region Transactional - - /// [AlphaFS] Initializes a new instance of the class, which acts as a wrapper for a file path. - /// The transaction. - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - public FileInfo(KernelTransaction transaction, string fileName) : this(transaction, fileName, PathFormat.RelativePath) - { - } - - /// [AlphaFS] Initializes a new instance of the class, which acts as a wrapper for a file path. - /// The transaction. - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - /// Indicates the format of the path parameter(s). - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - public FileInfo(KernelTransaction transaction, string fileName, PathFormat pathFormat) - { - InitializeCore(false, transaction, fileName, pathFormat); - - _name = Path.GetFileName(Path.RemoveTrailingDirectorySeparator(fileName, false), pathFormat != PathFormat.LongFullPath); - } - - #endregion // Transacted - - #endregion // AlphaFS - - #endregion // Constructors - - #region Properties - - #region .NET - - #region Directory - - /// Gets an instance of the parent directory. - /// A object representing the parent directory of this file. - /// To get the parent directory as a string, use the DirectoryName property. - /// - public DirectoryInfo Directory - { - get - { - string dirName = DirectoryName; - return dirName == null ? null : new DirectoryInfo(Transaction, dirName, PathFormat.FullPath); - } - } - - #endregion // Directory - - #region DirectoryName - - /// Gets a string representing the directory's full path. - /// A string representing the directory's full path. - /// - /// To get the parent directory as a DirectoryInfo object, use the Directory property. - /// When first called, FileInfo calls Refresh and caches information about the file. - /// On subsequent calls, you must call Refresh to get the latest copy of the information. - /// - /// - public string DirectoryName - { - [SecurityCritical] get { return Path.GetDirectoryName(FullPath, false); } - } - - #endregion // DirectoryName - - #region Exists - - /// Gets a value indicating whether the file exists. - /// if the file exists; otherwise, . - /// - /// The property returns if any error occurs while trying to determine if the specified file exists. - /// This can occur in situations that raise exceptions such as passing a file name with invalid characters or too many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public override bool Exists - { - [SecurityCritical] - get - { - try - { - if (DataInitialised == -1) - Refresh(); - - FileAttributes attrs = Win32AttributeData.dwFileAttributes; - return DataInitialised == 0 && attrs != (FileAttributes) (-1) && (attrs & FileAttributes.Directory) == 0; - } - catch - { - return false; - } - } - } - - #endregion // Exists - - #region IsReadOnly - - /// Gets or sets a value that determines if the current file is read only. - /// if the current file is read only; otherwise, . - /// - /// Use the IsReadOnly property to quickly determine or change whether the current file is read only. - /// When first called, FileInfo calls Refresh and caches information about the file. - /// On subsequent calls, you must call Refresh to get the latest copy of the information. - /// - /// - /// - public bool IsReadOnly - { - get { return EntryInfo == null || EntryInfo.IsReadOnly; } - - set - { - if (value) - Attributes |= FileAttributes.ReadOnly; - else - Attributes &= ~FileAttributes.ReadOnly; - } - } - - #endregion // IsReadOnly - - #region Length - - /// Gets the size, in bytes, of the current file. - /// The size of the current file in bytes. - /// - /// The value of the Length property is pre-cached - /// To get the latest value, call the Refresh method. - /// - /// - /// - [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")] - public long Length - { - [SecurityCritical] - get - { - if (DataInitialised == -1) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - Refresh(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised != 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - FileAttributes attrs = Win32AttributeData.dwFileAttributes; - - // MSDN: .NET 3.5+: FileNotFoundException: The file does not exist or the Length property is called for a directory. - if (attrs == (FileAttributes) (-1)) - NativeError.ThrowException(Win32Errors.ERROR_FILE_NOT_FOUND, LongFullName); - - // MSDN: .NET 3.5+: FileNotFoundException: The file does not exist or the Length property is called for a directory. - if ((attrs & FileAttributes.Directory) == FileAttributes.Directory) - NativeError.ThrowException(Win32Errors.ERROR_FILE_NOT_FOUND, string.Format(CultureInfo.CurrentCulture, Resources.Target_File_Is_A_Directory, LongFullName)); - - return Win32AttributeData.FileSize; - } - } - - #endregion // Length - - #region Name - - private string _name; - - /// Gets the name of the file. - /// The name of the file. - /// - /// The name of the file includes the file extension. - /// When first called, calls Refresh and caches information about the file. - /// On subsequent calls, you must call Refresh to get the latest copy of the information. - /// The name of the file includes the file extension. - /// - public override string Name - { - get { return _name; } - } - - #endregion // Name - - #endregion // .NET - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileSystemEntryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FileSystemEntryInfo.cs deleted file mode 100644 index 86c28e3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileSystemEntryInfo.cs +++ /dev/null @@ -1,254 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents information about a file system entry. - /// This class cannot be inherited. - /// - [SerializableAttribute] - [SecurityCritical] - public sealed class FileSystemEntryInfo - { - /// Initializes a new instance of the class. - /// The NativeMethods.WIN32_FIND_DATA structure. - internal FileSystemEntryInfo(NativeMethods.WIN32_FIND_DATA findData) - { - Win32FindData = findData; - } - - - #region Properties - - /// Gets the 8.3 version of the filename. - /// the 8.3 version of the filename. - public string AlternateFileName - { - get { return Win32FindData.cAlternateFileName; } - } - - - /// Gets the attributes. - /// The attributes. - public FileAttributes Attributes - { - get { return Win32FindData.dwFileAttributes; } - } - - - /// Gets the time this entry was created. - /// The time this entry was created. - public DateTime CreationTime - { - get { return CreationTimeUtc.ToLocalTime(); } - } - - - /// Gets the time, in coordinated universal time (UTC), this entry was created. - /// The time, in coordinated universal time (UTC), this entry was created. - public DateTime CreationTimeUtc - { - get { return DateTime.FromFileTimeUtc(Win32FindData.ftCreationTime); } - } - - - /// Gets the name of the file. - /// The name of the file. - public string FileName - { - get { return Win32FindData.cFileName; } - } - - - /// Gets the size of the file. - /// The size of the file. - public long FileSize - { - get { return NativeMethods.ToLong(Win32FindData.nFileSizeHigh, Win32FindData.nFileSizeLow); } - } - - - private string _fullPath; - - /// The full path of the file system object. - public string FullPath - { - get { return _fullPath; } - set - { - LongFullPath = value; - _fullPath = Path.GetRegularPathCore(LongFullPath, GetFullPathOptions.None, false); - } - } - - - /// Gets a value indicating whether this instance is compressed. - /// if this instance is compressed; otherwise, . - /// - /// It is not possible to change the compression status of a File object by using the SetAttributes method. - /// Instead, you must actually compress the file using either a compression tool or one of the classes in the namespace. - /// - public bool IsCompressed - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.Compressed) != 0; } - } - - - /// Gets a value indicating whether this instance is hidden, and thus is not included in an ordinary directory listing. - /// if this instance is hidden; otherwise, . - public bool IsHidden - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.Hidden) != 0; } - } - - - /// Gets a value indicating whether this instance represents a directory. - /// if this instance represents a directory; otherwise, . - public bool IsDirectory - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.Directory) != 0; } - } - - - /// Gets a value indicating whether this instance is encrypted (EFS). - /// if this instance is encrypted (EFS); otherwise, . - /// - /// For a file, this means that all data in the file is encrypted. - /// For a directory, this means that encryption is the default for newly created files and directories. - /// - public bool IsEncrypted - { - get { return Attributes != (FileAttributes) (-1) && (Attributes & FileAttributes.Encrypted) != 0; } - } - - - /// Gets a value indicating whether this instance is a mount point. - /// if this instance is a mount point; otherwise, . - public bool IsMountPoint - { - get { return ReparsePointTag == ReparsePointTag.MountPoint; } - } - - - /// Gets a value indicating whether this instance is offline. The data of the file is not immediately available. - /// if this instance is offline; otherwise, . - public bool IsOffline - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.Offline) != 0; } - } - - - /// Gets a value indicating whether this instance is read-only. - /// if this instance is read-only; otherwise, . - public bool IsReadOnly - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.ReadOnly) != 0; } - } - - - /// Gets a value indicating whether this instance contains a reparse point, which is a block of user-defined data associated with a file or a directory. - /// if this instance contains a reparse point; otherwise, . - public bool IsReparsePoint - { - get { return Attributes != (FileAttributes)(-1) && (Attributes & FileAttributes.ReparsePoint) != 0; } - } - - - /// Gets a value indicating whether this instance is a symbolic link. - /// if this instance is a symbolic link; otherwise, . - public bool IsSymbolicLink - { - get { return ReparsePointTag == ReparsePointTag.SymLink; } - } - - - /// Gets the time this entry was last accessed. - /// The time this entry was last accessed. - public DateTime LastAccessTime - { - get { return LastAccessTimeUtc.ToLocalTime(); } - } - - - /// Gets the time, in coordinated universal time (UTC), this entry was last accessed. - /// The time, in coordinated universal time (UTC), this entry was last accessed. - public DateTime LastAccessTimeUtc - { - get { return DateTime.FromFileTimeUtc(Win32FindData.ftLastAccessTime); } - } - - - /// Gets the time this entry was last modified. - /// The time this entry was last modified. - public DateTime LastWriteTime - { - get { return LastWriteTimeUtc.ToLocalTime(); } - } - - - /// Gets the time, in coordinated universal time (UTC), this entry was last modified. - /// The time, in coordinated universal time (UTC), this entry was last modified. - public DateTime LastWriteTimeUtc - { - get { return DateTime.FromFileTimeUtc(Win32FindData.ftLastWriteTime); } - } - - - private string _longFullPath; - - /// The full path of the file system object in Unicode (LongPath) format. - public string LongFullPath - { - get { return _longFullPath; } - private set { _longFullPath = Path.GetLongPathCore(value, GetFullPathOptions.None); } - } - - - /// Gets the reparse point tag of this entry. - /// The reparse point tag of this entry. - public ReparsePointTag ReparsePointTag - { - get { return IsReparsePoint ? Win32FindData.dwReserved0 : ReparsePointTag.None; } - } - - - /// Gets internal WIN32 FIND Data - internal NativeMethods.WIN32_FIND_DATA Win32FindData { get; private set; } - - #endregion // Properties - - - #region Methods - - /// Returns the of the instance. - /// The instance as a string. - public override string ToString() - { - return FullPath; - } - - #endregion // Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FileSystemInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FileSystemInfo.cs deleted file mode 100644 index be062ce..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FileSystemInfo.cs +++ /dev/null @@ -1,643 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides the base class for both and objects. - [SerializableAttribute] - [ComVisibleAttribute(true)] - public abstract class FileSystemInfo : MarshalByRefObject - { - #region Methods - - #region .NET - - #region Delete - - /// Deletes a file or directory. - [SecurityCritical] - public abstract void Delete(); - - #endregion // Delete - - #region Refresh - - /// Refreshes the state of the object. - /// - /// FileSystemInfo.Refresh() takes a snapshot of the file from the current file system. - /// Refresh cannot correct the underlying file system even if the file system returns incorrect or outdated information. - /// This can happen on platforms such as Windows 98. - /// Calls must be made to Refresh() before attempting to get the attribute information, or the information will be - /// outdated. - /// - [SecurityCritical] - protected void Refresh() - { - DataInitialised = File.FillAttributeInfoCore(Transaction, LongFullName, ref Win32AttributeData, false, false); - } - - #endregion // Refresh - - #region ToString - - /// Returns a string that represents the current object. - /// - /// ToString is the major formatting method in the .NET Framework. It converts an object to its string representation so that it is - /// suitable for display. - /// - /// A string that represents this instance. - public override string ToString() - { - // "Alphaleonis.Win32.Filesystem.FileSystemInfo" - return GetType().ToString(); - } - - #endregion // ToString - - #region Equality - - /// Determines whether the specified Object is equal to the current Object. - /// Another object to compare to. - /// if the specified Object is equal to the current Object; otherwise, . - public override bool Equals(object obj) - { - if (obj == null || GetType() != obj.GetType()) - return false; - - FileSystemInfo other = obj as FileSystemInfo; - - return other != null && (other.Name != null && - (other.FullName.Equals(FullName, StringComparison.OrdinalIgnoreCase) && - other.Attributes.Equals(Attributes) && - other.CreationTimeUtc.Equals(CreationTimeUtc) && - other.LastWriteTimeUtc.Equals(LastWriteTimeUtc))); - } - - // A random prime number will be picked and added to the HashCode, each time an instance is created. - [NonSerialized] - private readonly int _random = new Random().Next(0, 19); - - [NonSerialized] - private static readonly int[] Primes = { 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919 }; - - /// Serves as a hash function for a particular type. - /// A hash code for the current Object. - public override int GetHashCode() - { - string fullName = FullName; - string name = Name; - - unchecked - { - int hash = Primes[_random]; - - if (!Utils.IsNullOrWhiteSpace(fullName)) - hash = hash * Primes[1] + fullName.GetHashCode(); - - if (!Utils.IsNullOrWhiteSpace(name)) - hash = hash * Primes[1] + name.GetHashCode(); - - hash = hash * Primes[1] + Attributes.GetHashCode(); - hash = hash * Primes[1] + CreationTimeUtc.GetHashCode(); - hash = hash * Primes[1] + LastWriteTimeUtc.GetHashCode(); - - return hash; - } - } - - /// Implements the operator == - /// A. - /// B. - /// The result of the operator. - public static bool operator ==(FileSystemInfo left, FileSystemInfo right) - { - return ReferenceEquals(left, null) && ReferenceEquals(right, null) || - !ReferenceEquals(left, null) && !ReferenceEquals(right, null) && left.Equals(right); - } - - /// Implements the operator != - /// A. - /// B. - /// The result of the operator. - public static bool operator !=(FileSystemInfo left, FileSystemInfo right) - { - return !(left == right); - } - - #endregion // Equality - - #endregion // .NET - - #region AlphaFS - - #region RefreshEntryInfo - - /// Refreshes the state of the EntryInfo instance. - /// - /// FileSystemInfo.RefreshEntryInfo() takes a snapshot of the file from the current file system. - /// Refresh cannot correct the underlying file system even if the file system returns incorrect or outdated information. - /// This can happen on platforms such as Windows 98. - /// Calls must be made to Refresh() before attempting to get the attribute information, or the information will be outdated. - /// - [SecurityCritical] - protected void RefreshEntryInfo() - { - _entryInfo = File.GetFileSystemEntryInfoCore(IsDirectory, Transaction, LongFullName, true, PathFormat.LongFullPath); - - if (_entryInfo == null) - DataInitialised = -1; - else - { - DataInitialised = 0; - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(_entryInfo.Win32FindData); - } - } - - #endregion // RefreshEntryInfo - - #region Reset - - /// [AlphaFS] Resets the state of the file system object to uninitialized. - internal void Reset() - { - DataInitialised = -1; - } - - #endregion // Reset - - #region InitializeCore - - /// Initializes the specified file name. - /// - /// - /// Specifies that is a file or directory. - /// The transaction. - /// The full path and name of the file. - /// Indicates the format of the path parameter(s). - internal void InitializeCore(bool isFolder, KernelTransaction transaction, string path, PathFormat pathFormat) - { - if (pathFormat == PathFormat.RelativePath) - Path.CheckSupportedPathFormat(path, true, true); - - LongFullName = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | (isFolder ? GetFullPathOptions.RemoveTrailingDirectorySeparator : 0) | GetFullPathOptions.ContinueOnNonExist); - - // (Not on MSDN): .NET 4+ Trailing spaces are removed from the end of the path parameter before creating the FileSystemInfo instance. - - FullPath = Path.GetRegularPathCore(LongFullName, GetFullPathOptions.None, false); - - IsDirectory = isFolder; - Transaction = transaction; - - OriginalPath = FullPath.Length == 2 && (FullPath[1] == Path.VolumeSeparatorChar) - ? Path.CurrentDirectoryPrefix - : path; - - DisplayPath = OriginalPath.Length != 2 || OriginalPath[1] != Path.VolumeSeparatorChar - ? Path.GetRegularPathCore(OriginalPath, GetFullPathOptions.None, false) - : Path.CurrentDirectoryPrefix; - } - - #endregion // InitializeCore - - #endregion // AlphaFS - - #endregion // Methods - - #region Properties - - #region .NET - - #region Attributes - - /// - /// Gets or sets the attributes for the current file or directory. - /// - /// - /// The value of the CreationTime property is pre-cached - /// To get the latest value, call the Refresh method. - /// - /// of the current . - /// - /// - /// - /// - public FileAttributes Attributes - { - [SecurityCritical] - get - { - if (DataInitialised == -1) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - Refresh(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised != 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - return Win32AttributeData.dwFileAttributes; - } - - [SecurityCritical] - set - { - File.SetAttributesCore(IsDirectory, Transaction, LongFullName, value, PathFormat.LongFullPath); - Reset(); - } - } - - #endregion // Attributes - - #region CreationTime - - /// Gets or sets the creation time of the current file or directory. - /// - /// The value of the CreationTime property is pre-cached To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions whose values may not be continuously updated by - /// the operating system. - /// If the file described in the FileSystemInfo object does not exist, this property will return - /// 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. - /// NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time. - /// This process is known as file tunneling. As a result, it may be necessary to explicitly set the creation time of a file if you are - /// overwriting or replacing an existing file. - /// - /// The creation date and time of the current object. - /// - /// - /// - public DateTime CreationTime - { - [SecurityCritical] get { return CreationTimeUtc.ToLocalTime(); } - [SecurityCritical] set { CreationTimeUtc = value.ToUniversalTime(); } - } - - #endregion // CreationTime - - #region CreationTimeUtc - - /// Gets or sets the creation time, in coordinated universal time (UTC), of the current file or directory. - /// - /// The value of the CreationTimeUtc property is pre-cached - /// To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions - /// whose values may not be continuously updated by the operating system. - /// To get the latest value, call the Refresh method. - /// If the file described in the FileSystemInfo object does not exist, this property will return - /// 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC). - /// NTFS-formatted drives may cache file meta-info, such as file creation time, for a short period of time. - /// This process is known as file tunneling. As a result, it may be necessary to explicitly set the creation time - /// of a file if you are overwriting or replacing an existing file. - /// - /// The creation date and time in UTC format of the current object. - /// - /// - /// - [ComVisible(false)] - public DateTime CreationTimeUtc - { - [SecurityCritical] - get - { - if (DataInitialised == -1) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - Refresh(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised != 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - return DateTime.FromFileTimeUtc(Win32AttributeData.ftCreationTime); - } - - [SecurityCritical] - set - { - File.SetFsoDateTimeCore(IsDirectory, Transaction, LongFullName, value, null, null, false, PathFormat.LongFullPath); - Reset(); - } - } - - #endregion // CreationTimeUtc - - #region Exists - - /// - /// Gets a value indicating whether the file or directory exists. - /// - /// - /// The property returns if any error occurs while trying to determine if the - /// specified file or directory exists. - /// This can occur in situations that raise exceptions such as passing a directory- or file name with invalid characters or too - /// many characters, - /// a failing or missing disk, or if the caller does not have permission to read the file or directory. - /// - /// if the file or directory exists; otherwise, . - public abstract bool Exists { get; } - - #endregion // Exists - - #region Extension - - /// - /// Gets the string representing the extension part of the file. - /// - /// - /// The Extension property returns the extension, including the period (.). - /// For example, for a file c:\NewFile.txt, this property returns ".txt". - /// - /// A string containing the extension. - public string Extension - { - get { return Path.GetExtension(FullPath, false); } - } - - #endregion // Extension - - #region FullName - - /// - /// Gets the full path of the directory or file. - /// - /// A string containing the full path. - public virtual string FullName - { - [SecurityCritical] - get { return FullPath; } - } - - #endregion // FullName - - #region LastAccessTime - - /// Gets or sets the time the current file or directory was last accessed. - /// - /// The value of the LastAccessTime property is pre-cached - /// To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions - /// whose values may not be continuously updated by the operating system. - /// If the file described in the FileSystemInfo object does not exist, this property will return - /// 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. - /// - /// The time that the current file or directory was last accessed. - /// - /// - public DateTime LastAccessTime - { - [SecurityCritical] get { return LastAccessTimeUtc.ToLocalTime(); } - [SecurityCritical] set { LastAccessTimeUtc = value.ToUniversalTime(); } - } - - #endregion // LastAccessTime - - #region LastAccessTimeUtc - - /// Gets or sets the time, in coordinated universal time (UTC), that the current file or directory was last accessed. - /// - /// The value of the LastAccessTimeUtc property is pre-cached. - /// To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions - /// whose values may not be continuously updated by the operating system. - /// If the file described in the FileSystemInfo object does not exist, this property will return - /// 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. - /// - /// The UTC time that the current file or directory was last accessed. - /// - /// - [ComVisible(false)] - public DateTime LastAccessTimeUtc - { - [SecurityCritical] - get - { - if (DataInitialised == -1) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - Refresh(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised != 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - return DateTime.FromFileTimeUtc(Win32AttributeData.ftLastAccessTime); - } - - [SecurityCritical] - set - { - File.SetFsoDateTimeCore(IsDirectory, Transaction, LongFullName, null, value, null, false, PathFormat.LongFullPath); - Reset(); - } - } - - #endregion // LastAccessTimeUtc - - #region LastWriteTime - - /// Gets or sets the time when the current file or directory was last written to. - /// - /// The value of the LastWriteTime property is pre-cached. - /// To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions - /// whose values may not be continuously updated by the operating system. - /// If the file described in the FileSystemInfo object does not exist, this property will return - /// 12:00 midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. - /// - /// The time the current file was last written. - /// - /// - public DateTime LastWriteTime - { - get { return LastWriteTimeUtc.ToLocalTime(); } - set { LastWriteTimeUtc = value.ToUniversalTime(); } - } - - #endregion // LastWriteTime - - #region LastWriteTimeUtc - - /// Gets or sets the time, in coordinated universal time (UTC), when the current file or directory was last written to. - /// - /// The value of the LastWriteTimeUtc property is pre-cached. To get the latest value, call the Refresh method. - /// This method may return an inaccurate value, because it uses native functions whose values may not be continuously updated by - /// the operating system. - /// If the file described in the FileSystemInfo object does not exist, this property will return 12:00 midnight, January 1, 1601 - /// A.D. (C.E.) Coordinated Universal Time (UTC), adjusted to local time. - /// - /// The UTC time when the current file was last written to. - [ComVisible(false)] - public DateTime LastWriteTimeUtc - { - [SecurityCritical] - get - { - if (DataInitialised == -1) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - Refresh(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised != 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - return DateTime.FromFileTimeUtc(Win32AttributeData.ftLastWriteTime); - } - - [SecurityCritical] - set - { - File.SetFsoDateTimeCore(IsDirectory, Transaction, LongFullName, null, null, value, false, PathFormat.LongFullPath); - Reset(); - } - } - - #endregion // LastWriteTimeUtc - - #region Name - - /// - /// For files, gets the name of the file. For directories, gets the name of the last directory in the hierarchy if a hierarchy exists. - /// Otherwise, the Name property gets the name of the directory. - /// - /// - /// For a directory, Name returns only the name of the parent directory, such as Dir, not c:\Dir. - /// For a subdirectory, Name returns only the name of the subdirectory, such as Sub1, not c:\Dir\Sub1. - /// For a file, Name returns only the file name and file name extension, such as MyFile.txt, not c:\Dir\Myfile.txt. - /// - /// - /// A string that is the name of the parent directory, the name of the last directory in the hierarchy, - /// or the name of a file, including the file name extension. - /// - public abstract string Name { get; } - - #endregion // Name - - #endregion // .NET - - #region AlphaFS - - #region DisplayPath - - /// Returns the path as a string. - protected internal string DisplayPath { get; protected set; } - - #endregion // DisplayPath - - #region EntryInfo - - private FileSystemEntryInfo _entryInfo; - - /// [AlphaFS] Gets the instance of the class. - public FileSystemEntryInfo EntryInfo - { - [SecurityCritical] - get - { - if (_entryInfo == null) - { - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(); - RefreshEntryInfo(); - } - - // MSDN: .NET 3.5+: IOException: Refresh cannot initialize the data. - if (DataInitialised > 0) - NativeError.ThrowException(DataInitialised, LongFullName); - - return _entryInfo; - } - - internal set - { - _entryInfo = value; - - DataInitialised = value == null ? -1 : 0; - - if (DataInitialised == 0) - Win32AttributeData = new NativeMethods.WIN32_FILE_ATTRIBUTE_DATA(_entryInfo.Win32FindData); - } - } - - #endregion // EntryInfo - - #region IsDirectory - - /// [AlphaFS] The initial "IsDirectory" indicator that was passed to the constructor. - protected bool IsDirectory { get; set; } - - #endregion // IsDirectory - - #region LongFullName - - /// The full path of the file system object in Unicode (LongPath) format. - protected string LongFullName { get; set; } - - #endregion // LongFullName - - #region Transaction - - /// [AlphaFS] Represents the KernelTransaction that was passed to the constructor. - protected KernelTransaction Transaction { get; set; } - - #endregion // Transaction - - #endregion // AlphaFS - - #endregion // Properties - - #region Fields - - // We use this field in conjunction with the Refresh methods, if we succeed - // we store a zero, on failure we store the HResult in it so that we can - // give back a generic error back. - [NonSerialized] internal int DataInitialised = -1; - - // The pre-cached FileSystemInfo information. - [NonSerialized] internal NativeMethods.WIN32_FILE_ATTRIBUTE_DATA Win32AttributeData; - - #region .NET - - /// Represents the fully qualified path of the file or directory. - /// - /// Classes derived from can use the FullPath field - /// to determine the full path of the object being manipulated. - /// - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - protected string FullPath; - - /// The path originally specified by the user, whether relative or absolute. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - protected string OriginalPath; - - #endregion // .NET - - #endregion // Fields - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs b/FolderMonitor/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs deleted file mode 100644 index 28601e7..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/FindFileSystemEntryInfo.cs +++ /dev/null @@ -1,387 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Text.RegularExpressions; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Class that retrieves file system entries (i.e. files and directories) using Win32 API FindFirst()/FindNext(). - [SerializableAttribute] - internal sealed class FindFileSystemEntryInfo - { - private static readonly Regex WildcardMatchAll = new Regex(@"^(\*)+(\.\*+)+$", RegexOptions.IgnoreCase | RegexOptions.Compiled); // special case to recognize *.* or *.** etc - private Regex _nameFilter; - private string _searchPattern = Path.WildcardStarMatchAll; - - - public FindFileSystemEntryInfo(bool isFolder, KernelTransaction transaction, string path, string searchPattern, DirectoryEnumerationOptions options, Type typeOfT, PathFormat pathFormat) - { - Transaction = transaction; - - OriginalInputPath = path; - InputPath = Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - IsRelativePath = !Path.IsPathRooted(OriginalInputPath, false); - - // .NET behaviour. - SearchPattern = searchPattern.TrimEnd(Path.TrimEndChars); - - FileSystemObjectType = null; - - ContinueOnException = (options & DirectoryEnumerationOptions.ContinueOnException) != 0; - - AsLongPath = (options & DirectoryEnumerationOptions.AsLongPath) != 0; - - AsString = typeOfT == typeof(string); - AsFileSystemInfo = !AsString && (typeOfT == typeof(FileSystemInfo) || typeOfT.BaseType == typeof(FileSystemInfo)); - - FindExInfoLevel = NativeMethods.IsAtLeastWindows7 && (options & DirectoryEnumerationOptions.BasicSearch) != 0 - ? NativeMethods.FINDEX_INFO_LEVELS.Basic - : NativeMethods.FINDEX_INFO_LEVELS.Standard; - - LargeCache = NativeMethods.IsAtLeastWindows7 && (options & DirectoryEnumerationOptions.LargeCache) != 0 - ? NativeMethods.FindExAdditionalFlags.LargeFetch - : NativeMethods.FindExAdditionalFlags.None; - - IsDirectory = isFolder; - - if (IsDirectory) - { - // Need files or folders to enumerate. - if ((options & DirectoryEnumerationOptions.FilesAndFolders) == 0) - options |= DirectoryEnumerationOptions.FilesAndFolders; - - FileSystemObjectType = (options & DirectoryEnumerationOptions.FilesAndFolders) == DirectoryEnumerationOptions.FilesAndFolders - ? (bool?) null - : (options & DirectoryEnumerationOptions.Folders) != 0; - - Recursive = (options & DirectoryEnumerationOptions.Recursive) != 0; - - SkipReparsePoints = (options & DirectoryEnumerationOptions.SkipReparsePoints) != 0; - } - } - - - - - private void ThrowPossibleException(uint lastError, string pathLp) - { - //Answer - - switch (lastError) - { - case Win32Errors.ERROR_NO_MORE_FILES: - lastError = Win32Errors.NO_ERROR; - break; - - case Win32Errors.ERROR_FILE_NOT_FOUND: - case Win32Errors.ERROR_PATH_NOT_FOUND: - // MSDN: .NET 3.5+: DirectoryNotFoundException: Path is invalid, such as referring to an unmapped drive. - // Directory.Delete() - - lastError = IsDirectory ? (int) Win32Errors.ERROR_PATH_NOT_FOUND : Win32Errors.ERROR_FILE_NOT_FOUND; - break; - - - //case Win32Errors.ERROR_DIRECTORY: - // // MSDN: .NET 3.5+: IOException: path is a file name. - // // Directory.EnumerateDirectories() - // // Directory.EnumerateFiles() - // // Directory.EnumerateFileSystemEntries() - // // Directory.GetDirectories() - // // Directory.GetFiles() - // // Directory.GetFileSystemEntries() - // break; - - //case Win32Errors.ERROR_ACCESS_DENIED: - // // MSDN: .NET 3.5+: UnauthorizedAccessException: The caller does not have the required permission. - // break; - } - - if (lastError != Win32Errors.NO_ERROR) - NativeError.ThrowException(lastError, pathLp); - } - - - private SafeFindFileHandle FindFirstFile(string pathLp, out NativeMethods.WIN32_FIND_DATA win32FindData) - { - var searchOption = null != FileSystemObjectType && (bool)FileSystemObjectType - ? NativeMethods.FINDEX_SEARCH_OPS.SearchLimitToDirectories - : NativeMethods.FINDEX_SEARCH_OPS.SearchNameMatch; - - - var handle = Transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // FindFirstFileEx() / FindFirstFileTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN confirms LongPath usage. - - // A trailing backslash is not allowed. - ? NativeMethods.FindFirstFileEx(Path.RemoveTrailingDirectorySeparator(pathLp, false), FindExInfoLevel, out win32FindData, searchOption, IntPtr.Zero, LargeCache) - : NativeMethods.FindFirstFileTransacted(Path.RemoveTrailingDirectorySeparator(pathLp, false), FindExInfoLevel, out win32FindData, searchOption, IntPtr.Zero, LargeCache, Transaction.SafeHandle); - - var lastError = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - handle.Close(); - handle = null; - - if (!ContinueOnException) - ThrowPossibleException((uint)lastError, pathLp); - } - - return handle; - } - - - private T NewFileSystemEntryType(bool isFolder, NativeMethods.WIN32_FIND_DATA win32FindData, string fileName, string pathLp) - { - // Determine yield, e.g. don't return files when only folders are requested and vice versa. - if (null != FileSystemObjectType && (!(bool) FileSystemObjectType || !isFolder) && (!(bool) !FileSystemObjectType || isFolder)) - return (T) (object) null; - - // Determine yield. - if (null != fileName && !(_nameFilter == null || (_nameFilter != null && _nameFilter.IsMatch(fileName)))) - return (T) (object) null; - - - var fullPathLp = (IsRelativePath ? OriginalInputPath + Path.DirectorySeparator : pathLp) + (!Utils.IsNullOrWhiteSpace(fileName) ? fileName : string.Empty); - - - // Return object instance FullPath property as string, optionally in long path format. - if (AsString) - return (T) (object) (AsLongPath ? fullPathLp : Path.GetRegularPathCore(fullPathLp, GetFullPathOptions.None, false)); - - - // Make sure the requested file system object type is returned. - // null = Return files and directories. - // true = Return only directories. - // false = Return only files. - - var fsei = new FileSystemEntryInfo(win32FindData) {FullPath = fullPathLp}; - - return AsFileSystemInfo - // Return object instance of type FileSystemInfo. - ? (T) (object) (fsei.IsDirectory - ? (FileSystemInfo) - new DirectoryInfo(Transaction, fsei.LongFullPath, PathFormat.LongFullPath) {EntryInfo = fsei} - : new FileInfo(Transaction, fsei.LongFullPath, PathFormat.LongFullPath) {EntryInfo = fsei}) - - // Return object instance of type FileSystemEntryInfo. - : (T) (object) fsei; - } - - - - - /// Get an enumerator that returns all of the file system objects that match the wildcards that are in any of the directories to be searched. - /// An instance: FileSystemEntryInfo, DirectoryInfo, FileInfo or string (full path). - [SecurityCritical] - public IEnumerable Enumerate() - { - // MSDN: Queue - // Represents a first-in, first-out collection of objects. - // The capacity of a Queue is the number of elements the Queue can hold. - // As elements are added to a Queue, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize. - // The growth factor is the number by which the current capacity is multiplied when a greater capacity is required. The growth factor is determined when the Queue is constructed. - // The capacity of the Queue will always increase by a minimum value, regardless of the growth factor; a growth factor of 1.0 will not prevent the Queue from increasing in size. - // If the size of the collection can be estimated, specifying the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the Queue. - // This constructor is an O(n) operation, where n is capacity. - - var dirs = new Queue(1000); - dirs.Enqueue(InputPath); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - while (dirs.Count > 0) - { - // Removes the object at the beginning of your Queue. - // The algorithmic complexity of this is O(1). It doesn't loop over elements. - - var path = Path.AddTrailingDirectorySeparator(dirs.Dequeue(), false); - var pathLp = path + Path.WildcardStarMatchAll; - NativeMethods.WIN32_FIND_DATA win32FindData; - - using (var handle = FindFirstFile(pathLp, out win32FindData)) - { - if (handle == null && ContinueOnException) - continue; - - do - { - var fileName = win32FindData.cFileName; - - // Skip entries "." and ".." - if (fileName.Equals(Path.CurrentDirectoryPrefix, StringComparison.OrdinalIgnoreCase) || - fileName.Equals(Path.ParentDirectoryPrefix, StringComparison.OrdinalIgnoreCase)) - continue; - - // Skip reparse points here to cleanly separate regular directories from links. - if (SkipReparsePoints && (win32FindData.dwFileAttributes & FileAttributes.ReparsePoint) != 0) - continue; - - - // If object is a folder, add it to the queue for later traversal. - var isFolder = (win32FindData.dwFileAttributes & FileAttributes.Directory) != 0; - - if (Recursive && (win32FindData.dwFileAttributes & FileAttributes.Directory) != 0) - dirs.Enqueue(path + fileName); - - - var res = NewFileSystemEntryType(isFolder, win32FindData, fileName, path); - if (res == null) - continue; - - yield return res; - - - } while (NativeMethods.FindNextFile(handle, out win32FindData)); - - - var lastError = Marshal.GetLastWin32Error(); - - if (!ContinueOnException) - ThrowPossibleException((uint)lastError, pathLp); - } - } - } - - - /// Gets a specific file system object. - /// - /// The return type is based on C# inference. Possible return types are: - /// - (full path), - ( or ), instance - /// or null in case an Exception is raised and is . - /// - [SecurityCritical] - public T Get() - { - NativeMethods.WIN32_FIND_DATA win32FindData; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - using (var handle = FindFirstFile(InputPath, out win32FindData)) - return handle == null - ? (T)(object)null - : NewFileSystemEntryType((win32FindData.dwFileAttributes & FileAttributes.Directory) != 0, win32FindData, null, InputPath); - } - - - - - /// Gets or sets the ability to return the object as a instance. - /// returns the object as a instance. - public bool AsFileSystemInfo { get; internal set; } - - - /// Gets or sets the ability to return the full path in long full path format. - /// returns the full path in long full path format, returns the full path in regular path format. - public bool AsLongPath { get; internal set; } - - - /// Gets or sets the ability to return the object instance as a . - /// returns the full path of the object as a - public bool AsString { get; internal set; } - - - /// Gets the value indicating which to use. - public NativeMethods.FINDEX_INFO_LEVELS FindExInfoLevel { get; internal set; } - - - /// Gets or sets the ability to skip on access errors. - /// suppress any Exception that might be thrown as a result from a failure, such as ACLs protected directories or non-accessible reparse points. - public bool ContinueOnException { get; internal set; } - - - /// Gets the file system object type. - /// - /// = Return files and directories. - /// = Return only directories. - /// = Return only files. - /// - public bool? FileSystemObjectType { get; set; } - - - /// Gets or sets if the path is an absolute or relative path. - /// Gets a value indicating whether the specified path string contains absolute or relative path information. - public bool IsRelativePath { get; set; } - - - /// Gets or sets the initial path to the folder. - /// The initial path to the file or folder in long path format. - public string OriginalInputPath { get; internal set; } - - - /// Gets or sets the path to the folder. - /// The path to the file or folder in long path format. - public string InputPath { get; internal set; } - - - /// Gets or sets a value indicating which to use. - /// indicates a folder object, indicates a file object. - public bool IsDirectory { get; internal set; } - - - /// Gets the value indicating which to use. - public NativeMethods.FindExAdditionalFlags LargeCache { get; internal set; } - - - /// Specifies whether the search should include only the current directory or should include all subdirectories. - /// to all subdirectories. - public bool Recursive { get; internal set; } - - - /// Search for file system object-name using a pattern. - /// The path which has wildcard characters, for example, an asterisk () or a question mark (). - [SuppressMessage("Microsoft.Usage", "CA2208:InstantiateArgumentExceptionsCorrectly")] - public string SearchPattern - { - get { return _searchPattern; } - - internal set - { - if (null == value) - throw new ArgumentNullException("SearchPattern"); - - _searchPattern = value; - - _nameFilter = _searchPattern == Path.WildcardStarMatchAll || WildcardMatchAll.IsMatch(_searchPattern) - ? null - : new Regex(string.Format(CultureInfo.CurrentCulture, "^{0}$", Regex.Escape(_searchPattern).Replace(@"\*", ".*").Replace(@"\?", ".")), RegexOptions.IgnoreCase | RegexOptions.Compiled); - } - } - - - /// skips ReparsePoints, will follow ReparsePoints. - public bool SkipReparsePoints { get; internal set; } - - - /// Get or sets the KernelTransaction instance. - /// The transaction. - public KernelTransaction Transaction { get; internal set; } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/KernelTransaction.cs b/FolderMonitor/AlphaFS/Filesystem/KernelTransaction.cs deleted file mode 100644 index 0501d4a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/KernelTransaction.cs +++ /dev/null @@ -1,159 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using System.Security.Permissions; -using System.Transactions; - -namespace Alphaleonis.Win32.Filesystem -{ - [ComImport] - [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [Guid("79427A2B-F895-40e0-BE79-B57DC82ED231")] - [SuppressUnmanagedCodeSecurity] - internal interface IKernelTransaction - { - void GetHandle([Out] out SafeKernelTransactionHandle handle); - } - - /// A KTM transaction object for use with the transacted operations in - public sealed class KernelTransaction : MarshalByRefObject, IDisposable - { - /// Initializes a new instance of the class, internally using the specified . - /// This method allows the usage of methods accepting a with an instance of . - /// - /// The transaction to use for any transactional operations. - [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] - [SecurityCritical] - public KernelTransaction(Transaction transaction) - { - ((IKernelTransaction) TransactionInterop.GetDtcTransaction(transaction)).GetHandle(out _hTrans); - } - - /// Initializes a new instance of the class with a default security descriptor, infinite timeout and no description. - [SecurityCritical] - public KernelTransaction() - : this(0, null) - { - } - - /// Initializes a new instance of the class with a default security descriptor. - /// The time, in milliseconds, when the transaction will be aborted if it has not already reached the prepared state. - /// A user-readable description of the transaction. This parameter may be . - [SecurityCritical] - public KernelTransaction(int timeout, string description) - : this(null, timeout, description) - { - } - - /// Initializes a new instance of the class. - /// The security descriptor. - /// The time, in milliseconds, when the transaction will be aborted if it has not already reached the prepared state. - /// Specify 0 to provide an infinite timeout. - /// A user-readable description of the transaction. This parameter may be . - [SecurityCritical] - public KernelTransaction(ObjectSecurity securityDescriptor, int timeout, string description) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - using (var securityAttributes = new Security.NativeMethods.SecurityAttributes(securityDescriptor)) - { - - _hTrans = NativeMethods.CreateTransaction(securityAttributes, IntPtr.Zero, 0, 0, 0, timeout, description); - int lastError = Marshal.GetLastWin32Error(); - - NativeMethods.IsValidHandle(_hTrans, lastError); - } - } - - /// Requests that the specified transaction be committed. - /// - /// - /// - [SecurityCritical] - public void Commit() - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - if (!NativeMethods.CommitTransaction(_hTrans)) - CheckTransaction(); - } - - /// Requests that the specified transaction be rolled back. This function is synchronous. - /// - /// - [SecurityCritical] - public void Rollback() - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - if (!NativeMethods.RollbackTransaction(_hTrans)) - CheckTransaction(); - } - - private static void CheckTransaction() - { - uint error = (uint) Marshal.GetLastWin32Error(); - int hr = Marshal.GetHRForLastWin32Error(); - - switch (error) - { - case Win32Errors.ERROR_TRANSACTION_ALREADY_ABORTED: - throw new TransactionAlreadyAbortedException("Transaction was already aborted", Marshal.GetExceptionForHR(hr)); - - case Win32Errors.ERROR_TRANSACTION_ALREADY_COMMITTED: - throw new TransactionAlreadyAbortedException("Transaction was already committed", Marshal.GetExceptionForHR(hr)); - - default: - Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); - break; - } - } - - /// Gets the safe handle. - /// The safe handle. - public SafeHandle SafeHandle - { - get { return _hTrans; } - } - - private readonly SafeKernelTransactionHandle _hTrans; - - #region IDisposable Members - - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - [SecurityPermissionAttribute(SecurityAction.Demand, UnmanagedCode = true)] - public void Dispose() - { - _hTrans.Close(); - } - - #endregion // IDisposable Members - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/LinkTargetInfo.cs b/FolderMonitor/AlphaFS/Filesystem/LinkTargetInfo.cs deleted file mode 100644 index 5e9876a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/LinkTargetInfo.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Information about the target of a symbolic link or mount point. - public class LinkTargetInfo - { - internal LinkTargetInfo(string substituteName, string printName) - { - PrintName = printName; - SubstituteName = substituteName; - } - - /// The print name. - public string PrintName { get; private set; } - - /// The substitute name. - public string SubstituteName { get; private set; } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs deleted file mode 100644 index 0e56e35..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.BackupStreams.cs +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// The BackupRead function can be used to back up a file or directory, including the security information. - /// The function reads data associated with a specified file or directory into a buffer, - /// which can then be written to the backup medium using the WriteFile function. - /// - /// - /// This function is not intended for use in backing up files encrypted under the Encrypted File System. - /// Use ReadEncryptedFileRaw for that purpose. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// The file. - /// The buffer. - /// Number of bytes to reads. - /// [out] Number of bytes reads. - /// true to abort. - /// true to process security. - /// [out] The context. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero, indicating that an I/O error occurred. To get extended error information, - /// call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool BackupRead(SafeFileHandle hFile, SafeGlobalMemoryBufferHandle lpBuffer, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToRead, [MarshalAs(UnmanagedType.U4)] out uint lpNumberOfBytesRead, [MarshalAs(UnmanagedType.Bool)] bool bAbort, [MarshalAs(UnmanagedType.Bool)] bool bProcessSecurity, ref IntPtr lpContext); - - - /// The BackupSeek function seeks forward in a data stream initially accessed by using the or - /// function. - /// The function reads data associated with a specified file or directory into a buffer, which can then be written to the backup - /// medium using the WriteFile function. - /// - /// - /// Applications use the BackupSeek function to skip portions of a data stream that cause errors. - /// This function does not seek across stream headers. For example, this function cannot be used to skip the stream name. - /// If an application attempts to seek past the end of a substream, the function fails, the lpdwLowByteSeeked and - /// lpdwHighByteSeeked parameters - /// indicate the actual number of bytes the function seeks, and the file position is placed at the start of the next stream - /// header. - ///   - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// The file. - /// The low bytes to seek. - /// The high bytes to seek. - /// [out] The lpdw low bytes seeked. - /// [out] The lpdw high bytes seeked. - /// [out] The context. - /// - /// If the function could seek the requested amount, the function returns a nonzero value. - /// If the function could not seek the requested amount, the function returns zero. To get extended error information, call - /// GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool BackupSeek(SafeFileHandle hFile, [MarshalAs(UnmanagedType.U4)] uint dwLowBytesToSeek, [MarshalAs(UnmanagedType.U4)] uint dwHighBytesToSeek, [MarshalAs(UnmanagedType.U4)] out uint lpdwLowBytesSeeked, [MarshalAs(UnmanagedType.U4)] out uint lpdwHighBytesSeeked, ref IntPtr lpContext); - - - /// The BackupWrite function can be used to restore a file or directory that was backed up using . - /// Use the ReadFile function to get a stream of data from the backup medium, then use BackupWrite to write the data to the - /// specified file or directory. - ///   - /// - /// - /// This function is not intended for use in restoring files encrypted under the Encrypted File System. Use WriteEncryptedFileRaw - /// for that purpose. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// The file. - /// The buffer. - /// Number of bytes to writes. - /// [out] Number of bytes writtens. - /// true to abort. - /// true to process security. - /// [out] The context. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero, indicating that an I/O error occurred. To get extended error information, - /// call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool BackupWrite(SafeFileHandle hFile, SafeGlobalMemoryBufferHandle lpBuffer, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToWrite, [MarshalAs(UnmanagedType.U4)] out uint lpNumberOfBytesWritten, [MarshalAs(UnmanagedType.Bool)] bool bAbort, [MarshalAs(UnmanagedType.Bool)] bool bProcessSecurity, ref IntPtr lpContext); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs deleted file mode 100644 index 6f87972..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Constants.cs +++ /dev/null @@ -1,67 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - public static readonly bool IsAtLeastWindows7 = OperatingSystem.IsAtLeast(OperatingSystem.EnumOsName.Windows7); - public static readonly bool IsAtLeastWindowsVista = OperatingSystem.IsAtLeast(OperatingSystem.EnumOsName.WindowsVista); - - /// The FindFirstFileEx function does not query the short file name, improving overall enumeration speed. - ///   - /// - /// The data is returned in a structure, - /// and cAlternateFileName member is always a NULL string. - /// This value is not supported until Windows Server 2008 R2 and Windows 7. - /// - /// - public static readonly FINDEX_INFO_LEVELS FindexInfoLevels = IsAtLeastWindows7 ? FINDEX_INFO_LEVELS.Basic : FINDEX_INFO_LEVELS.Standard; - - /// Uses a larger buffer for directory queries, which can increase performance of the find operation. - /// This value is not supported until Windows Server 2008 R2 and Windows 7. - public static readonly FindExAdditionalFlags LargeCache = IsAtLeastWindows7 ? FindExAdditionalFlags.LargeFetch : FindExAdditionalFlags.None; - - /// DefaultFileBufferSize = 4096; Default type buffer size used for reading and writing files. - public const int DefaultFileBufferSize = 4096; - - /// DefaultFileEncoding = Encoding.UTF8; Default type of Encoding used for reading and writing files. - public static readonly Encoding DefaultFileEncoding = Encoding.UTF8; - - /// MaxDirectoryLength = 255 - internal const int MaxDirectoryLength = 255; - - /// MaxPath = 260 - /// The specified path, file name, or both exceed the system-defined maximum length. - /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. - /// - internal const int MaxPath = 260; - - /// MaxPathUnicode = 32000 - internal const int MaxPathUnicode = 32000; - - - /// When an exception is raised, bit shifting is needed to prevent: "System.OverflowException: Arithmetic operation resulted in an overflow." - internal const int OverflowExceptionBitShift = 65535; - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs deleted file mode 100644 index c1265ec..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DeviceManagement.cs +++ /dev/null @@ -1,291 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - #region CM_Xxx - - /// The CM_Connect_Machine function creates a connection to a remote machine. - /// - /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. - /// You cannot access remote machines when running on these versions of Windows. - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// Name of the unc server. - /// [out] The ph machine. - /// - /// If the operation succeeds, the function returns CR_SUCCESS. - /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CM_Connect_MachineW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I4)] - public static extern int CM_Connect_Machine([MarshalAs(UnmanagedType.LPWStr)] string uncServerName, out SafeCmConnectMachineHandle phMachine); - - /// - /// The CM_Get_Device_ID_Ex function retrieves the device instance ID for a specified device instance on a local or a remote machine. - /// - /// - /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. - /// You cannot access remote machines when running on these versions of Windows. - ///   - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// The dn development instance. - /// The buffer. - /// Length of the buffer. - /// The ul flags. - /// The machine. - /// - /// If the operation succeeds, the function returns CR_SUCCESS. - /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CM_Get_Device_ID_ExW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I4)] - public static extern int CM_Get_Device_ID_Ex([MarshalAs(UnmanagedType.U4)] uint dnDevInst, SafeGlobalMemoryBufferHandle buffer, [MarshalAs(UnmanagedType.U4)] uint bufferLen, [MarshalAs(UnmanagedType.U4)] uint ulFlags, SafeCmConnectMachineHandle hMachine); - - /// - /// The CM_Disconnect_Machine function removes a connection to a remote machine. - /// - /// - /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. - /// You cannot access remote machines when running on these versions of Windows. - /// SetLastError is set to . - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// The machine. - /// - /// If the operation succeeds, the function returns CR_SUCCESS. - /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I4)] - internal static extern int CM_Disconnect_Machine(IntPtr hMachine); - - /// - /// The CM_Get_Parent_Ex function obtains a device instance handle to the parent node of a specified device node (devnode) in a local - /// or a remote machine's device tree. - /// - /// - /// Beginning in Windows 8 and Windows Server 2012 functionality to access remote machines has been removed. - /// You cannot access remote machines when running on these versions of Windows. - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// [out] The pdn development instance. - /// The dn development instance. - /// The ul flags. - /// The machine. - /// - /// If the operation succeeds, the function returns CR_SUCCESS. - /// Otherwise, it returns one of the CR_-prefixed error codes defined in Cfgmgr32.h. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I4)] - internal static extern int CM_Get_Parent_Ex([MarshalAs(UnmanagedType.U4)] out uint pdnDevInst, [MarshalAs(UnmanagedType.U4)] uint dnDevInst, [MarshalAs(UnmanagedType.U4)] uint ulFlags, SafeCmConnectMachineHandle hMachine); - - #endregion // CM_Xxx - - #region DeviceIoControl - - /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. - /// - /// If the operation completes successfully, the return value is nonzero. - /// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError. - /// - /// - /// To retrieve a handle to the device, you must call the function with either the name of a device or - /// the name of the driver associated with a device. - /// To specify a device name, use the following format: \\.\DeviceName - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - /// - /// The device. - /// The i/o control code. - /// Buffer for in data. - /// Size of the in buffer. - /// Buffer for out data. - /// Size of the out buffer. - /// [out] The bytes returned. - /// The overlapped. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DeviceIoControl(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] uint dwIoControlCode, IntPtr lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, SafeGlobalMemoryBufferHandle lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, [MarshalAs(UnmanagedType.U4)] out uint lpBytesReturned, IntPtr lpOverlapped); - - /// Sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation. - /// - /// If the operation completes successfully, the return value is nonzero. - /// If the operation fails or is pending, the return value is zero. To get extended error information, call GetLastError. - /// - /// - /// To retrieve a handle to the device, you must call the function with either the name of a device or - /// the name of the driver associated with a device. - /// To specify a device name, use the following format: \\.\DeviceName - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - /// - /// The device. - /// The i/o control code. - /// Buffer for in data. - /// Size of the in buffer. - /// Buffer for out data. - /// Size of the out buffer. - /// [out] The bytes returned. - /// The overlapped. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DeviceIoControl(SafeFileHandle hDevice, [MarshalAs(UnmanagedType.U4)] uint dwIoControlCode, [MarshalAs(UnmanagedType.AsAny)] object lpInBuffer, [MarshalAs(UnmanagedType.U4)] uint nInBufferSize, [MarshalAs(UnmanagedType.AsAny)] [Out] object lpOutBuffer, [MarshalAs(UnmanagedType.U4)] uint nOutBufferSize, [MarshalAs(UnmanagedType.U4)] out uint lpBytesReturned, IntPtr lpOverlapped); - - #endregion // DeviceIoControl - - #region SetupDiXxx - - /// - /// The SetupDiDestroyDeviceInfoList function deletes a device information set and frees all associated memory. - /// - /// - /// SetLastError is set to . - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// Information describing the development. - /// - /// The function returns TRUE if it is successful. - /// Otherwise, it returns FALSE and the logged error can be retrieved with a call to GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool SetupDiDestroyDeviceInfoList(IntPtr hDevInfo); - - /// - /// The SetupDiEnumDeviceInterfaces function enumerates the device interfaces that are contained in a device information set. - /// - /// - /// Repeated calls to this function return an structure for a different device - /// interface. - /// This function can be called repeatedly to get information about interfaces in a device information set that are - /// associated - /// with a particular device information element or that are associated with all device information elements. - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// Information describing the development. - /// Information describing the development. - /// [in,out] Unique identifier for the interface class. - /// Zero-based index of the member. - /// [in,out] Information describing the device interface. - /// - /// SetupDiEnumDeviceInterfaces returns TRUE if the function completed without error. - /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling - /// GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetupDiEnumDeviceInterfaces(SafeHandle hDevInfo, IntPtr devInfo, ref Guid interfaceClassGuid, [MarshalAs(UnmanagedType.U4)] uint memberIndex, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData); - - /// - /// The SetupDiGetClassDevsEx function returns a handle to a device information set that contains requested device information elements - /// for a local or a remote computer. - /// - /// - /// The caller of SetupDiGetClassDevsEx must delete the returned device information set when it is no longer needed by calling - /// . - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// [in,out] Unique identifier for the class. - /// The enumerator. - /// The parent. - /// The devs ex flags. - /// Set the device information belongs to. - /// Name of the machine. - /// The reserved. - /// - /// If the operation succeeds, SetupDiGetClassDevsEx returns a handle to a device information set that contains all installed - /// devices that matched the supplied parameters. - /// If the operation fails, the function returns INVALID_HANDLE_VALUE. To get extended error information, call - /// GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern SafeSetupDiClassDevsExHandle SetupDiGetClassDevsEx(ref Guid classGuid, IntPtr enumerator, IntPtr hwndParent, [MarshalAs(UnmanagedType.U4)] SetupDiGetClassDevsExFlags devsExFlags, IntPtr deviceInfoSet, [MarshalAs(UnmanagedType.LPWStr)] string machineName, IntPtr reserved); - - /// - /// The SetupDiGetDeviceInterfaceDetail function returns details about a device interface. - /// - /// - /// The interface detail returned by this function consists of a device path that can be passed to Win32 functions such as - /// CreateFile. - /// Do not attempt to parse the device path symbolic name. The device path can be reused across system starts. - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// - /// Information describing the development. - /// [in,out] Information describing the device interface. - /// [in,out] Information describing the device interface detail. - /// Size of the device interface detail data. - /// Size of the required. - /// [in,out] Information describing the device information. - /// - /// SetupDiGetDeviceInterfaceDetail returns TRUE if the function completed without error. - /// If the function completed with an error, FALSE is returned and the error code for the failure can be retrieved by calling - /// GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetupDiGetDeviceInterfaceDetail(SafeHandle hDevInfo, ref SP_DEVICE_INTERFACE_DATA deviceInterfaceData, ref SP_DEVICE_INTERFACE_DETAIL_DATA deviceInterfaceDetailData, [MarshalAs(UnmanagedType.U4)] uint deviceInterfaceDetailDataSize, IntPtr requiredSize, ref SP_DEVINFO_DATA deviceInfoData); - - /// - /// The SetupDiGetDeviceRegistryProperty function retrieves a specified Plug and Play device property. - /// - /// Available in Microsoft Windows 2000 and later versions of Windows. - /// Set the device information belongs to. - /// [in,out] Information describing the device information. - /// The property. - /// [out] Type of the property register data. - /// Buffer for property data. - /// Size of the property buffer. - /// Size of the required. - /// - /// SetupDiGetDeviceRegistryProperty returns TRUE if the call was successful. - /// Otherwise, it returns FALSE and the logged error can be retrieved by making a call to GetLastError. - /// SetupDiGetDeviceRegistryProperty returns the ERROR_INVALID_DATA error code if the requested property does not exist for a - /// device or if the property data is not valid. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetupDiGetDeviceRegistryProperty(SafeHandle deviceInfoSet, ref SP_DEVINFO_DATA deviceInfoData, SetupDiGetDeviceRegistryPropertyEnum property, [MarshalAs(UnmanagedType.U4)] out uint propertyRegDataType, SafeGlobalMemoryBufferHandle propertyBuffer, [MarshalAs(UnmanagedType.U4)] uint propertyBufferSize, IntPtr requiredSize); - - #endregion // SetupDiXxx - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DirectoryManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DirectoryManagement.cs deleted file mode 100644 index 0ee7079..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DirectoryManagement.cs +++ /dev/null @@ -1,208 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// - /// Creates a new directory. - /// If the underlying file system supports security on files and directories, - /// the function applies a specified security descriptor to the new directory. - /// - /// - /// Some file systems, such as the NTFS file system, support compression or encryption for individual files and - /// directories. - /// On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent - /// directory. - /// An application can obtain a handle to a directory by calling with the FILE_FLAG_BACKUP_SEMANTICS - /// flag set. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - /// Full pathname of the file. - /// The security attributes. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateDirectoryW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CreateDirectory([MarshalAs(UnmanagedType.LPWStr)] string lpPathName, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes); - - /// - /// Creates a new directory with the attributes of a specified template directory. - /// If the underlying file system supports security on files and directories, - /// the function applies a specified security descriptor to the new directory. - /// The new directory retains the other attributes of the specified template directory. - /// - /// - /// The CreateDirectoryEx function allows you to create directories that inherit stream information from other directories. - /// This function is useful, for example, when you are using Macintosh directories, which have a resource stream - /// that is needed to properly identify directory contents as an attribute. - /// Some file systems, such as the NTFS file system, support compression or encryption for individual files and - /// directories. - /// On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent - /// directory. - /// You can obtain a handle to a directory by calling the function with the FILE_FLAG_BACKUP_SEMANTICS - /// flag set. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Pathname of the template directory. - /// Full pathname of the file. - /// The security attributes. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateDirectoryExW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CreateDirectoryEx([MarshalAs(UnmanagedType.LPWStr)] string lpTemplateDirectory, [MarshalAs(UnmanagedType.LPWStr)] string lpPathName, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes); - - /// - /// Creates a new directory as a transacted operation, with the attributes of a specified template directory. - /// If the underlying file system supports security on files and directories, - /// the function applies a specified security descriptor to the new directory. - /// The new directory retains the other attributes of the specified template directory. - /// - /// - /// The CreateDirectoryTransacted function allows you to create directories that inherit stream information from other - /// directories. - /// This function is useful, for example, when you are using Macintosh directories, which have a resource stream - /// that is needed to properly identify directory contents as an attribute. - /// Some file systems, such as the NTFS file system, support compression or encryption for individual files and - /// directories. - /// On volumes formatted for such a file system, a new directory inherits the compression and encryption attributes of its parent - /// directory. - /// You can obtain a handle to a directory by calling the function with the - /// FILE_FLAG_BACKUP_SEMANTICS flag set. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Pathname of the template directory. - /// Pathname of the new directory. - /// The security attributes. - /// The transaction. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. - /// This function fails with ERROR_EFS_NOT_ALLOWED_IN_TRANSACTION if you try to create a - /// child directory with a parent directory that has encryption disabled. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateDirectoryTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CreateDirectoryTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpTemplateDirectory, [MarshalAs(UnmanagedType.LPWStr)] string lpNewDirectory, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes, SafeHandle hTransaction); - - /// - /// Retrieves the current directory for the current process. - /// - /// - /// The RemoveDirectory function marks a directory for deletion on close. - /// Therefore, the directory is not removed until the last handle to the directory is closed. - /// RemoveDirectory removes a directory junction, even if the contents of the target are not empty; - /// the function removes directory junctions regardless of the state of the target object. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - /// The length of the buffer for the current directory string, in TCHARs. The buffer length must include room for a terminating null character. - /// - /// A pointer to the buffer that receives the current directory string. This null-terminated string specifies the absolute path to the current directory. - /// To determine the required buffer size, set this parameter to NULL and the nBufferLength parameter to 0. - /// - /// - /// If the function succeeds, the return value specifies the number of characters that are written to the buffer, not including the terminating null character. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Usage", "CA2205:UseManagedEquivalentsOfWin32Api")] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetCurrentDirectoryW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetCurrentDirectory([MarshalAs(UnmanagedType.U4)] uint nBufferLength, StringBuilder lpBuffer); - - /// - /// Deletes an existing empty directory. - /// - /// - /// The RemoveDirectory function marks a directory for deletion on close. - /// Therefore, the directory is not removed until the last handle to the directory is closed. - /// RemoveDirectory removes a directory junction, even if the contents of the target are not empty; - /// the function removes directory junctions regardless of the state of the target object. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - /// Full pathname of the file. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "RemoveDirectoryW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RemoveDirectory([MarshalAs(UnmanagedType.LPWStr)] string lpPathName); - - /// - /// Deletes an existing empty directory as a transacted operation. - /// - /// - /// The RemoveDirectoryTransacted function marks a directory for deletion on close. - /// Therefore, the directory is not removed until the last handle to the directory is closed. - /// RemoveDirectory removes a directory junction, even if the contents of the target are not empty; - /// the function removes directory junctions regardless of the state of the target object. - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - /// - /// Full pathname of the file. - /// The transaction. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "RemoveDirectoryTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RemoveDirectoryTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpPathName, SafeHandle hTransaction); - - /// - /// Changes the current directory for the current process. - /// - /// - /// The path to the new current directory. This parameter may specify a relative path or a full path. In either case, the full path of the specified directory is calculated and stored as the current directory. - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Usage", "CA2205:UseManagedEquivalentsOfWin32Api")] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetCurrentDirectoryW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetCurrentDirectory([MarshalAs(UnmanagedType.LPWStr)] string lpPathName); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs deleted file mode 100644 index 1853217..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.DiskManagement.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// - /// Retrieves information about the specified disk, including the amount of free space on the disk. - /// - /// - /// Symbolic link behavior: If the path points to a symbolic link, the operation is performed on the target. - /// If this parameter is a UNC name, it must include a trailing backslash (for example, "\\MyServer\MyShare\"). - /// Furthermore, a drive specification must have a trailing backslash (for example, "C:\"). - /// The calling application must have FILE_LIST_DIRECTORY access rights for this directory. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Full pathname of the root file. - /// [out] The sectors per cluster. - /// [out] The bytes per sector. - /// [out] Number of free clusters. - /// [out] The total number of clusters. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetDiskFreeSpaceW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetDiskFreeSpace([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, [MarshalAs(UnmanagedType.U4)] out int lpSectorsPerCluster, [MarshalAs(UnmanagedType.U4)] out int lpBytesPerSector, [MarshalAs(UnmanagedType.U4)] out int lpNumberOfFreeClusters, [MarshalAs(UnmanagedType.U4)] out uint lpTotalNumberOfClusters); - - /// - /// Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, - /// the total amount of free space, and the total amount of free space available to the user that is associated with the calling - /// thread. - /// - /// - /// Symbolic link behavior: If the path points to a symbolic link, the operation is performed on the target. - /// The GetDiskFreeSpaceEx function returns zero (0) for lpTotalNumberOfFreeBytes and lpFreeBytesAvailable - /// for all CD requests unless the disk is an unwritten CD in a CD-RW drive. - /// If this parameter is a UNC name, it must include a trailing backslash, for example, "\\MyServer\MyShare\". - /// This parameter does not have to specify the root directory on a disk. - /// The function accepts any directory on a disk. - /// The calling application must have FILE_LIST_DIRECTORY access rights for this directory. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - /// - /// Pathname of the directory. - /// [out] The free bytes available. - /// [out] The total number of in bytes. - /// [out] The total number of free in bytes. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero (0). To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetDiskFreeSpaceExW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetDiskFreeSpaceEx([MarshalAs(UnmanagedType.LPWStr)] string lpDirectoryName, [MarshalAs(UnmanagedType.U8)] out long lpFreeBytesAvailable, [MarshalAs(UnmanagedType.U8)] out long lpTotalNumberOfBytes, [MarshalAs(UnmanagedType.U8)] out long lpTotalNumberOfFreeBytes); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs deleted file mode 100644 index 1e94f71..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.EncryptedFileRaw.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - partial class NativeMethods - { - /// Opens an encrypted file in order to backup (export) or restore (import) the file. - /// If the function succeeds, it returns ERROR_SUCCESS. - /// If the function fails, it returns a nonzero error code defined in WinError.h. You can use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic text description of the error. - /// Minimum supported client: Windows XP Professional [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// The name of the file to be opened. - /// The operation to be performed. - /// [out] The address of a context block that must be presented in subsequent calls to - /// ReadEncryptedFileRaw, WriteEncryptedFileRaw, or CloseEncryptedFileRaw. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "OpenEncryptedFileRawW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint OpenEncryptedFileRaw([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, EncryptedFileRawMode ulFlags, out SafeEncryptedFileRawHandle pvContext); - - - /// Closes an encrypted file after a backup or restore operation, and frees associated system resources. - /// Minimum supported client: Windows XP Professional [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// A pointer to a system-defined context block. The OpenEncryptedFileRaw function returns the context block. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern void CloseEncryptedFileRaw(IntPtr pvContext); - - - /// Backs up (export) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// If the function succeeds, it returns ERROR_SUCCESS. - /// If the function fails, it returns a nonzero error code defined in WinError.h. You can use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic text description of the error. - /// Minimum supported client: Windows XP Professional [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), SuppressUnmanagedCodeSecurity] - [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint ReadEncryptedFileRaw([MarshalAs(UnmanagedType.FunctionPtr)] EncryptedFileRawExportCallback pfExportCallback, IntPtr pvCallbackContext, SafeEncryptedFileRawHandle pvContext); - - - /// Restores (import) encrypted files. This is one of a group of Encrypted File System (EFS) functions that is intended to implement backup and restore functionality, while maintaining files in their encrypted state. - /// If the function succeeds, it returns ERROR_SUCCESS. - /// If the function fails, it returns a nonzero error code defined in WinError.h. You can use FormatMessage with the FORMAT_MESSAGE_FROM_SYSTEM flag to get a generic text description of the error. - /// Minimum supported client: Windows XP Professional [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("Advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint WriteEncryptedFileRaw([MarshalAs(UnmanagedType.FunctionPtr)] EncryptedFileRawImportCallback pfExportCallback, IntPtr pvCallbackContext, SafeEncryptedFileRawHandle pvContext); - - - [SuppressUnmanagedCodeSecurity] - internal delegate int EncryptedFileRawExportCallback(IntPtr pbData, IntPtr pvCallbackContext, uint ulLength); - - [SuppressUnmanagedCodeSecurity] - internal delegate int EncryptedFileRawImportCallback(IntPtr pbData, IntPtr pvCallbackContext, ref uint ulLength); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs deleted file mode 100644 index 40bc36b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.FileManagement.cs +++ /dev/null @@ -1,760 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.AccessControl; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// - /// Copies an existing file to a new file, notifying the application of its progress through a callback function. - /// - /// - /// This function fails with ERROR_ACCESS_DENIED if the destination file already exists and has the FILE_ATTRIBUTE_HIDDEN or - /// FILE_ATTRIBUTE_READONLY attribute set. - /// This function preserves extended attributes, OLE structured storage, NTFS file system alternate data streams, security - /// resource attributes, and file attributes. - /// Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - /// Security resource attributes (ATTRIBUTE_SECURITY_INFORMATION) for the existing file are not copied to the new file until - /// Windows 8 and Windows Server 2012. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Filename of the existing file. - /// Filename of the new file. - /// The progress routine. - /// The data. - /// [out] The pb cancel. - /// The copy flags. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CopyFileExW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CopyFileEx([MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName, NativeCopyMoveProgressRoutine lpProgressRoutine, IntPtr lpData, [MarshalAs(UnmanagedType.Bool)] out bool pbCancel, CopyOptions dwCopyFlags); - - /// - /// Copies an existing file to a new file as a transacted operation, notifying the application of its progress through a callback - /// function. - /// - /// - /// This function fails with ERROR_ACCESS_DENIED if the destination file already exists and has the FILE_ATTRIBUTE_HIDDEN or - /// FILE_ATTRIBUTE_READONLY attribute set. - /// This function preserves extended attributes, OLE structured storage, NTFS file system alternate data streams, security - /// resource attributes, and file attributes. - /// Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: - /// Security resource attributes (ATTRIBUTE_SECURITY_INFORMATION) for the existing file are not copied to the new file until - /// Windows 8 and Windows Server 2012. - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CopyFileTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CopyFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName, NativeCopyMoveProgressRoutine lpProgressRoutine, IntPtr lpData, [MarshalAs(UnmanagedType.Bool)] out bool pbCancel, CopyOptions dwCopyFlags, SafeHandle hTransaction); - - /// - /// Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical - /// disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. - /// - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot. If the - /// function fails, the return value is Win32Errors.ERROR_INVALID_HANDLE. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateFileW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFileHandle CreateFile([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileSystemRights dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare dwShareMode, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] ExtendedFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile); - - /// - /// Creates or opens a file or I/O device. The most commonly used I/O devices are as follows: file, file stream, directory, physical - /// disk, volume, console buffer, tape drive, communications resource, mailslot, and pipe. - /// - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is an open handle to the specified file, device, named pipe, or mail slot. If the - /// function fails, the return value is Win32Errors.ERROR_INVALID_HANDLE". To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateFileTransactedW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFileHandle CreateFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileSystemRights dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] FileShare dwShareMode, [MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] FileMode dwCreationDisposition, [MarshalAs(UnmanagedType.U4)] ExtendedFileAttributes dwFlagsAndAttributes, IntPtr hTemplateFile, SafeHandle hTransaction, IntPtr pusMiniVersion, IntPtr pExtendedParameter); - - /// Creates or opens a named or unnamed file mapping object for a specified file. - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is a handle to the newly created file mapping object. If the function fails, the return - /// value is . - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode, EntryPoint = "CreateFileMappingW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFileHandle CreateFileMapping(SafeFileHandle hFile, SafeHandle lpSecurityAttributes, [MarshalAs(UnmanagedType.U4)] uint flProtect, [MarshalAs(UnmanagedType.U4)] uint dwMaximumSizeHigh, [MarshalAs(UnmanagedType.U4)] uint dwMaximumSizeLow, [MarshalAs(UnmanagedType.LPWStr)] string lpName); - - /// - /// Establishes a hard link between an existing file and a new file. This function is only supported on the NTFS file system, and only - /// for files, not directories. - /// - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateHardLinkW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CreateHardLink([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, IntPtr lpSecurityAttributes); - - /// - /// Establishes a hard link between an existing file and a new file as a transacted operation. This function is only supported on the - /// NTFS file system, and only for files, not directories. - /// - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateHardLinkTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CreateHardLinkTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, IntPtr lpSecurityAttributes, SafeHandle hTransaction); - - /// Creates a symbolic link. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// The unmanaged prototype contains a return directive because the CreateSymbolicLink API function returns BOOLEAN, a one-byte data type. - /// The default marshaling for bool is four bytes (to allow seamless integration with BOOL return values). - /// If you were to use the default marshaling for BOOLEAN values, it's likely that you will get erroneous results. - /// The return directive forces PInvoke to marshal just one byte of the return value. - /// Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=762&ns=16196 - /// - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateSymbolicLinkW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I1)] - internal static extern bool CreateSymbolicLink([MarshalAs(UnmanagedType.LPWStr)] string lpSymlinkFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpTargetFileName, [MarshalAs(UnmanagedType.U4)] SymbolicLinkTarget dwFlags); - - /// Creates a symbolic link as a transacted operation. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// The unmanaged prototype contains a return directive because the CreateSymbolicLink API function returns BOOLEAN, a one-byte data type. - /// The default marshaling for bool is four bytes (to allow seamless integration with BOOL return values). - /// If you were to use the default marshaling for BOOLEAN values, it's likely that you will get erroneous results. - /// The return directive forces PInvoke to marshal just one byte of the return value. - /// Source: http://www.informit.com/guides/content.aspx?g=dotnet&seqNum=762&ns=16196 - /// - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "CreateSymbolicLinkTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.I1)] - internal static extern bool CreateSymbolicLinkTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpSymlinkFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpTargetFileName, [MarshalAs(UnmanagedType.U4)] SymbolicLinkTarget dwFlags, SafeHandle hTransaction); - - /// Decrypts an encrypted file or directory. - /// - /// The DecryptFile function requires exclusive access to the file being decrypted, and will fail if another process is using the file. - /// If the file is not encrypted, DecryptFile simply returns a nonzero value, which indicates success. If lpFileName specifies a read- - /// only file, the function fails and GetLastError returns ERROR_FILE_READ_ONLY. If lpFileName specifies a directory that contains a - /// read-only file, the functions succeeds but the directory is not decrypted. - /// - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DecryptFileW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DecryptFile([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint dwReserved); - - /// Deletes an existing file. - /// - /// If an application attempts to delete a file that does not exist, the DeleteFile function fails with ERROR_FILE_NOT_FOUND. - /// - /// If the file is a read-only file, the function fails with ERROR_ACCESS_DENIED. - /// - /// If the path points to a symbolic link, the symbolic link is deleted, not the target. To delete a target, you must call CreateFile - /// and specify FILE_FLAG_DELETE_ON_CLOSE. - /// - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]. - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeleteFileW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DeleteFile([MarshalAs(UnmanagedType.LPWStr)] string lpFileName); - - /// Deletes an existing file as a transacted operation. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeleteFileTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DeleteFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, SafeHandle hTransaction); - - /// - /// Encrypts a file or directory. All data streams in a file are encrypted. All new files created in an encrypted directory are - /// encrypted. - /// - /// - /// The EncryptFile function requires exclusive access to the file being encrypted, and will fail if another process is using the file. - /// If the file is already encrypted, EncryptFile simply returns a nonzero value, which indicates success. If the file is compressed, - /// EncryptFile will decompress the file before encrypting it. If lpFileName specifies a read-only file, the function fails and - /// GetLastError returns ERROR_FILE_READ_ONLY. If lpFileName specifies a directory that contains a read-only file, the functions - /// succeeds but the directory is not encrypted. - /// - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "EncryptFileW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EncryptFile([MarshalAs(UnmanagedType.LPWStr)] string lpFileName); - - /// - /// Disables or enables encryption of the specified directory and the files in it. It does not affect encryption of subdirectories - /// below the indicated directory. - /// - /// - /// EncryptionDisable() disables encryption of directories and files. It does not affect the visibility of files with the - /// FILE_ATTRIBUTE_SYSTEM attribute set. This method will create/change the file "Desktop.ini" and wil set Encryption value: - /// "Disable=0|1". - /// - /// Minimum supported client: Windows XP Professional [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), SuppressUnmanagedCodeSecurity] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool EncryptionDisable([MarshalAs(UnmanagedType.LPWStr)] string dirPath, [MarshalAs(UnmanagedType.Bool)] bool disable); - - /// Retrieves the encryption status of the specified file. - /// Minimum supported client: Windows XP Professional [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FileEncryptionStatusW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FileEncryptionStatus([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, out FileEncryptionStatus lpStatus); - - /// - /// Closes a file search handle opened by the FindFirstFile, FindFirstFileEx, FindFirstFileNameW, FindFirstFileNameTransactedW, - /// FindFirstFileTransacted, FindFirstStreamTransactedW, or FindFirstStreamW functions. - /// - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]. - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), SuppressUnmanagedCodeSecurity] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindClose(IntPtr hFindFile); - - /// Searches a directory for a file or subdirectory with a name and attributes that match those specified. - /// A trailing backslash is not allowed and will be removed. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]. - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]. - /// - /// If the function succeeds, the return value is a search handle used in a subsequent call to FindNextFile or FindClose, and the - /// lpFindFileData parameter contains information about the first file or directory found. If the function fails or fails to locate - /// files from the search string in the lpFileName parameter, the return value is INVALID_HANDLE_VALUE and the contents of - /// lpFindFileData are indeterminate. To get extended error information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstFileExW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstFileEx([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, FindExAdditionalFlags dwAdditionalFlags); - - /// - /// Searches a directory for a file or subdirectory with a name that matches a specific name as a transacted operation. - /// - /// A trailing backslash is not allowed and will be removed. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is a search handle used in a subsequent call to FindNextFile or FindClose, and the - /// lpFindFileData parameter contains information about the first file or directory found. If the function fails or fails to locate - /// files from the search string in the lpFileName parameter, the return value is INVALID_HANDLE_VALUE and the contents of - /// lpFindFileData are indeterminate. To get extended error information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstFileTransactedW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, out WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, FindExAdditionalFlags dwAdditionalFlags, SafeHandle hTransaction); - - /// - /// Creates an enumeration of all the hard links to the specified file. The FindFirstFileNameW function returns a handle to the - /// enumeration that can be used on subsequent calls to the FindNextFileNameW function. - /// - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is a search handle that can be used with the FindNextFileNameW function or closed with - /// the FindClose function. If the function fails, the return value is INVALID_HANDLE_VALUE (0xffffffff). To get extended error - /// information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstFileNameW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstFileName([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint dwFlags, [MarshalAs(UnmanagedType.U4)] out uint stringLength, StringBuilder linkName); - - /// - /// Creates an enumeration of all the hard links to the specified file as a transacted operation. The function returns a handle to the - /// enumeration that can be used on subsequent calls to the FindNextFileNameW function. - /// - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is a search handle that can be used with the FindNextFileNameW function or closed with - /// the FindClose function. If the function fails, the return value is INVALID_HANDLE_VALUE (0xffffffff). To get extended error - /// information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstFileNameTransactedW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstFileNameTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint dwFlags, [MarshalAs(UnmanagedType.U4)] out uint stringLength, StringBuilder linkName, SafeHandle hTransaction); - - /// - /// Continues a file search from a previous call to the FindFirstFile, FindFirstFileEx, or FindFirstFileTransacted functions. - /// - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]. - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]. - /// - /// If the function succeeds, the return value is nonzero and the lpFindFileData parameter contains information about the next file or - /// directory found. If the function fails, the return value is zero and the contents of lpFindFileData are indeterminate. To get - /// extended error information, call the GetLastError function. If the function fails because no more matching files can be found, the - /// GetLastError function returns ERROR_NO_MORE_FILES. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindNextFileW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindNextFile(SafeFindFileHandle hFindFile, out WIN32_FIND_DATA lpFindFileData); - - /// - /// Continues enumerating the hard links to a file using the handle returned by a successful call to the FindFirstFileName function. - /// - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero (0). To get extended error - /// information, call GetLastError. If no matching files can be found, the GetLastError function returns ERROR_HANDLE_EOF. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindNextFileNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindNextFileName(SafeFindFileHandle hFindStream, [MarshalAs(UnmanagedType.U4)] out uint stringLength, StringBuilder linkName); - - /// Flushes the buffers of a specified file and causes all buffered data to be written to a file. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps]. - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FlushFileBuffers(SafeFileHandle hFile); - - /// Retrieves the actual number of bytes of disk storage used to store a specified file. - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is the low-order DWORD of the actual number of bytes of disk storage used to store the - /// specified file, and if lpFileSizeHigh is non-NULL, the function puts the high-order DWORD of that actual value into the DWORD - /// pointed to by that parameter. This is the compressed file size for compressed files, the actual file size for noncompressed files. - /// If the function fails, and lpFileSizeHigh is NULL, the return value is INVALID_FILE_SIZE. To get extended error information, call - /// GetLastError. If the return value is INVALID_FILE_SIZE and lpFileSizeHigh is non-NULL, an application must call GetLastError to - /// determine whether the function has succeeded (value is NO_ERROR) or failed (value is other than NO_ERROR). - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetCompressedFileSizeW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetCompressedFileSize([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] out uint lpFileSizeHigh); - - /// Retrieves the actual number of bytes of disk storage used to store a specified file as a transacted operation. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is the low-order DWORD of the actual number of bytes of disk storage used to store the - /// specified file, and if lpFileSizeHigh is non-NULL, the function puts the high-order DWORD of that actual value into the DWORD - /// pointed to by that parameter. This is the compressed file size for compressed files, the actual file size for noncompressed files. - /// If the function fails, and lpFileSizeHigh is NULL, the return value is INVALID_FILE_SIZE. To get extended error information, call - /// GetLastError. If the return value is INVALID_FILE_SIZE and lpFileSizeHigh is non-NULL, an application must call GetLastError to - /// determine whether the function has succeeded (value is NO_ERROR) or failed (value is other than NO_ERROR). - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetCompressedFileSizeTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetCompressedFileSizeTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] out uint lpFileSizeHigh, SafeHandle hTransaction); - - /// - /// Retrieves attributes for a specified file or directory. - /// - /// - /// The GetFileAttributes function retrieves file system attribute information. - /// GetFileAttributesEx can obtain other sets of file or directory attribute information. - /// Currently, GetFileAttributesEx retrieves a set of standard attributes that is a superset of the file system attribute - /// information. - /// When the GetFileAttributesEx function is called on a directory that is a mounted folder, it returns the attributes of the directory, - /// not those of the root directory in the volume that the mounted folder associates with the directory. To obtain the attributes of - /// the associated volume, call GetVolumeNameForVolumeMountPoint to obtain the name of the associated volume. Then use the resulting - /// name in a call to GetFileAttributesEx. The results are the attributes of the root directory on the associated volume. - /// Symbolic link behavior: If the path points to a symbolic link, the function returns attributes for the symbolic link. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFileAttributesExW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileAttributesEx([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] GetFileExInfoLevels fInfoLevelId, out WIN32_FILE_ATTRIBUTE_DATA lpFileInformation); - - /// Retrieves attributes for a specified file or directory. - /// - /// The GetFileAttributes function retrieves file system attribute information. - /// GetFileAttributesEx can obtain other sets of file or directory attribute information. - /// - /// Currently, GetFileAttributesEx retrieves a set of standard attributes that is a superset of the file system attribute information. - /// When the GetFileAttributesEx function is called on a directory that is a mounted folder, it returns the attributes of the directory, - /// not those of the root directory in the volume that the mounted folder associates with the directory. To obtain the attributes of - /// the associated volume, call GetVolumeNameForVolumeMountPoint to obtain the name of the associated volume. Then use the resulting - /// name in a call to GetFileAttributesEx. The results are the attributes of the root directory on the associated volume. - /// Symbolic link behavior: If the path points to a symbolic link, the function returns attributes for the symbolic link. - /// Transacted Operations - /// If a file is open for modification in a transaction, no other thread can open the file for modification until the transaction - /// is committed. Conversely, if a file is open for modification outside of a transaction, no transacted thread can open the file for - /// modification until the non-transacted handle is closed. If a non-transacted thread has a handle opened to modify a file, a call to - /// GetFileAttributesTransacted for that file will fail with an ERROR_TRANSACTIONAL_CONFLICT error. - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFileAttributesTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileAttributesTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] GetFileExInfoLevels fInfoLevelId, out WIN32_FILE_ATTRIBUTE_DATA lpFileInformation, SafeHandle hTransaction); - - /// Retrieves file information for the specified file. - /// - /// If the function succeeds, the return value is nonzero and file information data is contained in the buffer pointed to by the lpByHandleFileInformation parameter. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// - /// Depending on the underlying network features of the operating system and the type of server connected to, - /// the GetFileInformationByHandle function may fail, return partial information, or full information for the given file. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileInformationByHandle(SafeFileHandle hFile, [MarshalAs(UnmanagedType.Struct)] out BY_HANDLE_FILE_INFORMATION lpByHandleFileInformation); - - /// - /// Retrieves file information for the specified file. - /// - /// - /// Minimum supported client: Windows Vista [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2008 [desktop apps | Windows Store apps] - /// Redistributable: Windows SDK on Windows Server 2003 and Windows XP. - /// - /// The file. - /// The file information by handle class. - /// Information describing the file. - /// Size of the buffer. - /// - /// If the function succeeds, the return value is nonzero and file information data is contained in the buffer pointed to by the - /// lpByHandleFileInformation parameter. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileInformationByHandleEx(SafeFileHandle hFile, [MarshalAs(UnmanagedType.I4)] FileInfoByHandleClass fileInfoByHandleClass, SafeGlobalMemoryBufferHandle lpFileInformation, [MarshalAs(UnmanagedType.U4)] uint dwBufferSize); - - /// Retrieves file information for the specified file. - /// - /// Minimum supported client: Windows Vista [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2008 [desktop apps | Windows Store apps] - /// Redistributable: Windows SDK on Windows Server 2003 and Windows XP. - /// - /// - /// If the function succeeds, the return value is nonzero and file information data is contained in the buffer pointed to by the - /// lpByHandleFileInformation parameter. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// The file. - /// The file information by handle class. - /// Information describing the file. - /// Size of the buffer. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFileInformationByHandleEx"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileInformationByHandleEx_FileBasicInfo(SafeFileHandle hFile, [MarshalAs(UnmanagedType.I4)] FileInfoByHandleClass fileInfoByHandleClass, [MarshalAs(UnmanagedType.Struct)] out FILE_BASIC_INFO lpFileInformation, [MarshalAs(UnmanagedType.U4)] uint dwBufferSize); - - /// - /// Retrieves the size of the specified file. - /// - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetFileSizeEx(SafeFileHandle hFile, out long lpFileSize); - - /// Retrieves the final path for the specified file. - /// Minimum supported client: Windows Vista [desktop apps only]. - /// Minimum supported server: Windows Server 2008 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFinalPathNameByHandleW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetFinalPathNameByHandle(SafeFileHandle hFile, StringBuilder lpszFilePath, [MarshalAs(UnmanagedType.U4)] uint cchFilePath, FinalPathFormats dwFlags); - - /// - /// Checks whether the specified address is within a memory-mapped file in the address space of the specified process. If so, the - /// function returns the name of the memory-mapped file. - /// - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("psapi.dll", SetLastError = false, CharSet = CharSet.Unicode, EntryPoint = "GetMappedFileNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetMappedFileName(IntPtr hProcess, SafeLocalMemoryBufferHandle lpv, StringBuilder lpFilename, [MarshalAs(UnmanagedType.U4)] uint nSize); - - /// Locks the specified file for exclusive access by the calling process. - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is nonzero (TRUE). If the function fails, the return value is zero (FALSE). To get - /// extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool LockFile(SafeFileHandle hFile, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetLow, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetHigh, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToLockLow, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToLockHigh); - - /// Maps a view of a file mapping into the address space of a calling process. - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is the starting address of the mapped view. If the function fails, the return value is - /// . - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern SafeLocalMemoryBufferHandle MapViewOfFile(SafeFileHandle hFileMappingObject, [MarshalAs(UnmanagedType.U4)] uint dwDesiredAccess, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetHigh, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetLow, UIntPtr dwNumberOfBytesToMap); - - /// - /// Moves a file or directory, including its children. - /// You can provide a callback function that receives progress notifications. - /// - /// - /// The MoveFileWithProgress function coordinates its operation with the link tracking service, so link sources can be tracked as they are moved. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Filename of the existing file. - /// Filename of the new file. - /// The progress routine. - /// The data. - /// The flags. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "MoveFileWithProgressW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool MoveFileWithProgress([MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName, NativeCopyMoveProgressRoutine lpProgressRoutine, IntPtr lpData, [MarshalAs(UnmanagedType.U4)] MoveOptions dwFlags); - - /// - /// Moves an existing file or a directory, including its children, as a transacted operation. - /// You can provide a callback function that receives progress notifications. - /// - /// - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "MoveFileTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool MoveFileTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpExistingFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpNewFileName, NativeCopyMoveProgressRoutine lpProgressRoutine, IntPtr lpData, [MarshalAs(UnmanagedType.U4)] MoveOptions dwCopyFlags, SafeHandle hTransaction); - - /// An application-defined callback function used with the CopyFileEx, MoveFileTransacted, and MoveFileWithProgress functions. - /// It is called when a portion of a copy or move operation is completed. - /// The LPPROGRESS_ROUTINE type defines a pointer to this callback function. - /// NativeCopyMoveProgressRoutine (NativeCopyMoveProgressRoutine) is a placeholder for the application-defined function name. - /// - [SuppressUnmanagedCodeSecurity] - internal delegate CopyMoveProgressResult NativeCopyMoveProgressRoutine(long totalFileSize, long totalBytesTransferred, long streamSize, long streamBytesTransferred, [MarshalAs(UnmanagedType.U4)] int dwStreamNumber, CopyMoveProgressCallbackReason dwCallbackReason, IntPtr hSourceFile, IntPtr hDestinationFile, IntPtr lpData); - - /// Replaces one file with another file, with the option of creating a backup copy of the original file. The replacement file assumes the name of the replaced file and its identity. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "ReplaceFileW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool ReplaceFile([MarshalAs(UnmanagedType.LPWStr)] string lpReplacedFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpReplacementFileName, [MarshalAs(UnmanagedType.LPWStr)] string lpBackupFileName, FileSystemRights dwReplaceFlags, IntPtr lpExclude, IntPtr lpReserved); - - /// Sets the attributes for a file or directory. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [SuppressMessage("Microsoft.Usage", "CA2205:UseManagedEquivalentsOfWin32Api")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetFileAttributesW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetFileAttributes([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileAttributes dwFileAttributes); - - /// Sets the attributes for a file or directory as a transacted operation. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetFileAttributesTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetFileAttributesTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] FileAttributes dwFileAttributes, SafeHandle hTransaction); - - /// Sets the date and time that the specified file or directory was created, last accessed, or last modified. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetFileTime(SafeFileHandle hFile, SafeGlobalMemoryBufferHandle lpCreationTime, SafeGlobalMemoryBufferHandle lpLastAccessTime, SafeGlobalMemoryBufferHandle lpLastWriteTime); - - /// Unlocks a region in an open file. Unlocking a region enables other processes to access the region. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool UnlockFile(SafeFileHandle hFile, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetLow, [MarshalAs(UnmanagedType.U4)] uint dwFileOffsetHigh, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToUnlockLow, [MarshalAs(UnmanagedType.U4)] uint nNumberOfBytesToUnlockHigh); - - /// Unmaps a mapped view of a file from the calling process's address space. - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// The base address. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool UnmapViewOfFile(SafeLocalMemoryBufferHandle lpBaseAddress); - - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstStreamTransactedW(string fileName, STREAM_INFO_LEVELS infoLevel, SafeGlobalMemoryBufferHandle lpFindStreamData, int flags, SafeHandle hTransaction); - - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindFileHandle FindFirstStreamW(string fileName, STREAM_INFO_LEVELS infoLevel, SafeGlobalMemoryBufferHandle lpFindStreamData, int flags); - - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindNextStreamW(SafeFindFileHandle handle, SafeGlobalMemoryBufferHandle lpFindStreamData); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs deleted file mode 100644 index 0a78c2d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Handles.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Closes an open object handle. - /// - /// The CloseHandle function closes handles to the following objects: - /// Access token, Communications device, Console input, Console screen buffer, Event, File, File mapping, I/O completion port, - /// Job, Mailslot, Memory resource notification, Mutex, Named pipe, Pipe, Process, Semaphore, Thread, Transaction, Waitable - /// timer. - /// SetLastError is set to . - /// Minimum supported client: Windows 2000 Professional [desktop apps | Windows Store apps] - /// Minimum supported server: Windows 2000 Server [desktop apps | Windows Store apps] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// If the application is running under a debugger, the function will throw an exception if it receives either a handle value - /// that is not valid or a pseudo-handle value.This can happen if you close a handle twice, or if you call CloseHandle on a handle - /// returned by the FindFirstFile function instead of calling the FindClose function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CloseHandle(IntPtr hObject); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs deleted file mode 100644 index ba5fc03..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.KernelTransactions.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// - /// Creates a new transaction object. - /// - /// - /// Use the function to close the transaction handle. If the last transaction handle is closed - /// beforea client calls the CommitTransaction function with the transaction handle, then KTM rolls back the transaction. - /// Minimum supported client: Windows Vista - /// Minimum supported server:Windows Server 2008 - /// - /// - /// If the function succeeds, the return value is a handle to the transaction. - /// If the function fails, the return value is INVALID_HANDLE_VALUE. To get extended error information, call the GetLastError - /// function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern SafeKernelTransactionHandle CreateTransaction([MarshalAs(UnmanagedType.LPStruct)] Security.NativeMethods.SecurityAttributes lpTransactionAttributes, IntPtr uow, [MarshalAs(UnmanagedType.U4)] uint createOptions, [MarshalAs(UnmanagedType.U4)] uint isolationLevel, [MarshalAs(UnmanagedType.U4)] uint isolationFlags, [MarshalAs(UnmanagedType.U4)] int timeout, [MarshalAs(UnmanagedType.LPWStr)] string description); - - /// Requests that the specified transaction be committed. - /// - /// You can commit any transaction handle that has been opened or created using the TRANSACTION_COMMIT permission; any - /// application can commit a transaction, not just the creator. - /// This function can only be called if the transaction is still active, not prepared, pre-prepared, or rolled back. - /// Minimum supported client: Windows Vista - /// Minimum supported server:Windows Server 2008 - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is 0 (zero). To get extended error information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool CommitTransaction(SafeHandle hTrans); - - /// - /// Requests that the specified transaction be rolled back. This function is synchronous. - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call the GetLastError function. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("ktmw32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RollbackTransaction(SafeHandle hTrans); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs deleted file mode 100644 index 514b182..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.PathManagement.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Retrieves the full path and file name of the specified file or directory. - /// If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError. - /// The GetFullPathName function is not recommended for multithreaded applications or shared library code. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFullPathNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetFullPathName([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint nBufferLength, StringBuilder lpBuffer, IntPtr lpFilePart); - - /// Retrieves the full path and file name of the specified file or directory as a transacted operation. - /// If the function fails for any other reason, the return value is zero. To get extended error information, call GetLastError. - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetFullPathNameTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetFullPathNameTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpFileName, [MarshalAs(UnmanagedType.U4)] uint nBufferLength, StringBuilder lpBuffer, IntPtr lpFilePart, SafeHandle hTransaction); - - /// Converts the specified path to its long form. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetLongPathNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetLongPathName([MarshalAs(UnmanagedType.LPWStr)] string lpszShortPath, StringBuilder lpszLongPath, [MarshalAs(UnmanagedType.U4)] uint cchBuffer); - - /// Converts the specified path to its long form as a transacted operation. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetLongPathNameTransactedW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetLongPathNameTransacted([MarshalAs(UnmanagedType.LPWStr)] string lpszShortPath, StringBuilder lpszLongPath, [MarshalAs(UnmanagedType.U4)] uint cchBuffer, SafeHandle hTransaction); - - /// Retrieves the short path form of the specified path. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetShortPathNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetShortPathName([MarshalAs(UnmanagedType.LPWStr)] string lpszLongPath, StringBuilder lpszShortPath, [MarshalAs(UnmanagedType.U4)] uint cchBuffer); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs deleted file mode 100644 index 04908bf..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Shell32.cs +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - #region AssocXxx - - /// Returns a pointer to an IQueryAssociations object. - /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint AssocCreate(Guid clsid, ref Guid riid, [MarshalAs(UnmanagedType.Interface)] out IQueryAssociations ppv); - - /// Searches for and retrieves a file or protocol association-related string from the registry. - /// Return value Type: HRESULT. Returns a standard COM error value, including the following: S_OK, E_POINTER and S_FALSE. - /// Minimum supported client: Windows 2000 Professional - /// Minimum supported server: Windows 2000 Server - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "AssocQueryStringW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint AssocQueryString(Shell32.AssociationAttributes flags, Shell32.AssociationString str, [MarshalAs(UnmanagedType.LPWStr)] string pszAssoc, [MarshalAs(UnmanagedType.LPWStr)] string pszExtra, StringBuilder pszOut, [MarshalAs(UnmanagedType.U4)] out uint pcchOut); - - - #region IQueryAssociations - - internal static readonly Guid ClsidQueryAssociations = new Guid("A07034FD-6CAA-4954-AC3F-97A27216F98A"); - internal const string QueryAssociationsGuid = "C46CA590-3C3F-11D2-BEE6-0000F805CA57"; - - /// Exposes methods that simplify the process of retrieving information stored in the registry in association with defining a file type or protocol and associating it with an application. - [Guid(QueryAssociationsGuid), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [SuppressUnmanagedCodeSecurity] - internal interface IQueryAssociations - { - /// Initializes the IQueryAssociations interface and sets the root key to the appropriate ProgID. - /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - void Init(Shell32.AssociationAttributes flags, [MarshalAs(UnmanagedType.LPWStr)] string pszAssoc, IntPtr hkProgid, IntPtr hwnd); - - //[return: MarshalAs(UnmanagedType.U4)] - //uint Init(Shell32.AssociationAttributes flags, [MarshalAs(UnmanagedType.LPWStr)] string pszAssoc, IntPtr hkProgid, IntPtr hwnd); - - /// Searches for and retrieves a file or protocol association-related string from the registry. - /// A standard COM error value, including the following: S_OK, E_POINTER, S_FALSE - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - void GetString(Shell32.AssociationAttributes flags, Shell32.AssociationString str, [MarshalAs(UnmanagedType.LPWStr)] string pwszExtra, StringBuilder pwszOut, [MarshalAs(UnmanagedType.I4)] out int pcchOut); - - //[return: MarshalAs(UnmanagedType.U4)] - //void GetString(Shell32.AssociationAttributes flags, Shell32.AssociationString str, [MarshalAs(UnmanagedType.LPWStr)] string pwszExtra, StringBuilder pwszOut, [MarshalAs(UnmanagedType.I4)] out int pcchOut); - - ///// Searches for and retrieves a file or protocol association-related key from the registry. - ///// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - ///// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - ///// Minimum supported server: Windows 2000 Server [desktop apps only] - //[return: MarshalAs(UnmanagedType.U4)] - //uint GetKey(Shell32.AssociationAttributes flags, Shell32.AssociationKey str, [MarshalAs(UnmanagedType.LPWStr)] string pwszExtra, out UIntPtr phkeyOut); - - ///// Searches for and retrieves file or protocol association-related binary data from the registry. - ///// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - ///// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - ///// Minimum supported server: Windows 2000 Server [desktop apps only] - //[return: MarshalAs(UnmanagedType.U4)] - //uint GetData(Shell32.AssociationAttributes flags, Shell32.AssociationData data, [MarshalAs(UnmanagedType.LPWStr)] string pwszExtra, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 4)] out byte[] pvOut, [MarshalAs(UnmanagedType.I4)] out int pcbOut); - - ///// This method is not implemented. - //void GetEnum(); - } - - #endregion // IQueryAssociations - - #endregion // AssocXxx - - - #region Path - - /// Determines whether a path to a file system object such as a file or folder is valid. - /// if the file exists; otherwise, . Call GetLastError for extended error information. - /// - /// This function tests the validity of the path. - /// A path specified by Universal Naming Convention (UNC) is limited to a file only; that is, \\server\share\file is permitted. - /// A network share path to a server or server share is not permitted; that is, \\server or \\server\share. - /// This function returns FALSE if a mounted remote drive is out of service. - /// - /// Minimum supported client: Windows 2000 Professional - /// Minimum supported server: Windows 2000 Server - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("Shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PathFileExistsW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool PathFileExists([MarshalAs(UnmanagedType.LPWStr)] string pszPath); - - - /// Converts a file URL to a Microsoft MS-DOS path. - /// Type: HRESULT - /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - /// - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "PathCreateFromUrlW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint PathCreateFromUrl([MarshalAs(UnmanagedType.LPWStr)] string pszUrl, StringBuilder pszPath, [MarshalAs(UnmanagedType.U4)] ref uint pcchPath, [MarshalAs(UnmanagedType.U4)] uint dwFlags); - - - /// Creates a path from a file URL. - /// Type: HRESULT - /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - /// - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint PathCreateFromUrlAlloc([MarshalAs(UnmanagedType.LPWStr)] string pszIn, out StringBuilder pszPath, [MarshalAs(UnmanagedType.U4)] uint dwFlags); - - - /// Converts a Microsoft MS-DOS path to a canonicalized URL. - /// Type: HRESULT - /// Returns S_FALSE if pszPath is already in URL format. In this case, pszPath will simply be copied to pszUrl. - /// Otherwise, it returns S_OK if successful or a standard COM error value if not. - /// - /// - /// UrlCreateFromPath does not support extended paths. These are paths that include the extended-length path prefix "\\?\". - /// - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "UrlCreateFromPathW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint UrlCreateFromPath([MarshalAs(UnmanagedType.LPWStr)] string pszPath, StringBuilder pszUrl, ref uint pcchUrl, [MarshalAs(UnmanagedType.U4)] uint dwFlags); - - - /// Tests whether a URL is a specified type. - /// - /// Type: BOOL - /// For all but one of the URL types, UrlIs returns if the URL is the specified type, otherwise. - /// If UrlIs is set to , UrlIs will attempt to determine the URL scheme. - /// If the function is able to determine a scheme, it returns , or . - /// - /// Minimum supported client: Windows 2000 Professional, Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shlwapi.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "UrlIsW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool UrlIs([MarshalAs(UnmanagedType.LPWStr)] string pszUrl, Shell32.UrlType urlIs); - - #endregion // Path - - - /// Destroys an icon and frees any memory the icon occupied. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("user32.dll", SetLastError = false)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DestroyIcon(IntPtr hIcon); - - - /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. - /// You should call this function from a background thread. Failure to do so could cause the UI to stop responding. - /// Minimum supported client: Windows 2000 Professional [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("shell32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SHGetFileInfoW"), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr ShGetFileInfo([MarshalAs(UnmanagedType.LPWStr)] string pszPath, FileAttributes dwFileAttributes, [MarshalAs(UnmanagedType.Struct)] out Shell32.FileInfo psfi, [MarshalAs(UnmanagedType.U4)] uint cbFileInfo, [MarshalAs(UnmanagedType.U4)] Shell32.FileAttributes uFlags); - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs deleted file mode 100644 index 3cd33aa..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.Utilities.cs +++ /dev/null @@ -1,136 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Security; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - internal static uint GetHighOrderDword(long highPart) - { - return (uint)((highPart >> 32) & 0xFFFFFFFF); - } - - internal static uint GetLowOrderDword(long lowPart) - { - return (uint)(lowPart & 0xFFFFFFFF); - } - - /// Check is the current handle is not null, not closed and not invalid. - /// The current handle to check. - /// will throw an , will not raise this exception.. - /// on success, otherwise. - /// - internal static bool IsValidHandle(SafeHandle handle, bool throwException = true) - { - if (handle == null || handle.IsClosed || handle.IsInvalid) - { - if (handle != null) - handle.Close(); - - if (throwException) - throw new ArgumentException(Resources.Handle_Is_Invalid); - - return false; - } - - return true; - } - - /// Check is the current handle is not null, not closed and not invalid. - /// The current handle to check. - /// The result of Marshal.GetLastWin32Error() - /// will throw an , will not raise this exception.. - /// on success, otherwise. - /// - internal static bool IsValidHandle(SafeHandle handle, int lastError, bool throwException = true) - { - if (handle == null || handle.IsClosed || handle.IsInvalid) - { - if (handle != null) - handle.Close(); - - if (throwException) - throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.Handle_Is_Invalid_Win32Error, lastError)); - - return false; - } - - return true; - } - - internal static long LuidToLong(Luid luid) - { - ulong high = (((ulong)luid.HighPart) << 32); - ulong low = (((ulong)luid.LowPart) & 0x00000000FFFFFFFF); - return unchecked((long)(high | low)); - } - - internal static Luid LongToLuid(long lluid) - { - return new Luid { HighPart = (uint)(lluid >> 32), LowPart = (uint)(lluid & 0xFFFFFFFF) }; - } - - /// - /// Controls whether the system will handle the specified types of serious errors or whether the process will handle them. - /// - /// - /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error- - /// mode attributes. Doing so can lead to inconsistent error handling. - /// - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// The mode. - /// The return value is the previous state of the error-mode bit attributes. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - private static extern ErrorMode SetErrorMode(ErrorMode uMode); - - /// - /// Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them. - /// - /// - /// Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error- - /// mode attributes. Doing so can lead to inconsistent error handling. - /// - /// Minimum supported client: Windows 7 [desktop apps only]. - /// Minimum supported server: Windows Server 2008 R2 [desktop apps only]. - /// The new mode. - /// [out] The old mode. - /// The return value is the previous state of the error-mode bit attributes. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - private static extern bool SetThreadErrorMode(ErrorMode dwNewMode, [MarshalAs(UnmanagedType.U4)] out ErrorMode lpOldMode); - - internal static long ToLong(uint highPart, uint lowPart) - { - return (((long)highPart) << 32) | (((long)lowPart) & 0xFFFFFFFF); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs b/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs deleted file mode 100644 index 71c170d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Methods/NativeMethods.VolumeManagement.cs +++ /dev/null @@ -1,285 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Defines, redefines, or deletes MS-DOS device names. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DefineDosDeviceW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DefineDosDevice(DosDeviceAttributes dwFlags, [MarshalAs(UnmanagedType.LPWStr)] string lpDeviceName, [MarshalAs(UnmanagedType.LPWStr)] string lpTargetPath); - - /// Deletes a drive letter or mounted folder. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "DeleteVolumeMountPointW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool DeleteVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint); - - /// Retrieves the name of a volume on a computer. FindFirstVolume is used to begin scanning the volumes of a computer. - /// - /// If the function succeeds, the return value is a search handle used in a subsequent call to the FindNextVolume and FindVolumeClose functions. - /// If the function fails to find any volumes, the return value is the INVALID_HANDLE_VALUE error code. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstVolumeW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindVolumeHandle FindFirstVolume(StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Retrieves the name of a mounted folder on the specified volume. FindFirstVolumeMountPoint is used to begin scanning the mounted folders on a volume. - /// - /// If the function succeeds, the return value is a search handle used in a subsequent call to the FindNextVolumeMountPoint and FindVolumeMountPointClose functions. - /// If the function fails to find a mounted folder on the volume, the return value is the INVALID_HANDLE_VALUE error code. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindFirstVolumeMountPointW"), SuppressUnmanagedCodeSecurity] - internal static extern SafeFindVolumeMountPointHandle FindFirstVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszRootPathName, StringBuilder lpszVolumeMountPoint, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Continues a volume search started by a call to the FindFirstVolume function. FindNextVolume finds one volume per call. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindNextVolumeW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindNextVolume(SafeFindVolumeHandle hFindVolume, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Continues a mounted folder search started by a call to the FindFirstVolumeMountPoint function. FindNextVolumeMountPoint finds one mounted folder per call. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. If no more mounted folders can be found, the GetLastError function returns the ERROR_NO_MORE_FILES error code. - /// In that case, close the search with the FindVolumeMountPointClose function. - /// - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "FindNextVolumeMountPointW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindNextVolumeMountPoint(SafeFindVolumeMountPointHandle hFindVolume, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Closes the specified volume search handle. - /// - /// SetLastError is set to . - /// Minimum supported client: Windows XP [desktop apps only]. Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindVolumeClose(IntPtr hFindVolume); - - /// Closes the specified mounted folder search handle. - /// - /// SetLastError is set to . - /// Minimum supported client: Windows XP - /// Minimum supported server: Windows Server 2003 - /// - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool FindVolumeMountPointClose(IntPtr hFindVolume); - - /// - /// Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. - /// To determine whether a drive is a USB-type drive, call and specify the - /// SPDRP_REMOVAL_POLICY property. - /// - /// - /// SMB does not support volume management functions. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// Full pathname of the root file. - /// - /// The return value specifies the type of drive, see . - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetDriveTypeW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern DriveType GetDriveType([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName); - - /// - /// Retrieves a bitmask representing the currently available disk drives. - /// - /// - /// SMB does not support volume management functions. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is a bitmask representing the currently available disk drives. - /// Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetLogicalDrives(); - - /// Retrieves information about the file system and volume associated with the specified root directory. - /// - /// If all the requested information is retrieved, the return value is nonzero. - /// If not all the requested information is retrieved, the return value is zero. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// "lpRootPathName" must end with a trailing backslash. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumeInformationW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetVolumeInformation([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, StringBuilder lpVolumeNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nVolumeNameSize, [MarshalAs(UnmanagedType.U4)] out uint lpVolumeSerialNumber, [MarshalAs(UnmanagedType.U4)] out int lpMaximumComponentLength, [MarshalAs(UnmanagedType.U4)] out VolumeInfoAttributes lpFileSystemAttributes, StringBuilder lpFileSystemNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nFileSystemNameSize); - - /// Retrieves information about the file system and volume associated with the specified file. - /// - /// If all the requested information is retrieved, the return value is nonzero. - /// If not all the requested information is retrieved, the return value is zero. To get extended error information, call GetLastError. - /// - /// To retrieve the current compression state of a file or directory, use FSCTL_GET_COMPRESSION. - /// SMB does not support volume management functions. - /// Minimum supported client: Windows Vista [desktop apps only] - /// Minimum supported server: Windows Server 2008 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumeInformationByHandleW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetVolumeInformationByHandle(SafeFileHandle hFile, StringBuilder lpVolumeNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nVolumeNameSize, [MarshalAs(UnmanagedType.U4)] out uint lpVolumeSerialNumber, [MarshalAs(UnmanagedType.U4)] out int lpMaximumComponentLength, out VolumeInfoAttributes lpFileSystemAttributes, StringBuilder lpFileSystemNameBuffer, [MarshalAs(UnmanagedType.U4)] uint nFileSystemNameSize); - - /// Retrieves a volume GUID path for the volume that is associated with the specified volume mount point (drive letter, volume GUID path, or mounted folder). - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Use GetVolumeNameForVolumeMountPoint to obtain a volume GUID path for use with functions such as SetVolumeMountPoint and FindFirstVolumeMountPoint that require a volume GUID path as an input parameter. - /// SMB does not support volume management functions. - /// Mount points aren't supported by ReFS volumes. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumeNameForVolumeMountPointW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetVolumeNameForVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint, StringBuilder lpszVolumeName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Retrieves the volume mount point where the specified path is mounted. - /// - /// If a specified path is passed, GetVolumePathName returns the path to the volume mount point, which means that it returns the - /// root of the volume where the end point of the specified path is located. - /// For example, assume that you have volume D mounted at C:\Mnt\Ddrive and volume E mounted at "C:\Mnt\Ddrive\Mnt\Edrive". Also - /// assume that you have a file with the path "E:\Dir\Subdir\MyFile". - /// If you pass "C:\Mnt\Ddrive\Mnt\Edrive\Dir\Subdir\MyFile" to GetVolumePathName, it returns the path "C:\Mnt\Ddrive\Mnt\Edrive\". - /// If a network share is specified, GetVolumePathName returns the shortest path for which GetDriveType returns DRIVE_REMOTE, - /// which means that the path is validated as a remote drive that exists, which the current user can access. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumePathNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetVolumePathName([MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, StringBuilder lpszVolumePathName, [MarshalAs(UnmanagedType.U4)] uint cchBufferLength); - - /// Retrieves a list of drive letters and mounted folder paths for the specified volume. - /// Minimum supported client: Windows XP. - /// Minimum supported server: Windows Server 2003. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetVolumePathNamesForVolumeNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetVolumePathNamesForVolumeName([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeName, char[] lpszVolumePathNames, [MarshalAs(UnmanagedType.U4)] uint cchBuferLength, [MarshalAs(UnmanagedType.U4)] out uint lpcchReturnLength); - - /// Sets the label of a file system volume. - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// "lpRootPathName" must end with a trailing backslash. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetVolumeLabelW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetVolumeLabel([MarshalAs(UnmanagedType.LPWStr)] string lpRootPathName, [MarshalAs(UnmanagedType.LPWStr)] string lpVolumeName); - - /// Associates a volume with a drive letter or a directory on another volume. - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is nonzero. If the function fails, the return value is zero. To get extended error - /// information, call GetLastError. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetVolumeMountPointW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool SetVolumeMountPoint([MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeMountPoint, [MarshalAs(UnmanagedType.LPWStr)] string lpszVolumeName); - - /// Retrieves information about MS-DOS device names. - /// Minimum supported client: Windows XP [desktop apps only]. - /// Minimum supported server: Windows Server 2003 [desktop apps only]. - /// - /// If the function succeeds, the return value is the number of TCHARs stored into the buffer pointed to by lpTargetPath. If the - /// function fails, the return value is zero. To get extended error information, call GetLastError. If the buffer is too small, the - /// function fails and the last error code is ERROR_INSUFFICIENT_BUFFER. - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "QueryDosDeviceW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint QueryDosDevice([MarshalAs(UnmanagedType.LPWStr)] string lpDeviceName, char[] lpTargetPath, [MarshalAs(UnmanagedType.U4)] uint ucchMax); - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/BY_HANDLE_FILE_INFORMATION.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/BY_HANDLE_FILE_INFORMATION.cs deleted file mode 100644 index 27493de..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/BY_HANDLE_FILE_INFORMATION.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Contains information that the GetFileInformationByHandle function retrieves. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct BY_HANDLE_FILE_INFORMATION - { - /// The file attributes. - public readonly FileAttributes dwFileAttributes; - - /// A structure that specifies when a file or directory is created. - public readonly FILETIME ftCreationTime; - - /// A structure. For a file, the structure specifies the last time that a file is read from or written to. - /// For a directory, the structure specifies when the directory is created. - /// For both files and directories, the specified date is correct, but the time of day is always set to midnight. - /// - public readonly FILETIME ftLastAccessTime; - - /// A structure. For a file, the structure specifies the last time that a file is written to. - /// For a directory, the structure specifies when the directory is created. - public readonly FILETIME ftLastWriteTime; - - /// The serial number of the volume that contains a file. - [MarshalAs(UnmanagedType.U4)] - public readonly int dwVolumeSerialNumber; - - /// The high-order part of the file size. - [MarshalAs(UnmanagedType.U4)] - public readonly uint nFileSizeHigh; - - /// The low-order part of the file size. - [MarshalAs(UnmanagedType.U4)] - public readonly uint nFileSizeLow; - - /// The number of links to this file. For the FAT file system this member is always 1. For the NTFS file system, it can be more than 1. - [MarshalAs(UnmanagedType.U4)] - public readonly int nNumberOfLinks; - - /// The high-order part of a unique identifier that is associated with a file. - [MarshalAs(UnmanagedType.U4)] - public readonly uint nFileIndexHigh; - - /// The low-order part of a unique identifier that is associated with a file. - [MarshalAs(UnmanagedType.U4)] - public readonly uint nFileIndexLow; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILETIME.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILETIME.cs deleted file mode 100644 index 1d0dafa..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILETIME.cs +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Represents the number of 100-nanosecond intervals since January 1, 1601. This structure is a 64-bit value. - [SerializableAttribute] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct FILETIME - { - #region Fields - - private readonly uint dwLowDateTime; - private readonly uint dwHighDateTime; - - #endregion // Fields - - #region Methods - - /// Converts a value to long. - public static implicit operator long(FILETIME ft) - { - return ft.ToLong(); - } - - /// Converts a value to long. - [SuppressMessage("Microsoft.Naming", "CA1720:IdentifiersShouldNotContainTypeNames", MessageId = "long")] - public long ToLong() - { - return NativeMethods.ToLong(dwHighDateTime, dwLowDateTime); - } - - #endregion - - #region Equality - - #region Equals - - /// Determines whether the specified Object is equal to the current Object. - /// Another object to compare to. - /// if the specified Object is equal to the current Object; otherwise, . - public override bool Equals(object obj) - { - if (obj == null || GetType() != obj.GetType()) - return false; - - FILETIME other = obj as FILETIME? ?? new FILETIME(); - - return (other.dwHighDateTime.Equals(dwHighDateTime) && - other.dwLowDateTime.Equals(dwLowDateTime)); - } - - #endregion // Equals - - #region GetHashCode - - /// Serves as a hash function for a particular type. - /// A hash code for the current Object. - public override int GetHashCode() - { - unchecked - { - int hash = 17; - hash = hash * 23 + dwHighDateTime.GetHashCode(); - hash = hash * 11 + dwLowDateTime.GetHashCode(); - return hash; - } - } - - #endregion // GetHashCode - - #region == - - /// Implements the operator == - /// A. - /// B. - /// The result of the operator. - public static bool operator ==(FILETIME left, FILETIME right) - { - return left.Equals(right); - } - - #endregion // == - - #region != - /// Implements the operator != - /// A. - /// B. - /// The result of the operator. - public static bool operator !=(FILETIME left, FILETIME right) - { - return !(left == right); - } - - #endregion // != - - #endregion // Equality - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_BASIC_INFO.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_BASIC_INFO.cs deleted file mode 100644 index f3cd7f4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_BASIC_INFO.cs +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Contains the basic information for a file. Used for file handles. - /// - /// Specifying -1 for , , or - /// indicates that operations on the current handle should not affect the given field. - /// (I.e, specifying -1 for will leave the unaffected by writes performed - /// on the current handle.) - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct FILE_BASIC_INFO - { - /// The time the file was created in format, - /// which is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC). - /// - public FILETIME CreationTime; - - /// The time the file was last accessed in format. - public FILETIME LastAccessTime; - - /// The time the file was last written to in format. - public FILETIME LastWriteTime; - - /// The time the file was changed in format. - public FILETIME ChangeTime; - - /// The file attributes. - /// If this is set to 0 in a structure passed to SetFileInformationByHandle then none of the attributes are changed. - public FileAttributes FileAttributes; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_ID_BOTH_DIR_INFO.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_ID_BOTH_DIR_INFO.cs deleted file mode 100644 index 3c91a40..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/FILE_ID_BOTH_DIR_INFO.cs +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Contains information about files in the specified directory. Used for directory handles. Use only when calling GetFileInformationByHandleEx. - /// - /// The number of files that are returned for each call to GetFileInformationByHandleEx depends on the size of the buffer that is passed to the function. - /// Any subsequent calls to GetFileInformationByHandleEx on the same handle will resume the enumeration operation after the last file is returned. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct FILE_ID_BOTH_DIR_INFO - { - /// The offset for the next FILE_ID_BOTH_DIR_INFO structure that is returned. Contains zero (0) if no other entries follow this one. - [MarshalAs(UnmanagedType.U4)] - public readonly int NextEntryOffset; - - /// The byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS, - /// in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order. - /// - [MarshalAs(UnmanagedType.U4)] - public readonly uint FileIndex; - - /// The time that the file was created. - public FILETIME CreationTime; - - /// The time that the file was last accessed. - public FILETIME LastAccessTime; - - /// The time that the file was last written to. - public FILETIME LastWriteTime; - - /// The time that the file was last changed. - public FILETIME ChangeTime; - - /// The absolute new end-of-file position as a byte offset from the start of the file to the end of the file. - /// Because this value is zero-based, it actually refers to the first free byte in the file. - /// In other words, EndOfFile is the offset to the byte that immediately follows the last valid byte in the file. - /// - public readonly long EndOfFile; - - /// The number of bytes that are allocated for the file. This value is usually a multiple of the sector or cluster size of the underlying physical device. - public readonly long AllocationSize; - - /// The file attributes. - public readonly FileAttributes FileAttributes; - - /// The length of the file name. - [MarshalAs(UnmanagedType.U4)] - public readonly uint FileNameLength; - - /// The size of the extended attributes for the file. - [MarshalAs(UnmanagedType.U4)] - public readonly int EaSize; - - /// The length of ShortName. - [MarshalAs(UnmanagedType.U1)] - public readonly byte ShortNameLength; - - /// The short 8.3 file naming convention (for example, "FILENAME.TXT") name of the file. - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12, ArraySubType = UnmanagedType.U2)] - public readonly char[] ShortName; - - /// The file ID. - public readonly long FileId; - - /// The first character of the file name string. This is followed in memory by the remainder of the string. - public IntPtr FileName; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/MountPointReparseBuffer.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/MountPointReparseBuffer.cs deleted file mode 100644 index ba03cac..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/MountPointReparseBuffer.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct MountPointReparseBuffer - { - public readonly ushort SubstituteNameOffset; - public readonly ushort SubstituteNameLength; - public readonly ushort PrintNameOffset; - public readonly ushort PrintNameLength; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public readonly byte[] data; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/ReparseDataBufferHeader.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/ReparseDataBufferHeader.cs deleted file mode 100644 index 5c8db1d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/ReparseDataBufferHeader.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct ReparseDataBufferHeader - { - [MarshalAs(UnmanagedType.U4)] public readonly ReparsePointTag ReparseTag; - public readonly ushort ReparseDataLength; - public readonly ushort Reserved; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public readonly byte[] data; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DATA.cs deleted file mode 100644 index a03a77d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DATA.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// An SP_DEVICE_INTERFACE_DATA structure defines a device interface in a device information set. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SP_DEVICE_INTERFACE_DATA - { - /// The size, in bytes, of the SP_DEVICE_INTERFACE_DATA structure. - [MarshalAs(UnmanagedType.U4)] public uint cbSize; - - /// The GUID for the class to which the device interface belongs. - public readonly Guid InterfaceClassGuid; - - /// Can be one or more of the following: SPINT_ACTIVE (1), SPINT_DEFAULT (2), SPINT_REMOVED (3). - [MarshalAs(UnmanagedType.U4)] public readonly uint Flags; - - /// Reserved. Do not use. - private readonly IntPtr Reserved; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DETAIL_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DETAIL_DATA.cs deleted file mode 100644 index 0579e77..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVICE_INTERFACE_DETAIL_DATA.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// An SP_DEVICE_INTERFACE_DETAIL_DATA structure contains the path for a device interface. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SP_DEVICE_INTERFACE_DETAIL_DATA - { - /// The size, in bytes, of the SP_DEVICE_INTERFACE_DETAIL_DATA structure. - [MarshalAs(UnmanagedType.U4)] public uint cbSize; - - /// The device interface path. This path can be passed to Win32 functions such as CreateFile. - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] public readonly string DevicePath; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVINFO_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVINFO_DATA.cs deleted file mode 100644 index 927bbf0..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SP_DEVINFO_DATA.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// An SP_DEVINFO_DATA structure defines a device instance that is a member of a device information set. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SP_DEVINFO_DATA - { - /// The size, in bytes, of the SP_DEVINFO_DATA structure. - [MarshalAs(UnmanagedType.U4)] public uint cbSize; - - /// The GUID of the device's setup class. - public readonly Guid ClassGuid; - - /// An opaque handle to the device instance (also known as a handle to the devnode). - [MarshalAs(UnmanagedType.U4)] public readonly uint DevInst; - - /// Reserved. For internal use only. - private readonly IntPtr Reserved; - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SymbolicLinkReparseBuffer.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/SymbolicLinkReparseBuffer.cs deleted file mode 100644 index 90d31a4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/SymbolicLinkReparseBuffer.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SymbolicLinkReparseBuffer - { - public readonly ushort SubstituteNameOffset; - public readonly ushort SubstituteNameLength; - public readonly ushort PrintNameOffset; - public readonly ushort PrintNameLength; - public readonly SymbolicLinkType Flags; - [MarshalAs(UnmanagedType.ByValArray, SizeConst = 1)] public readonly byte[] data; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FILE_ATTRIBUTE_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FILE_ATTRIBUTE_DATA.cs deleted file mode 100644 index dfabfc4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FILE_ATTRIBUTE_DATA.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// WIN32_FILE_ATTRIBUTE_DATA structure contains attribute information for a file or directory. The GetFileAttributesEx function uses this structure. - /// - /// Not all file systems can record creation and last access time, and not all file systems record them in the same manner. - /// For example, on the FAT file system, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, - /// and access time has a resolution of 1 day. On the NTFS file system, access time has a resolution of 1 hour. - /// For more information, see File Times. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct WIN32_FILE_ATTRIBUTE_DATA - { - public WIN32_FILE_ATTRIBUTE_DATA(WIN32_FIND_DATA findData) - { - dwFileAttributes = findData.dwFileAttributes; - ftCreationTime = findData.ftCreationTime; - ftLastAccessTime = findData.ftLastAccessTime; - ftLastWriteTime = findData.ftLastWriteTime; - nFileSizeHigh = findData.nFileSizeHigh; - nFileSizeLow = findData.nFileSizeLow; - } - - /// The file attributes of a file. - [MarshalAs(UnmanagedType.I4)] public FileAttributes dwFileAttributes; - - /// A structure that specifies when a file or directory was created. - /// If the underlying file system does not support creation time, this member is zero. - public readonly FILETIME ftCreationTime; - - /// A structure. - /// For a file, the structure specifies when the file was last read from, written to, or for executable files, run. - /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last access time, this member is zero. - /// On the FAT file system, the specified date for both files and directories is correct, but the time of day is always set to midnight. - /// - public readonly FILETIME ftLastAccessTime; - - /// A structure. - /// For a file, the structure specifies when the file was last written to, truncated, or overwritten, for example, when WriteFile or SetEndOfFile are used. - /// The date and time are not updated when file attributes or security descriptors are changed. - /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last write time, this member is zero. - /// - public readonly FILETIME ftLastWriteTime; - - /// The high-order DWORD of the file size. This member does not have a meaning for directories. - /// This value is zero unless the file size is greater than MAXDWORD. - /// The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow. - /// - public readonly uint nFileSizeHigh; - - /// The low-order DWORD of the file size. This member does not have a meaning for directories. - public readonly uint nFileSizeLow; - - /// The file size. - public long FileSize - { - get { return ToLong(nFileSizeHigh, nFileSizeLow); } - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_DATA.cs deleted file mode 100644 index b7612fe..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_DATA.cs +++ /dev/null @@ -1,93 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Contains information about the file that is found by the FindFirstFile, FindFirstFileEx, or FindNextFile function. - /// - /// If a file has a long file name, the complete name appears in the cFileName member, and the 8.3 format truncated version of the name appears - /// in the cAlternateFileName member. Otherwise, cAlternateFileName is empty. If the FindFirstFileEx function was called with a value of FindExInfoBasic - /// in the fInfoLevelId parameter, the cAlternateFileName member will always contain a string value. This remains true for all subsequent calls to the - /// FindNextFile function. As an alternative method of retrieving the 8.3 format version of a file name, you can use the GetShortPathName function. - /// For more information about file names, see File Names, Paths, and Namespaces. - /// - /// - /// Not all file systems can record creation and last access times, and not all file systems record them in the same manner. - /// For example, on the FAT file system, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, - /// and access time has a resolution of 1 day. The NTFS file system delays updates to the last access time for a file by up to 1 hour - /// after the last access. For more information, see File Times. - /// - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - [SerializableAttribute] - internal struct WIN32_FIND_DATA - { - /// The file attributes of a file. - public FileAttributes dwFileAttributes; - - /// A structure that specifies when a file or directory was created. - /// If the underlying file system does not support creation time, this member is zero. - public FILETIME ftCreationTime; - - /// A structure. - /// For a file, the structure specifies when the file was last read from, written to, or for executable files, run. - /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last access time, this member is zero. - /// On the FAT file system, the specified date for both files and directories is correct, but the time of day is always set to midnight. - /// - public FILETIME ftLastAccessTime; - - /// A structure. - /// For a file, the structure specifies when the file was last written to, truncated, or overwritten, for example, when WriteFile or SetEndOfFile are used. - /// The date and time are not updated when file attributes or security descriptors are changed. - /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last write time, this member is zero. - /// - public FILETIME ftLastWriteTime; - - /// The high-order DWORD of the file size. This member does not have a meaning for directories. - /// This value is zero unless the file size is greater than MAXDWORD. - /// The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow. - /// - public uint nFileSizeHigh; - - /// The low-order DWORD of the file size. This member does not have a meaning for directories. - public uint nFileSizeLow; - - /// If the dwFileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute, this member specifies the reparse point tag. - /// Otherwise, this value is undefined and should not be used. - /// - public readonly ReparsePointTag dwReserved0; - - /// Reserved for future use. - private readonly uint dwReserved1; - - /// The name of the file. - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath)] public string cFileName; - - /// An alternative name for the file. This name is in the classic 8.3 file name format. - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 14)] public string cAlternateFileName; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_STREAM_DATA.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_STREAM_DATA.cs deleted file mode 100644 index 4e8c42b..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_FIND_STREAM_DATA.cs +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct WIN32_FIND_STREAM_DATA - { - public long StreamSize; - - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = MaxPath + 36)] - public string cStreamName; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_STREAM_ID.cs b/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_STREAM_ID.cs deleted file mode 100644 index cc9b49c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Native Structures/WIN32_STREAM_ID.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Contains stream data. - [StructLayout(LayoutKind.Sequential, Pack = 1, CharSet = CharSet.Unicode)] - [SerializableAttribute] - internal struct WIN32_STREAM_ID - { - /// Type of stream data. - [MarshalAs(UnmanagedType.U4)] - public readonly BackupStreamType dwStreamId; - - /// Attributes of data to facilitate cross-operating system transfer. - [MarshalAs(UnmanagedType.U4)] - public readonly StreamAttributes dwStreamAttributes; - - /// Size of data, in bytes. - [MarshalAs(UnmanagedType.U8)] - public readonly ulong Size; - - /// Length of the name of the alternative data stream, in bytes. - [MarshalAs(UnmanagedType.U4)] - public readonly uint dwStreamNameSize; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Combine.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Combine.cs deleted file mode 100644 index 5669b35..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Combine.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - /// Combines an array of strings into a path. - /// The combined paths. - /// - /// - /// An array of parts of the path. - [SecurityCritical] - public static string Combine(params string[] paths) - { - return CombineCore(true, paths); - } - - /// Combines an array of strings into a path. - /// The combined paths. - /// - /// The parameters are not parsed if they have white space. - /// Therefore, if path2 includes white space (for example, " c:\\ "), - /// the Combine method appends path2 to path1 instead of returning only path2. - /// - /// - /// - /// will not check for invalid path characters. - /// An array of parts of the path. - [SecurityCritical] - internal static string CombineCore(bool checkInvalidPathChars, params string[] paths) - { - if (paths == null) - throw new ArgumentNullException("paths"); - - int capacity = 0; - int num = 0; - for (int index = 0, l = paths.Length; index < l; ++index) - { - if (paths[index] == null) - throw new ArgumentNullException("paths"); - - if (paths[index].Length != 0) - { - if (IsPathRooted(paths[index], checkInvalidPathChars)) - { - num = index; - capacity = paths[index].Length; - } - else - capacity += paths[index].Length; - - char ch = paths[index][paths[index].Length - 1]; - - if (!IsDVsc(ch, null)) - ++capacity; - } - } - - var buffer = new StringBuilder(capacity); - for (int index = num; index < paths.Length; ++index) - { - if (paths[index].Length != 0) - { - if (buffer.Length == 0) - buffer.Append(paths[index]); - - else - { - char ch = buffer[buffer.Length - 1]; - - if (!IsDVsc(ch, null)) - buffer.Append(DirectorySeparatorChar); - - buffer.Append(paths[index]); - } - } - } - - return buffer.ToString(); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Constants.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Constants.cs deleted file mode 100644 index 08e8045..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Constants.cs +++ /dev/null @@ -1,124 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Globalization; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - /// AltDirectorySeparatorChar = '/' Provides a platform-specific alternate character used to separate directory levels in a path string that reflects a hierarchical file system organization. - public static readonly char AltDirectorySeparatorChar = System.IO.Path.AltDirectorySeparatorChar; - - /// DirectorySeparatorChar = '\' Provides a platform-specific character used to separate directory levels in a path string that reflects a hierarchical file system organization. - public static readonly char DirectorySeparatorChar = System.IO.Path.DirectorySeparatorChar; - - /// PathSeparator = ';' A platform-specific separator character used to separate path strings in environment variables. - public static readonly char PathSeparator = System.IO.Path.PathSeparator; - - /// VolumeSeparatorChar = ':' Provides a platform-specific Volume Separator character. - public static readonly char VolumeSeparatorChar = System.IO.Path.VolumeSeparatorChar; - - /// [AlphaFS] AltDirectorySeparatorChar = "/" Provides a platform-specific alternate string used to separate directory levels in a path string that reflects a hierarchical file system organization. - public static readonly string AltDirectorySeparator = AltDirectorySeparatorChar.ToString(CultureInfo.CurrentCulture); - - /// [AlphaFS] CurrentDirectoryPrefix = '.' Provides a current directory character. - public const char CurrentDirectoryPrefixChar = '.'; - - /// [AlphaFS] CurrentDirectoryPrefix = "." Provides a current directory string. - public static readonly string CurrentDirectoryPrefix = CurrentDirectoryPrefixChar.ToString(CultureInfo.CurrentCulture); - - /// [AlphaFS] DirectorySeparator = "\" Provides a platform-specific string used to separate directory levels in a path string that reflects a hierarchical file system organization. - public static readonly string DirectorySeparator = DirectorySeparatorChar.ToString(CultureInfo.CurrentCulture); - - /// [AlphaFS] ExtensionSeparatorChar = '.' Provides an Extension Separator character. - public const char ExtensionSeparatorChar = '.'; - - /// [AlphaFS] ParentDirectoryPrefix = ".." Provides a parent directory string. - public const string ParentDirectoryPrefix = ".."; - - /// [AlphaFS] StreamSeparator = ':' Provides a platform-specific Stream-name character. - public static readonly char StreamSeparatorChar = System.IO.Path.VolumeSeparatorChar; - - /// [AlphaFS] StreamSeparator = ':' Provides a platform-specific Stream-name character. - public static readonly string StreamSeparator = StreamSeparatorChar.ToString(CultureInfo.CurrentCulture); - - /// [AlphaFS] StreamDataLabel = ':$DATA' Provides a platform-specific Stream :$DATA label. - public const string StreamDataLabel = ":$DATA"; - - /// [AlphaFS] StringTerminatorChar = '\0' String Terminator Suffix. - public const char StringTerminatorChar = '\0'; - - /// [AlphaFS] Characters to trim from the SearchPattern. - internal static readonly char[] TrimEndChars = { (char) 0x9, (char) 0xA, (char) 0xB, (char) 0xC, (char) 0xD, (char) 0x20, (char) 0x85, (char) 0xA0 }; - - /// [AlphaFS] VolumeSeparatorChar = ':' Provides a platform-specific Volume Separator character. - public static readonly string VolumeSeparator = VolumeSeparatorChar.ToString(CultureInfo.CurrentCulture); - - /// [AlphaFS] WildcardStarMatchAll = "*" Provides a match-all-items string. - public const string WildcardStarMatchAll = "*"; - - /// [AlphaFS] WildcardStarMatchAll = '*' Provides a match-all-items character. - public const char WildcardStarMatchAllChar = '*'; - - /// [AlphaFS] WildcardQuestion = "?" Provides a replace-item string. - public const string WildcardQuestion = "?"; - - /// [AlphaFS] WildcardQuestion = '?' Provides a replace-item string. - public const char WildcardQuestionChar = '?'; - - /// [AlphaFS] UncPrefix = "\\" Provides standard Windows Path UNC prefix. - public static readonly string UncPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{0}", DirectorySeparatorChar); - - /// [AlphaFS] LongPathPrefix = "\\?\" Provides standard Windows Long Path prefix. - public static readonly string LongPathPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", UncPrefix, WildcardQuestion, DirectorySeparatorChar); - - /// [AlphaFS] LongPathUncPrefix = "\\?\UNC\" Provides standard Windows Long Path UNC prefix. - public static readonly string LongPathUncPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", LongPathPrefix, "UNC", DirectorySeparatorChar); - - /// [AlphaFS] GlobalRootPrefix = "\\?\GLOBALROOT\" Provides standard Windows Volume prefix. - public static readonly string GlobalRootPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", LongPathPrefix, "GLOBALROOT", DirectorySeparatorChar); - - /// [AlphaFS] MsDosNamespacePrefix = "\\.\" Provides standard logical drive prefix. - public static readonly string LogicalDrivePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{0}.{0}", DirectorySeparatorChar); - - /// [AlphaFS] SubstitutePrefix = "\??\" Provides a SUBST.EXE Path prefix to a Logical Drive. - public static readonly string SubstitutePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}{0}", DirectorySeparatorChar, WildcardQuestion, WildcardQuestion); - - /// [AlphaFS] VolumePrefix = "\\?\Volume" Provides standard Windows Volume prefix. - public static readonly string VolumePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}", LongPathPrefix, "Volume"); - - /// [AlphaFS] DevicePrefix = "\Device\" Provides standard Windows Device prefix. - public static readonly string DevicePrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{0}", DirectorySeparatorChar, "Device"); - - /// [AlphaFS] DosDeviceLanmanPrefix = "\Device\LanmanRedirector\" Provides a MS-Dos Lanman Redirector Path UNC prefix to a network share. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Lanman")] - public static readonly string DosDeviceLanmanPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", DevicePrefix, "LanmanRedirector", DirectorySeparatorChar); - - /// [AlphaFS] DosDeviceMupPrefix = "\Device\Mup\" Provides a MS-Dos Mup Redirector Path UNC prefix to a network share. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mup")] - public static readonly string DosDeviceMupPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", DevicePrefix, "Mup", DirectorySeparatorChar); - - /// [AlphaFS] DosDeviceUncPrefix = "\??\UNC\" Provides a SUBST.EXE Path UNC prefix to a network share. - public static readonly string DosDeviceUncPrefix = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}", SubstitutePrefix, "UNC", DirectorySeparatorChar); - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetComponents.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetComponents.cs deleted file mode 100644 index 87f9cb4..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetComponents.cs +++ /dev/null @@ -1,367 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region ChangeExtension (.NET) - - /// Changes the extension of a path string. - /// The modified path information. - /// - /// The path information to modify. The path cannot contain any of the characters defined in . - /// The new extension (with or without a leading period). Specify to remove an existing extension from path. - [SecurityCritical] - public static string ChangeExtension(string path, string extension) - { - return System.IO.Path.ChangeExtension(path, extension); - } - - #endregion // ChangeExtension (.NET) - - #region GetDirectoryName - - #region .NET - - /// Returns the directory information for the specified path string. - /// - /// Directory information for , or if denotes a root directory or is - /// . - /// Returns if does not contain directory information. - /// - /// - /// The path of a file or directory. - [SecurityCritical] - public static string GetDirectoryName(string path) - { - return GetDirectoryName(path, true); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Returns the directory information for the specified path string. - /// - /// Directory information for , or if denotes a root directory or is - /// . Returns if does not contain directory information. - /// - /// - /// The path of a file or directory. - /// will check for invalid path characters. - [SecurityCritical] - public static string GetDirectoryName(string path, bool checkInvalidPathChars) - { - if (path != null) - { - int rootLength = GetRootLength(path, checkInvalidPathChars); - if (path.Length > rootLength) - { - int length = path.Length; - if (length == rootLength) - return null; - - while (length > rootLength && path[--length] != DirectorySeparatorChar && path[length] != AltDirectorySeparatorChar) { } - - return path.Substring(0, length).Replace(AltDirectorySeparatorChar, DirectorySeparatorChar); - } - } - - return null; - } - - #endregion // AlphaFS - - #endregion // GetDirectoryName - - #region GetDirectoryNameWithoutRoot - - #region AlphaFS - - /// [AlphaFS] Returns the directory information for the specified path string without the root information, for example: "C:\Windows\system32" returns: "Windows". - /// The without the file name part and without the root information (if any), or if is or if denotes a root (such as "\", "C:", or * "\\server\share"). - /// The path. - [SecurityCritical] - public static string GetDirectoryNameWithoutRoot(string path) - { - return GetDirectoryNameWithoutRootTransacted(null, path); - } - - /// [AlphaFS] Returns the directory information for the specified path string without the root information, for example: "C:\Windows\system32" returns: "Windows". - /// The without the file name part and without the root information (if any), or if is or if denotes a root (such as "\", "C:", or * "\\server\share"). - /// The transaction. - /// The path. - [SecurityCritical] - public static string GetDirectoryNameWithoutRootTransacted(KernelTransaction transaction, string path) - { - if (path == null) - return null; - - DirectoryInfo di = Directory.GetParentCore(transaction, path, PathFormat.RelativePath); - return di != null && di.Parent != null ? di.Name : null; - } - - #endregion // AlphaFS - - #endregion // GetDirectoryNameWithoutRoot - - #region GetExtension - - #region .NET - - /// Returns the extension of the specified path string. - /// - /// The extension of the specified path (including the period "."), or null, or . - /// If is null, this method returns null. - /// If does not have extension information, - /// this method returns . - /// - /// - /// - /// The path string from which to get the extension. The path cannot contain any of the characters defined in . - [SecurityCritical] - public static string GetExtension(string path) - { - return GetExtension(path, !Utils.IsNullOrWhiteSpace(path)); - } - - #endregion // .NET - - #region AlphaFS - - /// Returns the extension of the specified path string. - /// - /// The extension of the specified path (including the period "."), or null, or . - /// If is null, this method returns null. - /// If does not have extension information, - /// this method returns . - /// - /// - /// The path string from which to get the extension. The path cannot contain any of the characters defined in . - /// will check for invalid path characters. - [SecurityCritical] - public static string GetExtension(string path, bool checkInvalidPathChars) - { - if (path == null) - return null; - - if (checkInvalidPathChars) - CheckInvalidPathChars(path, false, true); - - int length = path.Length; - int index = length; - while (--index >= 0) - { - char ch = path[index]; - if (ch == ExtensionSeparatorChar) - return index != length - 1 ? path.Substring(index, length - index) : string.Empty; - - if (IsDVsc(ch, null)) - break; - } - - return string.Empty; - } - - #endregion // AlphaFS - - #endregion // GetExtension - - #region GetFileName - - #region .NET - - /// Returns the file name and extension of the specified path string. - /// - /// The characters after the last directory character in . If the last character of is a - /// directory or volume separator character, this method returns string.Empty. If path is null, this method returns null. - /// - /// - /// The path string from which to obtain the file name and extension. The path cannot contain any of the characters defined in . - [SecurityCritical] - public static string GetFileName(string path) - { - return GetFileName(path, true); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Returns the file name and extension of the specified path string. - /// - /// The characters after the last directory character in . If the last character of is a - /// directory or volume separator character, this method returns string.Empty. If path is null, this method returns null. - /// - /// - /// The path string from which to obtain the file name and extension. - /// will check for invalid path characters. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - public static string GetFileName(string path, bool checkInvalidPathChars) - { - if (Utils.IsNullOrWhiteSpace(path)) - return path; - - if (checkInvalidPathChars) - CheckInvalidPathChars(path, false, true); - - int length = path.Length; - int index = length; - while (--index >= 0) - { - char ch = path[index]; - if (IsDVsc(ch, null)) - return path.Substring(index + 1, length - index - 1); - } - - return path; - } - - #endregion // AlphaFS - - #endregion // GetFileName - - #region GetFileNameWithoutExtension - - #region .NET - - /// Returns the file name of the specified path string without the extension. - /// The string returned by GetFileName, minus the last period (.) and all characters following it. - /// - /// The path of the file. The path cannot contain any of the characters defined in . - [SecurityCritical] - public static string GetFileNameWithoutExtension(string path) - { - return GetFileNameWithoutExtension(path, true); - } - - #endregion // .NET - - #region AlphaFS - - /// [AlphaFS] Returns the file name of the specified path string without the extension. - /// The string returned by GetFileName, minus the last period (.) and all characters following it. - /// - /// The path of the file. The path cannot contain any of the characters defined in . - /// will check for invalid path characters. - [SecurityCritical] - public static string GetFileNameWithoutExtension(string path, bool checkInvalidPathChars) - { - path = GetFileName(path, checkInvalidPathChars); - - if (path != null) - { - int i; - return (i = path.LastIndexOf('.')) == -1 ? path : path.Substring(0, i); - } - - return null; - } - - #endregion // AlphaFS - - #endregion // GetFileNameWithoutExtension - - #region GetInvalidFileNameChars (.NET) - - /// Gets an array containing the characters that are not allowed in file names. - /// An array containing the characters that are not allowed in file names. - [SecurityCritical] - public static char[] GetInvalidFileNameChars() - { - return System.IO.Path.GetInvalidFileNameChars(); - } - - #endregion // GetInvalidFileNameChars (.NET) - - #region GetInvalidPathChars (.NET) - - /// Gets an array containing the characters that are not allowed in path names. - /// An array containing the characters that are not allowed in path names. - [SecurityCritical] - public static char[] GetInvalidPathChars() - { - return System.IO.Path.GetInvalidPathChars(); - } - - #endregion // GetInvalidPathChars (.NET) - - #region GetPathRoot - - #region .NET - - /// Gets the root directory information of the specified path. - /// - /// Returns the root directory of , such as "C:\", - /// or if is , - /// or an empty string if does not contain root directory information. - /// - /// - /// The path from which to obtain root directory information. - [SecurityCritical] - public static string GetPathRoot(string path) - { - return GetPathRoot(path, true); - } - - #endregion // .NET - - /// [AlphaFS] Gets the root directory information of the specified path. - /// - /// Returns the root directory of , such as "C:\", - /// or if is , - /// or an empty string if does not contain root directory information. - /// - /// - /// The path from which to obtain root directory information. - /// will check for invalid path characters. - [SecurityCritical] - public static string GetPathRoot(string path, bool checkInvalidPathChars) - { - if (path == null) - return null; - - if (path.Trim().Length == 0) - throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "path"); - - string pathRp = GetRegularPathCore(path, checkInvalidPathChars ? GetFullPathOptions.CheckInvalidPathChars : GetFullPathOptions.None, false); - - var rootLengthPath = GetRootLength(path, false); - var rootLengthPathRp = GetRootLength(pathRp, false); - - // Check if pathRp is an empty string. - if (rootLengthPathRp == 0) - if (path.StartsWith(LongPathPrefix, StringComparison.OrdinalIgnoreCase)) - return GetLongPathCore(path.Substring(0, rootLengthPath), GetFullPathOptions.None); - - return path.StartsWith(LongPathUncPrefix, StringComparison.OrdinalIgnoreCase) - ? GetLongPathCore(pathRp.Substring(0, rootLengthPathRp), GetFullPathOptions.None) - : path.Substring(0, rootLengthPath); - } - - #endregion // GetPathRoot - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFinalPathNameByHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFinalPathNameByHandle.cs deleted file mode 100644 index 77206eb..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFinalPathNameByHandle.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Security; -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - /// [AlphaFS] Retrieves the final path for the specified file, formatted as . - /// The final path as a string. - /// - /// A final path is the path that is returned when a path is fully resolved. For example, for a symbolic link named "C:\tmp\mydir" that - /// points to "D:\yourdir", the final path would be "D:\yourdir". - /// - /// Then handle to a instance. - [SecurityCritical] - public static string GetFinalPathNameByHandle(SafeFileHandle handle) - { - return GetFinalPathNameByHandleCore(handle, FinalPathFormats.None); - } - - /// [AlphaFS] Retrieves the final path for the specified file, formatted as . - /// The final path as a string. - /// - /// A final path is the path that is returned when a path is fully resolved. For example, for a symbolic link named "C:\tmp\mydir" that - /// points to "D:\yourdir", the final path would be "D:\yourdir". - /// - /// Then handle to a instance. - /// The final path, formatted as - [SecurityCritical] - public static string GetFinalPathNameByHandle(SafeFileHandle handle, FinalPathFormats finalPath) - { - return GetFinalPathNameByHandleCore(handle, finalPath); - } - - /// Retrieves the final path for the specified file, formatted as . - /// The final path as a string. - /// - /// A final path is the path that is returned when a path is fully resolved. For example, for a symbolic link named "C:\tmp\mydir" that - /// points to "D:\yourdir", the final path would be "D:\yourdir". The string that is returned by this function uses the - /// syntax. - /// - /// Then handle to a instance. - /// The final path, formatted as - [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Alphaleonis.Win32.Filesystem.NativeMethods.GetMappedFileName(System.IntPtr,Alphaleonis.Win32.SafeGlobalMemoryBufferHandle,System.Text.StringBuilder,System.UInt32)")] - [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Alphaleonis.Win32.Filesystem.NativeMethods.GetMappedFileName(System.IntPtr,Alphaleonis.Win32.Security.SafeLocalMemoryBufferHandle,System.Text.StringBuilder,System.UInt32)")] - [SecurityCritical] - internal static string GetFinalPathNameByHandleCore(SafeFileHandle handle, FinalPathFormats finalPath) - { - NativeMethods.IsValidHandle(handle); - - var buffer = new StringBuilder(NativeMethods.MaxPathUnicode); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - if (NativeMethods.IsAtLeastWindowsVista) - { - if (NativeMethods.GetFinalPathNameByHandle(handle, buffer, (uint) buffer.Capacity, finalPath) == Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - return buffer.ToString(); - } - } - - #region Older OperatingSystem - - // Obtaining a File Name From a File Handle - // http://msdn.microsoft.com/en-us/library/aa366789%28VS.85%29.aspx - - // Be careful when using GetFileSizeEx to check the size of hFile handle of an unknown "File" type object. - // This is more towards returning a filename from a file handle. If the handle is a named pipe handle it seems to hang the thread. - // Check for: FileTypes.DiskFile - - // Can't map a 0 byte file. - long fileSizeHi; - if (!NativeMethods.GetFileSizeEx(handle, out fileSizeHi)) - if (fileSizeHi == 0) - return string.Empty; - - - // PAGE_READONLY - // Allows views to be mapped for read-only or copy-on-write access. An attempt to write to a specific region results in an access violation. - // The file handle that the hFile parameter specifies must be created with the GENERIC_READ access right. - // PageReadOnly = 0x02, - using (SafeFileHandle handle2 = NativeMethods.CreateFileMapping(handle, null, 2, 0, 1, null)) - { - NativeMethods.IsValidHandle(handle, Marshal.GetLastWin32Error()); - - // FILE_MAP_READ - // Read = 4 - using (SafeLocalMemoryBufferHandle pMem = NativeMethods.MapViewOfFile(handle2, 4, 0, 0, (UIntPtr)1)) - { - if (NativeMethods.IsValidHandle(pMem, Marshal.GetLastWin32Error())) - if (NativeMethods.GetMappedFileName(Process.GetCurrentProcess().Handle, pMem, buffer, (uint)buffer.Capacity)) - NativeMethods.UnmapViewOfFile(pMem); - } - } - - - // Default output from GetMappedFileName(): "\Device\HarddiskVolumeX\path\filename.ext" - string dosDevice = buffer.Length > 0 ? buffer.ToString() : string.Empty; - - // Select output format. - switch (finalPath) - { - // As-is: "\Device\HarddiskVolumeX\path\filename.ext" - case FinalPathFormats.VolumeNameNT: - return dosDevice; - - // To: "\path\filename.ext" - case FinalPathFormats.VolumeNameNone: - return DosDeviceToDosPath(dosDevice, string.Empty); - - // To: "\\?\Volume{GUID}\path\filename.ext" - case FinalPathFormats.VolumeNameGuid: - string dosPath = DosDeviceToDosPath(dosDevice, null); - if (!Utils.IsNullOrWhiteSpace(dosPath)) - { - string path = GetSuffixedDirectoryNameWithoutRootCore(null, dosPath); - string driveLetter = RemoveTrailingDirectorySeparator(GetPathRoot(dosPath, false), false); - string file = GetFileName(dosPath, true); - - if (!Utils.IsNullOrWhiteSpace(file)) - foreach (string drive in Directory.EnumerateLogicalDrivesCore(false, false).Select(drv => drv.Name).Where(drv => driveLetter.Equals(RemoveTrailingDirectorySeparator(drv, false), StringComparison.OrdinalIgnoreCase))) - return CombineCore(false, Volume.GetUniqueVolumeNameForPath(drive), path, file); - } - - break; - } - - // To: "\\?\C:\path\filename.ext" - return Utils.IsNullOrWhiteSpace(dosDevice) - ? string.Empty - : LongPathPrefix + DosDeviceToDosPath(dosDevice, null); - - #endregion // Older OperatingSystem - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs deleted file mode 100644 index a9202d5..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.GetFullPath.cs +++ /dev/null @@ -1,305 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region .NET - - /// Returns the absolute path for the specified path string. - /// The fully qualified location of path, such as "C:\MyFile.txt". - /// - /// GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. - /// It also calculates the address of the file name portion of the full path and file name. - ///   - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0". - ///   - /// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and - /// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetCurrentDirectory functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// - /// - /// The file or directory for which to obtain absolute path information. - [SecurityCritical] - public static string GetFullPath(string path) - { - return GetFullPathTackleCore(null, path, GetFullPathOptions.None); - } - - #endregion // .NET - - - #region AlphaFS - - /// Returns the absolute path for the specified path string. - /// The fully qualified location of path, such as "C:\MyFile.txt". - /// - /// GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. - /// It also calculates the address of the file name portion of the full path and file name. - ///   - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0". - ///   - /// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and - /// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetCurrentDirectory functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// - /// - /// The file or directory for which to obtain absolute path information. - /// Options for controlling the full path retrieval. - [SecurityCritical] - public static string GetFullPath(string path, GetFullPathOptions options) - { - return GetFullPathTackleCore(null, path, options); - } - - - /// [AlphaFS] Returns the absolute path for the specified path string. - /// The fully qualified location of path, such as "C:\MyFile.txt". - /// - /// GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. - /// It also calculates the address of the file name portion of the full path and file name. - ///   - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0". - ///   - /// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and - /// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetCurrentDirectory functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// - /// - /// The transaction. - /// The file or directory for which to obtain absolute path information. - [SecurityCritical] - public static string GetFullPathTransacted(KernelTransaction transaction, string path) - { - return GetFullPathTackleCore(transaction, path, GetFullPathOptions.None); - } - - /// [AlphaFS] Returns the absolute path for the specified path string. - /// The fully qualified location of path, such as "C:\MyFile.txt". - /// - /// GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. - /// It also calculates the address of the file name portion of the full path and file name. - ///   - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0". - ///   - /// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and - /// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetCurrentDirectory functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// - /// - /// The transaction. - /// The file or directory for which to obtain absolute path information. - /// Options for controlling the full path retrieval. - [SecurityCritical] - public static string GetFullPathTransacted(KernelTransaction transaction, string path, GetFullPathOptions options) - { - return GetFullPathTackleCore(transaction, path, options); - } - - #endregion // AlphaFS - - #region Internal Methods - - /// Retrieves the absolute path for the specified string. - /// The fully qualified location of , such as "C:\MyFile.txt". - /// - /// GetFullPathName merges the name of the current drive and directory with a specified file name to determine the full path and file name of a specified file. - /// It also calculates the address of the file name portion of the full path and file name. - ///   - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// The .NET Framework does not support direct access to physical disks through paths that are device names, such as "\\.\PHYSICALDRIVE0". - ///   - /// MSDN: Multithreaded applications and shared library code should not use the GetFullPathName function and - /// should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, - /// therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. - /// This limitation also applies to the SetCurrentDirectory and GetCurrentDirectory functions. The exception being when the application is guaranteed to be running in a single thread, - /// for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. - /// Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported. - /// - /// - /// - /// The transaction. - /// The file or directory for which to obtain absolute path information. - /// Options for controlling the full path retrieval. - [SecurityCritical] - internal static string GetFullPathCore(KernelTransaction transaction, string path, GetFullPathOptions options) - { - if (path != null) - if (path.StartsWith(GlobalRootPrefix, StringComparison.OrdinalIgnoreCase) ||path.StartsWith(VolumePrefix, StringComparison.OrdinalIgnoreCase)) - return path; - - if (options != GetFullPathOptions.None) - { - if ((options & GetFullPathOptions.CheckInvalidPathChars) != 0) - { - var checkAdditional = (options & GetFullPathOptions.CheckAdditional) != 0; - - CheckInvalidPathChars(path, checkAdditional, false); - - // Prevent duplicate checks. - options &= ~GetFullPathOptions.CheckInvalidPathChars; - - if (checkAdditional) - options &= ~GetFullPathOptions.CheckAdditional; - } - - // Do not remove trailing directory separator when path points to a drive like: "C:\" - // Doing so makes path point to the current directory. - - if (path == null || path.Length <= 3 || (!path.StartsWith(LongPathPrefix, StringComparison.OrdinalIgnoreCase) && path[1] != VolumeSeparatorChar)) - options &= ~GetFullPathOptions.RemoveTrailingDirectorySeparator; - } - - - var pathLp = GetLongPathCore(path, options); - uint bufferSize = NativeMethods.MaxPathUnicode; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - startGetFullPathName: - - var buffer = new StringBuilder((int)bufferSize); - var returnLength = (transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // GetFullPathName() / GetFullPathNameTransacted() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-04-15: MSDN confirms LongPath usage. - - ? NativeMethods.GetFullPathName(pathLp, bufferSize, buffer, IntPtr.Zero) - : NativeMethods.GetFullPathNameTransacted(pathLp, bufferSize, buffer, IntPtr.Zero, transaction.SafeHandle)); - - if (returnLength != Win32Errors.NO_ERROR) - { - if (returnLength > bufferSize) - { - bufferSize = returnLength; - goto startGetFullPathName; - } - } - else - { - if ((options & GetFullPathOptions.ContinueOnNonExist) != 0) - return null; - - NativeError.ThrowException(pathLp); - } - - - var finalFullPath = (options & GetFullPathOptions.AsLongPath) != 0 - ? GetLongPathCore(buffer.ToString(), GetFullPathOptions.None) - : GetRegularPathCore(buffer.ToString(), GetFullPathOptions.None, false); - - - finalFullPath = NormalizePath(finalFullPath, options); - - - if ((options & GetFullPathOptions.KeepDotOrSpace) != 0) - { - if (pathLp.EndsWith(".", StringComparison.OrdinalIgnoreCase)) - finalFullPath += "."; - - var lastChar = pathLp[pathLp.Length - 1]; - if (char.IsWhiteSpace(lastChar)) - finalFullPath += lastChar; - } - - - return finalFullPath; - } - } - - private static string GetFullPathTackleCore(KernelTransaction transaction, string path, GetFullPathOptions options) - { - if (path != null) - { - if (path.StartsWith(GlobalRootPrefix, StringComparison.OrdinalIgnoreCase) || path.StartsWith(VolumePrefix, StringComparison.OrdinalIgnoreCase)) - return path; - - CheckInvalidUncPath(path); - } - - CheckSupportedPathFormat(path, true, true); - - return GetFullPathCore(transaction, path, options); - } - - /// Applies the to - /// with applied . - /// - /// - /// - /// - private static string ApplyFullPathOptions(string path, GetFullPathOptions options) - { - if ((options & GetFullPathOptions.TrimEnd) != 0) - if ((options & GetFullPathOptions.KeepDotOrSpace) == 0) - path = path.TrimEnd(); - - if ((options & GetFullPathOptions.AddTrailingDirectorySeparator) != 0) - path = AddTrailingDirectorySeparator(path, false); - - if ((options & GetFullPathOptions.RemoveTrailingDirectorySeparator) != 0) - path = RemoveTrailingDirectorySeparator(path, false); - - if ((options & GetFullPathOptions.CheckInvalidPathChars) != 0) - CheckInvalidPathChars(path, (options & GetFullPathOptions.CheckAdditional) != 0, false); - - - // Trim leading whitespace. - if ((options & GetFullPathOptions.KeepDotOrSpace) == 0) - path = path.TrimStart(); - - return path; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.SeparatorManipulation.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.SeparatorManipulation.cs deleted file mode 100644 index 7140a10..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.SeparatorManipulation.cs +++ /dev/null @@ -1,202 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region AddTrailingDirectorySeparator - - /// [AlphaFS] Adds a trailing character to the string, when absent. - /// A text string with a trailing character. The function returns when is . - /// A text string to which the trailing is to be added, when absent. - [SecurityCritical] - public static string AddTrailingDirectorySeparator(string path) - { - return AddTrailingDirectorySeparator(path, false); - } - - /// [AlphaFS] Adds a trailing or character to the string, when absent. - /// A text string with a trailing or character. The function returns when is . - /// A text string to which the trailing or is to be added, when absent. - /// If the character will be added instead. - [SecurityCritical] - public static string AddTrailingDirectorySeparator(string path, bool addAlternateSeparator) - { - return path == null - ? null - : (addAlternateSeparator - ? ((!path.EndsWith(AltDirectorySeparatorChar.ToString(CultureInfo.CurrentCulture), StringComparison.OrdinalIgnoreCase)) - ? path + AltDirectorySeparatorChar - : path) - - : ((!path.EndsWith(DirectorySeparatorChar.ToString(CultureInfo.CurrentCulture), StringComparison.OrdinalIgnoreCase)) - ? path + DirectorySeparatorChar - : path)); - } - - #endregion // AddTrailingDirectorySeparator - - #region RemoveTrailingDirectorySeparator - - /// [AlphaFS] Removes the trailing character from the string, when present. - /// A text string where the trailing character has been removed. The function returns when is . - /// A text string from which the trailing is to be removed, when present. - [SecurityCritical] - public static string RemoveTrailingDirectorySeparator(string path) - { - return path == null ? null : path.TrimEnd(DirectorySeparatorChar, AltDirectorySeparatorChar); - } - - /// [AlphaFS] Removes the trailing or character from the string, when present. - /// A text string where the trailing or character has been removed. The function returns when is . - /// A text string from which the trailing or is to be removed, when present. - /// If the trailing character will be removed instead. - [SecurityCritical] - public static string RemoveTrailingDirectorySeparator(string path, bool removeAlternateSeparator) - { - return path == null - ? null - : path.TrimEnd(removeAlternateSeparator ? AltDirectorySeparatorChar : DirectorySeparatorChar); - } - - #endregion // RemoveTrailingDirectorySeparator - - #region GetSuffixedDirectoryName - - /// [AlphaFS] Returns the directory information for the specified with a trailing character. - /// - /// The suffixed directory information for the specified with a trailing character, - /// or if is or if denotes a root (such as "\", "C:", or * "\\server\share"). - /// - /// This method is similar to calling Path.GetDirectoryName() + Path.AddTrailingDirectorySeparator() - /// The path. - [SecurityCritical] - public static string GetSuffixedDirectoryName(string path) - { - return GetSuffixedDirectoryNameCore(null, path); - } - - /// [AlphaFS] Returns the directory information for the specified with a trailing character. - /// - /// The suffixed directory information for the specified with a trailing character, - /// or if is or if denotes a root (such as "\", "C:", or * "\\server\share"). - /// - /// This method is similar to calling Path.GetDirectoryName() + Path.AddTrailingDirectorySeparator() - /// The transaction. - /// The path. - [SecurityCritical] - public static string GetSuffixedDirectoryNameTransacted(KernelTransaction transaction, string path) - { - return GetSuffixedDirectoryNameCore(transaction, path); - } - - #endregion // GetSuffixedDirectoryName - - #region GetSuffixedDirectoryNameWithoutRoot - - /// [AlphaFS] Returns the directory information for the specified without the root and with a trailing character. - /// - /// The directory information for the specified without the root and with a trailing character, - /// or if is or if is . - /// - /// The path. - [SecurityCritical] - public static string GetSuffixedDirectoryNameWithoutRoot(string path) - { - return GetSuffixedDirectoryNameWithoutRootCore(null, path); - } - - /// [AlphaFS] Returns the directory information for the specified without the root and with a trailing character. - /// - /// The directory information for the specified without the root and with a trailing character, - /// or if is or if is . - /// - /// The transaction. - /// The path. - [SecurityCritical] - public static string GetSuffixedDirectoryNameWithoutRootTransacted(KernelTransaction transaction, string path) - { - return GetSuffixedDirectoryNameWithoutRootCore(transaction, path); - } - - #endregion // GetSuffixedDirectoryNameWithoutRoot - - #region Internal Methods - - /// Returns the directory information for the specified with a trailing character. - /// - /// The suffixed directory information for the specified with a trailing character, - /// or if is or if denotes a root (such as "\", "C:", or * "\\server\share"). - /// - /// This method is similar to calling Path.GetDirectoryName() + Path.AddTrailingDirectorySeparator() - /// The transaction. - /// The path. - [SecurityCritical] - private static string GetSuffixedDirectoryNameCore(KernelTransaction transaction, string path) - { - DirectoryInfo di = Directory.GetParentCore(transaction, path, PathFormat.RelativePath); - - return di != null && di.Parent != null && di.Name != null - ? AddTrailingDirectorySeparator(CombineCore(false, di.Parent.FullName, di.Name), false) - : null; - } - - /// Returns the directory information for the specified without the root and with a trailing character. - /// - /// The directory information for the specified without the root and with a trailing character, - /// or if is or if is . - /// - /// The transaction. - /// The path. - [SecurityCritical] - private static string GetSuffixedDirectoryNameWithoutRootCore(KernelTransaction transaction, string path) - { - DirectoryInfo di = Directory.GetParentCore(transaction, path, PathFormat.RelativePath); - - if (di == null || di.Parent == null) - return null; - - DirectoryInfo tmp = di; - string suffixedDirectoryNameWithoutRoot; - - do - { - suffixedDirectoryNameWithoutRoot = tmp.DisplayPath.Replace(di.Root.ToString(), string.Empty); - - if (tmp.Parent != null) - tmp = di.Parent.Parent; - - } while (tmp != null && tmp.Root.Parent != null && tmp.Parent != null && !Utils.IsNullOrWhiteSpace(tmp.Parent.ToString())); - - return Utils.IsNullOrWhiteSpace(suffixedDirectoryNameWithoutRoot) - ? null - : AddTrailingDirectorySeparator(suffixedDirectoryNameWithoutRoot.TrimStart(DirectorySeparatorChar), false); - // TrimStart() for network-drive, like: C$ - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ShortLongConversions.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ShortLongConversions.cs deleted file mode 100644 index 5209d0c..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ShortLongConversions.cs +++ /dev/null @@ -1,273 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region GetLongPath - - /// Makes an extended long path from the specified by prefixing . - /// The prefixed with a , the minimum required full path is: "C:\". - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// - /// - /// The path to the file or directory, this can also be an UNC path. - [SecurityCritical] - public static string GetLongPath(string path) - { - return GetLongPathCore(path, GetFullPathOptions.None); - } - - #endregion // GetLongPath - - #region GetLongFrom83ShortPath - - /// [AlphaFS] Converts the specified existing path to its regular long form. - /// An existing path to a folder or file. - /// The regular full path. - [SecurityCritical] - public static string GetLongFrom83ShortPath(string path) - { - return GetLongShort83PathCore(null, path, false); - } - - /// [AlphaFS] Converts the specified existing path to its regular long form. - /// The transaction. - /// An existing path to a folder or file. - /// The regular full path. - [SecurityCritical] - public static string GetLongFrom83ShortPathTransacted(KernelTransaction transaction, string path) - { - return GetLongShort83PathCore(transaction, path, false); - } - - #endregion // GetLongFrom83ShortPath - - #region GetRegularPath - - /// [AlphaFS] Gets the regular path from long prefixed one. i.e.: "\\?\C:\Temp\file.txt" to C:\Temp\file.txt" or: "\\?\UNC\Server\share\file.txt" to "\\Server\share\file.txt". - /// Regular form path string. - /// This method does not handle paths with volume names, eg. \\?\Volume{GUID}\Folder\file.txt. - /// The path. - [SecurityCritical] - public static string GetRegularPath(string path) - { - return GetRegularPathCore(path, GetFullPathOptions.CheckInvalidPathChars, false); - } - - #endregion // GetRegularPath - - #region GetShort83Path - - /// [AlphaFS] Retrieves the short path form of the specified path. - /// A path that has the 8.3 path form. - /// Will fail on NTFS volumes with disabled 8.3 name generation. - /// The path must actually exist to be able to get the short path name. - /// An existing path to a folder or file. - [SecurityCritical] - public static string GetShort83Path(string path) - { - return GetLongShort83PathCore(null, path, true); - } - - /// [AlphaFS] Retrieves the short path form of the specified path. - /// A path that has the 8.3 path form. - /// Will fail on NTFS volumes with disabled 8.3 name generation. - /// The path must actually exist to be able to get the short path name. - /// The transaction. - /// An existing path to a folder or file. - [SecurityCritical] - public static string GetShort83PathTransacted(KernelTransaction transaction, string path) - { - return GetLongShort83PathCore(transaction, path, true); - } - - #endregion // GetShort83Path - - #region IsLongPath - - /// [AlphaFS] Determines whether the specified path starts with a or . - /// if the specified path has a long path (UNC) prefix, otherwise. - /// The path to the file or directory. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public static bool IsLongPath(string path) - { - return !Utils.IsNullOrWhiteSpace(path) && path.StartsWith(LongPathPrefix, StringComparison.OrdinalIgnoreCase); - } - - #endregion // IsLongPath - - #region Internals Methods - - /// Makes an extended long path from the specified by prefixing . - /// The prefixed with a , the minimum required full path is: "C:\". - /// This method does not verify that the resulting path and file name are valid, or that they see an existing file on the associated volume. - /// - /// - /// The path to the file or directory, this can also be an UNC path. - /// Options for controlling the full path retrieval. - [SecurityCritical] - internal static string GetLongPathCore(string path, GetFullPathOptions options) - { - if (path == null) - throw new ArgumentNullException("path"); - - if (path.Length == 0 || Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "path"); - - if (options != GetFullPathOptions.None) - path = ApplyFullPathOptions(path, options); - - // ".", "C:" - if (path.Length <= 2 || - path.StartsWith(LongPathPrefix, StringComparison.OrdinalIgnoreCase) || - path.StartsWith(LogicalDrivePrefix, StringComparison.OrdinalIgnoreCase)) - return path; - - if (path.StartsWith(UncPrefix, StringComparison.OrdinalIgnoreCase)) - return LongPathUncPrefix + path.Substring(UncPrefix.Length); - - // Don't use char.IsLetter() here as that can be misleading. - // The only valid drive letters are: a-z and A-Z. - char c = path[0]; - return IsPathRooted(path, false) && ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) - ? LongPathPrefix + path - : path; - } - - /// Retrieves the short path form, or the regular long form of the specified . - /// If is , a path of the 8.3 form otherwise the regular long form. - /// - /// Will fail on NTFS volumes with disabled 8.3 name generation. - /// The path must actually exist to be able to get the short- or long path name. - /// - /// The transaction. - /// An existing path to a folder or file. - /// to retrieve the short path form, to retrieve the regular long form from the 8.3 . - [SecurityCritical] - private static string GetLongShort83PathCore(KernelTransaction transaction, string path, bool getShort) - { - string pathLp = GetFullPathCore(transaction, path, GetFullPathOptions.AsLongPath | GetFullPathOptions.FullCheck); - - var buffer = new StringBuilder(); - uint actualLength = getShort ? NativeMethods.GetShortPathName(pathLp, null, 0) : (uint) path.Length; - - while (actualLength > buffer.Capacity) - { - buffer = new StringBuilder((int)actualLength); - actualLength = getShort - - // GetShortPathName() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-01-29: MSDN confirms LongPath usage. - - ? NativeMethods.GetShortPathName(pathLp, buffer, (uint)buffer.Capacity) - : transaction == null || !NativeMethods.IsAtLeastWindowsVista - - // GetLongPathName() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-01-29: MSDN confirms LongPath usage. - - ? NativeMethods.GetLongPathName(pathLp, buffer, (uint)buffer.Capacity) - : NativeMethods.GetLongPathNameTransacted(pathLp, buffer, (uint)buffer.Capacity, transaction.SafeHandle); - - if (actualLength == Win32Errors.ERROR_SUCCESS) - NativeError.ThrowException(pathLp); - } - - return GetRegularPathCore(buffer.ToString(), GetFullPathOptions.None, false); - } - - /// Gets the regular path from a long path. - /// - /// Returns the regular form of a long . - /// For example: "\\?\C:\Temp\file.txt" to: "C:\Temp\file.txt", or: "\\?\UNC\Server\share\file.txt" to: "\\Server\share\file.txt". - /// - /// - /// MSDN: String.TrimEnd Method notes to Callers: http://msdn.microsoft.com/en-us/library/system.string.trimend%28v=vs.110%29.aspx - /// - /// - /// - /// The path. - /// Options for controlling the full path retrieval. - /// When , throws an . - [SecurityCritical] - internal static string GetRegularPathCore(string path, GetFullPathOptions options, bool allowEmpty) - { - if (path == null) - throw new ArgumentNullException("path"); - - if (!allowEmpty && (path.Length == 0 || Utils.IsNullOrWhiteSpace(path))) - throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "path"); - - if (options != GetFullPathOptions.None) - path = ApplyFullPathOptions(path, options); - - return path.StartsWith(GlobalRootPrefix, StringComparison.OrdinalIgnoreCase) - || path.StartsWith(VolumePrefix, StringComparison.OrdinalIgnoreCase) - || !path.StartsWith(LongPathPrefix, StringComparison.OrdinalIgnoreCase) - ? path - : (path.StartsWith(LongPathUncPrefix, StringComparison.OrdinalIgnoreCase) - ? UncPrefix + path.Substring(LongPathUncPrefix.Length) - : path.Substring(LongPathPrefix.Length)); - } - - /// Gets the path as a long full path. - /// The path as an extended length path. - /// - /// The transaction. - /// Full pathname of the source path to convert. - /// The path format to use. - /// Options for controlling the operation. Note that on .NET 3.5 the TrimEnd option has no effect. - internal static string GetExtendedLengthPathCore(KernelTransaction transaction, string sourcePath, PathFormat pathFormat, GetFullPathOptions options) - { - switch (pathFormat) - { - case PathFormat.LongFullPath: - return sourcePath; - - case PathFormat.FullPath: - return GetLongPathCore(sourcePath, GetFullPathOptions.None); - - case PathFormat.RelativePath: -#if NET35 - // .NET 3.5 the TrimEnd option has no effect. - options = options & ~GetFullPathOptions.TrimEnd; -#endif - return GetFullPathCore(transaction, sourcePath, GetFullPathOptions.AsLongPath | options); - - default: - throw new ArgumentException("Invalid value for " + typeof(PathFormat).Name + ": " + pathFormat); - } - } - - #endregion // Internals Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Temporary.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Temporary.cs deleted file mode 100644 index 552de97..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.Temporary.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region GetRandomFileName (.NET) - - /// Returns a random folder name or file name. - /// A random folder name or file name. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static string GetRandomFileName() - { - return System.IO.Path.GetRandomFileName(); - } - - #endregion // GetRandomFileName (.NET) - - #region GetTempFileName (.NET) - - /// Creates a uniquely named, zero-byte temporary file on disk and returns the full path of that file. - /// The full path of the temporary file. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static string GetTempFileName() - { - return System.IO.Path.GetTempFileName(); - } - - #endregion // GetTempFileName (.NET) - - #region GetTempPath (.NET) - - /// Returns the path of the current user's temporary folder. - /// The path to the temporary folder, ending with a backslash. - [SecurityCritical] - public static string GetTempPath() - { - return System.IO.Path.GetTempPath(); - } - - /// [AlphaFS] Returns the path of the current user's temporary folder. - /// The folder name to append to the temporary folder. - /// The path to the temporary folder, combined with . - [SecurityCritical] - public static string GetTempPath(string combinePath) - { - string tempPath = GetTempPath(); - return !Utils.IsNullOrWhiteSpace(combinePath) ? CombineCore(false, tempPath, combinePath) : tempPath; - } - - #endregion // GetTempPath (.NET) - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.UncPaths.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.UncPaths.cs deleted file mode 100644 index 6575c65..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.UncPaths.cs +++ /dev/null @@ -1,234 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Alphaleonis.Win32.Network; -using System; -using System.Globalization; -using System.IO; -using System.Net.NetworkInformation; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region GetMappedConnectionName - - /// [AlphaFS] Gets the connection name of the locally mapped drive. - /// The server and share as: \\servername\sharename. - /// - /// - /// - /// - /// The local path with drive name. - [SecurityCritical] - public static string GetMappedConnectionName(string path) - { - return Host.GetRemoteNameInfoCore(path, true).lpConnectionName; - } - - #endregion // GetMappedConnectionName - - #region GetMappedUncName - - /// [AlphaFS] Gets the network share name from the locally mapped path. - /// The network share connection name of . - /// - /// - /// - /// - /// The local path with drive name. - [SecurityCritical] - public static string GetMappedUncName(string path) - { - return Host.GetRemoteNameInfoCore(path, true).lpUniversalName; - } - - #endregion // GetMappedUncName - - #region IsUncPath - - /// [AlphaFS] Determines if a path string is a valid Universal Naming Convention (UNC) path. - /// if the specified path is a Universal Naming Convention (UNC) path, otherwise. - /// The path to check. - [SecurityCritical] - public static bool IsUncPath(string path) - { - return IsUncPathCore(path, false, true); - } - - /// [AlphaFS] Determines if a path string is a valid Universal Naming Convention (UNC) path, optionally skip invalid path character check. - /// if the specified path is a Universal Naming Convention (UNC) path, otherwise. - /// The path to check. - /// will check for invalid path characters. - [SecurityCritical] - public static bool IsUncPath(string path, bool checkInvalidPathChars) - { - return IsUncPathCore(path, false, checkInvalidPathChars); - } - - #endregion // IsUncPath - - #region LocalToUnc - - /// [AlphaFS] Converts a local path to a network share path. - /// A Local path, e.g.: "C:\Windows" will be returned as: "\\MachineName\C$\Windows". - /// If a logical drive points to a network share path, the share path will be returned instead. - /// - /// On successful conversion a UNC path is returned. - /// If the conversion fails, is returned. - /// If is an empty string or , is returned. - /// - /// - /// - /// - /// A local path, e.g.: "C:\Windows". - [SecurityCritical] - public static string LocalToUnc(string localPath) - { - return LocalToUncCore(localPath, false, false, false); - } - - /// [AlphaFS] Converts a local path to a network share path, optionally returning it in a long path format. - /// A Local path, e.g.: "C:\Windows" will be returned as: "\\MachineName\C$\Windows". - /// If a logical drive points to a network share path, the share path will be returned instead. - /// - /// On successful conversion a UNC path is returned. - /// If the conversion fails, is returned. - /// If is an empty string or , is returned. - /// - /// - /// - /// - /// A local path, e.g.: "C:\Windows". - /// returns the path in long path (Unicode) format, when returns the path as a regular path. - [SecurityCritical] - public static string LocalToUnc(string localPath, bool asLongPath) - { - return LocalToUncCore(localPath, asLongPath, false, false); - } - - /// [AlphaFS] Converts a local path to a network share path, optionally returning it in a long path format and the ability to add or remove a trailing backslash. - /// A Local path, e.g.: "C:\Windows" will be returned as: "\\MachineName\C$\Windows". - /// If a logical drive points to a network share path, the share path will be returned instead. - /// - /// On successful conversion a UNC path is returned. - /// If the conversion fails, is returned. - /// If is an empty string or , is returned. - /// - /// - /// - /// - /// A local path, e.g.: "C:\Windows". - /// returns the path in long path (Unicode) format, when returns the path as a regular path. - /// adds a trailing character to , when absent. - /// removes the trailing character from , when present. - [SecurityCritical] - public static string LocalToUnc(string localPath, bool asLongPath, bool addTrailingDirectorySeparator, bool removeTrailingDirectorySeparator) - { - return LocalToUncCore(localPath, asLongPath, addTrailingDirectorySeparator, removeTrailingDirectorySeparator); - } - - #endregion // LocalToUnc - - #region Internal Methods - - /// [AlphaFS] Determines if a path string is a valid Universal Naming Convention (UNC) path, optionally skip invalid path character check. - /// if the specified path is a Universal Naming Convention (UNC) path, otherwise. - /// The path to check. - /// When indicates that is already in regular path format. - /// will check for invalid path characters. - [SecurityCritical] - internal static bool IsUncPathCore(string path, bool isRegularPath, bool checkInvalidPathChars) - { - if (!isRegularPath) - path = GetRegularPathCore(path, checkInvalidPathChars ? GetFullPathOptions.CheckInvalidPathChars : 0, false); - - else if (checkInvalidPathChars) - CheckInvalidPathChars(path, false, false); - - Uri uri; - return Uri.TryCreate(path, UriKind.Absolute, out uri) && uri.IsUnc; - } - - /// Converts a local path to a network share path. - /// A Local path, e.g.: "C:\Windows" will be returned as: "\\MachineName\C$\Windows". - /// If a logical drive points to a network share path, the share path will be returned instead. - /// - /// On successful conversion a UNC path is returned. - /// If the conversion fails, is returned. - /// If is an empty string or , is returned. - /// - /// - /// - /// - /// A local path, e.g.: "C:\Windows". - /// returns the path in long path (Unicode) format, when returns the path as a regular path. - /// adds a trailing character to , when absent. - /// removes the trailing character from , when present. - [SecurityCritical] - internal static string LocalToUncCore(string localPath, bool asLongPath, bool addTrailingDirectorySeparator, bool removeTrailingDirectorySeparator) - { - if (Utils.IsNullOrWhiteSpace(localPath)) - return null; - - localPath = GetRegularPathCore(localPath, GetFullPathOptions.CheckInvalidPathChars, false); - - - if (!IsUncPathCore(localPath, true, false)) - { - if (localPath[0] == CurrentDirectoryPrefixChar || !IsPathRooted(localPath, false)) - localPath = GetFullPathCore(null, localPath, GetFullPathOptions.None); - - string drive = GetPathRoot(localPath, false); - - if (Utils.IsNullOrWhiteSpace(drive)) - return localPath; - - Network.NativeMethods.REMOTE_NAME_INFO unc = Host.GetRemoteNameInfoCore(drive, true); - - if (!Utils.IsNullOrWhiteSpace(unc.lpConnectionName)) - // Only leave trailing backslash if "localPath" also ends with backslash. - return localPath.EndsWith(DirectorySeparator, StringComparison.OrdinalIgnoreCase) - ? AddTrailingDirectorySeparator(unc.lpConnectionName, false) - : RemoveTrailingDirectorySeparator(unc.lpConnectionName, false); - - // Split: localDrive[0] = "C", localDrive[1] = "\Windows" - string[] localDrive = localPath.Split(VolumeSeparatorChar); - - // Return: "\\MachineName\C$\Windows" - localPath = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}${3}", Host.GetUncName(), DirectorySeparatorChar, localDrive[0], localDrive[1]); - } - - - // Only leave trailing backslash if "localPath" also ends with backslash. - addTrailingDirectorySeparator = addTrailingDirectorySeparator || - (localPath.EndsWith(DirectorySeparator, StringComparison.OrdinalIgnoreCase) && !removeTrailingDirectorySeparator); - - var options = (addTrailingDirectorySeparator ? GetFullPathOptions.AddTrailingDirectorySeparator : 0) | - (removeTrailingDirectorySeparator ? GetFullPathOptions.RemoveTrailingDirectorySeparator : 0); - - return asLongPath ? GetLongPathCore(localPath, options) : localPath; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ValidationAndChecks.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ValidationAndChecks.cs deleted file mode 100644 index 2d426e9..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.ValidationAndChecks.cs +++ /dev/null @@ -1,614 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - public static partial class Path - { - #region HasExtension (.NET) - - /// Determines whether a path includes a file name extension. - /// if the characters that follow the last directory separator (\\ or /) or volume separator (:) in the path include a period (.) followed by one or more characters; otherwise, . - /// - /// The path to search for an extension. The path cannot contain any of the characters defined in . - [SecurityCritical] - public static bool HasExtension(string path) - { - return System.IO.Path.HasExtension(path); - } - - #endregion // HasExtension (.NET) - - #region IsPathRooted - - #region .NET - - /// Gets a value indicating whether the specified path string contains absolute or relative path information. - /// if contains a root; otherwise, . - /// - /// The IsPathRooted method returns if the first character is a directory separator character such as - /// , or if the path starts with a drive letter and colon (). - /// For example, it returns true for path strings such as "\\MyDir\\MyFile.txt", "C:\\MyDir", or "C:MyDir". - /// It returns for path strings such as "MyDir". - /// - /// This method does not verify that the path or file name exists. - /// - /// - /// The path to test. The path cannot contain any of the characters defined in . - [SecurityCritical] - public static bool IsPathRooted(string path) - { - return IsPathRooted(path, true); - } - - #endregion // .NET - - /// [AlphaFS] Gets a value indicating whether the specified path string contains absolute or relative path information. - /// if contains a root; otherwise, . - /// - /// The IsPathRooted method returns true if the first character is a directory separator character such as - /// , or if the path starts with a drive letter and colon (). - /// For example, it returns for path strings such as "\\MyDir\\MyFile.txt", "C:\\MyDir", or "C:MyDir". - /// It returns for path strings such as "MyDir". - /// - /// This method does not verify that the path or file name exists. - /// - /// - /// The path to test. The path cannot contain any of the characters defined in . - /// will check for invalid path characters. - [SecurityCritical] - public static bool IsPathRooted(string path, bool checkInvalidPathChars) - { - if (path != null) - { - if (checkInvalidPathChars) - CheckInvalidPathChars(path, false, true); - - var length = path.Length; - - if ((length >= 1 && IsDVsc(path[0], false)) || - (length >= 2 && IsDVsc(path[1], true))) - return true; - } - - return false; - } - - #endregion // IsPathRooted - - #region IsValidName - - /// [AlphaFS] Check if file or folder name has any invalid characters. - /// - /// File or folder name. - /// if name contains any invalid characters. Otherwise - public static bool IsValidName(string name) - { - if (name == null) - throw new ArgumentNullException("name"); - - return name.IndexOfAny(GetInvalidFileNameChars()) < 0; - } - - #endregion // IsValidName - - #region Internal Methods - - internal static void CheckInvalidUncPath(string path) - { - // Tackle: Path.GetFullPath(@"\\\\.txt"), but exclude "." which is the current directory. - if (!IsLongPath(path) && path.StartsWith(UncPrefix, StringComparison.OrdinalIgnoreCase)) - { - var tackle = GetRegularPathCore(path, GetFullPathOptions.None, false).TrimStart(DirectorySeparatorChar, AltDirectorySeparatorChar); - - if (tackle.Length >= 2 && tackle[0] == CurrentDirectoryPrefixChar) - throw new ArgumentException(Resources.UNC_Path_Should_Match_Format); - } - } - - /// Checks that the given path format is supported. - /// - /// - /// A path to the file or directory. - /// Checks that the path contains only valid path-characters. - /// . - internal static void CheckSupportedPathFormat(string path, bool checkInvalidPathChars, bool checkAdditional) - { - if (Utils.IsNullOrWhiteSpace(path) || path.Length < 2) - return; - - var regularPath = GetRegularPathCore(path, GetFullPathOptions.None, false); - - var isArgumentException = (regularPath[0] == VolumeSeparatorChar); - var throwException = (isArgumentException || (regularPath.Length >= 2 && regularPath.IndexOf(VolumeSeparatorChar, 2) != -1)); - - if (throwException) - { - if (isArgumentException) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Unsupported_Path_Format, regularPath)); - - throw new NotSupportedException(string.Format(CultureInfo.CurrentCulture, Resources.Unsupported_Path_Format, regularPath)); - } - - if (checkInvalidPathChars) - CheckInvalidPathChars(path, checkAdditional, false); - } - - /// Checks that the path contains only valid path-characters. - /// - /// - /// A path to the file or directory. - /// also checks for ? and * characters. - /// When , throws an . - [SecurityCritical] - private static void CheckInvalidPathChars(string path, bool checkAdditional, bool allowEmpty) - { - if (path == null) - throw new ArgumentNullException("path"); - - if (!allowEmpty && (path.Length == 0 || Utils.IsNullOrWhiteSpace(path))) - throw new ArgumentException(Resources.Path_Is_Zero_Length_Or_Only_White_Space, "path"); - - // Will fail on a Unicode path. - var pathRp = GetRegularPathCore(path, GetFullPathOptions.None, allowEmpty); - - - // Handle "Path.GlobalRootPrefix" and "Path.VolumePrefix". - if (pathRp.StartsWith(GlobalRootPrefix, StringComparison.OrdinalIgnoreCase)) - pathRp = pathRp.Replace(GlobalRootPrefix, string.Empty); - - if (pathRp.StartsWith(VolumePrefix, StringComparison.OrdinalIgnoreCase)) - pathRp = pathRp.Replace(VolumePrefix, string.Empty); - - - for (int index = 0, l = pathRp.Length; index < l; ++index) - { - int num = pathRp[index]; - switch (num) - { - case 34: // " (quote) - case 60: // < (less than) - case 62: // > (greater than) - case 124: // | (pipe) - throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Resources.Illegal_Characters_In_Path, (char) num), pathRp); - - default: - // 32: space - if (num >= 32 && (!checkAdditional || num != WildcardQuestionChar && num != WildcardStarMatchAllChar)) - continue; - - goto case 34; - } - } - } - - /// Tranlates DosDevicePath, Volume GUID. For example: "\Device\HarddiskVolumeX\path\filename.ext" can translate to: "\path\filename.ext" or: "\\?\Volume{GUID}\path\filename.ext". - /// A translated dos path. - /// A DosDevicePath, for example: \Device\HarddiskVolumeX\path\filename.ext. - /// Alternate path/device text, usually string.Empty or . - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - private static string DosDeviceToDosPath(string dosDevice, string deviceReplacement) - { - if (Utils.IsNullOrWhiteSpace(dosDevice)) - return string.Empty; - - foreach (var drive in Directory.EnumerateLogicalDrivesCore(false, false).Select(drv => drv.Name)) - { - try - { - var path = RemoveTrailingDirectorySeparator(drive, false); - foreach (var devNt in Volume.QueryDosDevice(path).Where(dosDevice.StartsWith)) - return dosDevice.Replace(devNt, deviceReplacement ?? path); - } - catch - { - } - } - return string.Empty; - } - - [SecurityCritical] - internal static int GetRootLength(string path, bool checkInvalidPathChars) - { - if (checkInvalidPathChars) - CheckInvalidPathChars(path, false, false); - - var index = 0; - var length = path.Length; - - if (length >= 1 && IsDVsc(path[0], false)) - { - index = 1; - if (length >= 2 && IsDVsc(path[1], false)) - { - index = 2; - var num = 2; - - while (index < length && (!IsDVsc(path[index], false) || --num > 0)) - ++index; - } - } - else if (length >= 2 && IsDVsc(path[1], true)) - { - index = 2; - if (length >= 3 && IsDVsc(path[2], false)) - ++index; - } - - return index; - } - - /// Check if is a directory- and/or volume-separator character. - /// if is a separator character. - /// The character to check. - /// - /// If , checks for all separator characters: , - /// and - /// If , only checks for: and - /// If only checks for: - /// - [SecurityCritical] - internal static bool IsDVsc(char c, bool? checkSeparatorChar) - { - return checkSeparatorChar == null - - // Check for all separator characters. - ? c == DirectorySeparatorChar || c == AltDirectorySeparatorChar || c == VolumeSeparatorChar - - // Check for some separator characters. - : ((bool)checkSeparatorChar - ? c == VolumeSeparatorChar - : c == DirectorySeparatorChar || c == AltDirectorySeparatorChar); - } - - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - private static string NormalizePath(string path, GetFullPathOptions options) - { - var newBuffer = new StringBuilder(NativeMethods.MaxPathUnicode); - var index = 0; - uint numSpaces = 0; - uint numDots = 0; - var fixupDirectorySeparator = false; - - // Number of significant chars other than potentially suppressible - // dots and spaces since the last directory or volume separator char - uint numSigChars = 0; - - var lastSigChar = -1; // Index of last significant character. - - // Whether this segment of the path (not the complete path) started - // with a volume separator char. Reject "c:...". - var startedWithVolumeSeparator = false; - var firstSegment = true; - var lastDirectorySeparatorPos = 0; - - // LEGACY: This code is here for backwards compatibility reasons. It - // ensures that \\foo.cs\bar.cs stays \\foo.cs\bar.cs instead of being - // turned into \foo.cs\bar.cs. - if (path.Length > 0 && (path[0] == DirectorySeparatorChar || path[0] == AltDirectorySeparatorChar)) - { - newBuffer.Append('\\'); - index++; - lastSigChar = 0; - } - - // Normalize the string, stripping out redundant dots, spaces, and slashes. - while (index < path.Length) - { - var currentChar = path[index]; - - // We handle both directory separators and dots specially. For - // directory separators, we consume consecutive appearances. - // For dots, we consume all dots beyond the second in - // succession. All other characters are added as is. In - // addition we consume all spaces after the last other char - // in a directory name up until the directory separator. - - if (currentChar == DirectorySeparatorChar || currentChar == AltDirectorySeparatorChar) - { - // If we have a path like "123.../foo", remove the trailing dots. - // However, if we found "c:\temp\..\bar" or "c:\temp\...\bar", don't. - // Also remove trailing spaces from both files & directory names. - // This was agreed on with the OS team to fix undeletable directory - // names ending in spaces. - - // If we saw a '\' as the previous last significant character and - // are simply going to write out dots, suppress them. - // If we only contain dots and slashes though, only allow - // a string like [dot]+ [space]*. Ignore everything else. - // Legal: "\.. \", "\...\", "\. \" - // Illegal: "\.. .\", "\. .\", "\ .\" - - if (numSigChars == 0) - { - // Dot and space handling - if (numDots > 0) - { - // Look for ".[space]*" or "..[space]*" - var start = lastSigChar + 1; - if (path[start] != CurrentDirectoryPrefixChar) - throw new ArgumentException(path); - - // Only allow "[dot]+[space]*", and normalize the - // legal ones to "." or ".." - if (numDots >= 2) - { - // Reject "C:..." - if (startedWithVolumeSeparator && numDots > 2) - throw new ArgumentException(path); - - - if (path[start + 1] == CurrentDirectoryPrefixChar) - { - // Search for a space in the middle of the dots and throw - for (var i = start + 2; i < start + numDots; i++) - { - if (path[i] != CurrentDirectoryPrefixChar) - throw new ArgumentException(path); - } - - numDots = 2; - } - - else - { - if (numDots > 1) - throw new ArgumentException(path); - - numDots = 1; - } - } - - - if (numDots == 2) - newBuffer.Append(CurrentDirectoryPrefixChar); - - - newBuffer.Append(CurrentDirectoryPrefixChar); - fixupDirectorySeparator = false; - - // Continue in this case, potentially writing out '\'. - } - - - if (numSpaces > 0 && firstSegment) - { - // Handle strings like " \\server\share". - if (index + 1 < path.Length && (path[index + 1] == DirectorySeparatorChar || path[index + 1] == AltDirectorySeparatorChar)) - newBuffer.Append(DirectorySeparatorChar); - } - } - - - numDots = 0; - numSpaces = 0; // Suppress trailing spaces - - if (!fixupDirectorySeparator) - { - fixupDirectorySeparator = true; - newBuffer.Append(DirectorySeparatorChar); - } - - numSigChars = 0; - lastSigChar = index; - startedWithVolumeSeparator = false; - firstSegment = false; - - - var thisPos = newBuffer.Length - 1; - if (thisPos - lastDirectorySeparatorPos > NativeMethods.MaxDirectoryLength) - throw new PathTooLongException(path); - - lastDirectorySeparatorPos = thisPos; - } // if (Found directory separator) - - else if (currentChar == CurrentDirectoryPrefixChar) - { - // Reduce only multiple .'s only after slash to 2 dots. For - // instance a...b is a valid file name. - numDots++; - // Don't flush out non-terminal spaces here, because they may in - // the end not be significant. Turn "c:\ . .\foo" -> "c:\foo" - // which is the conclusion of removing trailing dots & spaces, - // as well as folding multiple '\' characters. - } - - else if (currentChar == ' ') - numSpaces++; - - else - { // Normal character logic - fixupDirectorySeparator = false; - - // To reject strings like "C:...\foo" and "C :\foo" - if (firstSegment && currentChar == VolumeSeparatorChar) - { - // Only accept "C:", not "c :" or ":" - // Get a drive letter or ' ' if index is 0. - var driveLetter = (index > 0) ? path[index - 1] : ' '; - - var validPath = (numDots == 0) && (numSigChars >= 1) && (driveLetter != ' '); - if (!validPath) - throw new ArgumentException(path); - - startedWithVolumeSeparator = true; - // We need special logic to make " c:" work, we should not fix paths like " foo::$DATA" - if (numSigChars > 1) - { - // Common case, simply do nothing - var spaceCount = 0; // How many spaces did we write out, numSpaces has already been reset. - while ((spaceCount < newBuffer.Length) && newBuffer[spaceCount] == ' ') - spaceCount++; - - if (numSigChars - spaceCount == 1) - { - //Safe to update stack ptr directly - newBuffer.Length = 0; - newBuffer.Append(driveLetter); - // Overwrite spaces, we need a special case to not break " foo" as a relative path. - } - } - - numSigChars = 0; - } - - else - numSigChars += 1 + numDots + numSpaces; - - // Copy any spaces & dots since the last significant character - // to here. Note we only counted the number of dots & spaces, - // and don't know what order they're in. Hence the copy. - if (numDots > 0 || numSpaces > 0) - { - var numCharsToCopy = lastSigChar >= 0 ? index - lastSigChar - 1 : index; - - if (numCharsToCopy > 0) - for (var i = 0; i < numCharsToCopy; i++) - newBuffer.Append(path[lastSigChar + 1 + i]); - - numDots = 0; - numSpaces = 0; - } - - newBuffer.Append(currentChar); - lastSigChar = index; - } - - index++; - } - - - if (newBuffer.Length - 1 - lastDirectorySeparatorPos > NativeMethods.MaxDirectoryLength) - throw new PathTooLongException(path); - - - // Drop any trailing dots and spaces from file & directory names, EXCEPT - // we MUST make sure that "C:\foo\.." is correctly handled. - // Also handle "C:\foo\." -> "C:\foo", while "C:\." -> "C:\" - if (numSigChars == 0) - { - if (numDots > 0) - { - // Look for ".[space]*" or "..[space]*" - var start = lastSigChar + 1; - - if (path[start] != CurrentDirectoryPrefixChar) - throw new ArgumentException(path); - - - // Only allow "[dot]+[space]*", and normalize the legal ones to "." or ".." - if (numDots >= 2) - { - // Reject "C:..." - if (startedWithVolumeSeparator && numDots > 2) - throw new ArgumentException(path); - - - if (path[start + 1] == CurrentDirectoryPrefixChar) - { - // Search for a space in the middle of the dots and throw - for (var i = start + 2; i < start + numDots; i++) - if (path[i] != CurrentDirectoryPrefixChar) - throw new ArgumentException(path); - - numDots = 2; - } - - else - { - if (numDots > 1) - throw new ArgumentException(path); - - numDots = 1; - } - } - - if (numDots == 2) - newBuffer.Append(CurrentDirectoryPrefixChar); - - newBuffer.Append(CurrentDirectoryPrefixChar); - } - } - - - // If we ended up eating all the characters, bail out. - if (newBuffer.Length == 0) - throw new ArgumentException(path); - - - // Disallow URL's here. Some of our other Win32 API calls will reject - // them later, so we might be better off rejecting them here. - // Note we've probably turned them into "file:\D:\foo.tmp" by now. - // But for compatibility, ensure that callers that aren't doing a - // full check aren't rejected here. - if ((options & GetFullPathOptions.FullCheck) != 0) - { - var newBufferString = newBuffer.ToString(); - if (newBufferString.StartsWith("http:", StringComparison.OrdinalIgnoreCase) || newBufferString.StartsWith("file:", StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(path); - } - - // Call the Win32 API to do the final canonicalization step. - var result = 1; - - - if (result != 0) - { - /* Throw an ArgumentException for paths like \\, \\server, \\server\ - This check can only be properly done after normalizing, so - \\foo\.. will be properly rejected. Also, reject \\?\GLOBALROOT\ - (an internal kernel path) because it provides aliases for drives. */ - if (newBuffer.Length > 1 && newBuffer[0] == '\\' && newBuffer[1] == '\\') - { - var startIndex = 2; - while (startIndex < result) - { - if (newBuffer[startIndex] == '\\') - { - startIndex++; - break; - } - - startIndex++; - } - - if (startIndex == result) - throw new ArgumentException(path); - } - } - - - return newBuffer.ToString(); - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.cs b/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.cs deleted file mode 100644 index 2adfe74..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Path Class/Path.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Performs operations on String instances that contain file or directory path information. These operations are performed in a cross-platform manner. - public static partial class Path - { - // This file only exists for the documentation. - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeCmConnectMachineHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeCmConnectMachineHandle.cs deleted file mode 100644 index 41b2b0f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeCmConnectMachineHandle.cs +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents a wrapper class for a handle used by the CM_Connect_Machine/CM_Disconnect_Machine Win32 API functions. - [SecurityCritical] - internal sealed class SafeCmConnectMachineHandle : SafeHandleZeroOrMinusOneIsInvalid - { - #region Constructor - - /// Initializes a new instance of the class. - public SafeCmConnectMachineHandle() : base(true) - { - } - - #endregion // Constructor - - #region ReleaseHandle - - protected override bool ReleaseHandle() - { - return NativeMethods.CM_Disconnect_Machine(handle) == Win32Errors.NO_ERROR; - } - - #endregion // ReleaseHandle - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeEncryptedFileRawHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeEncryptedFileRawHandle.cs deleted file mode 100644 index 21fc80a..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeEncryptedFileRawHandle.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents a wrapper class for a handle used by the FindFirstFile/FindNextFile Win32 API functions. - [SecurityCritical] - internal sealed class SafeEncryptedFileRawHandle : SafeHandleZeroOrMinusOneIsInvalid - { - /// Constructor that prevents a default instance of this class from being created. - private SafeEncryptedFileRawHandle() - : base(true) - { - } - - /// Constructor that prevents a default instance of this class from being created. - /// The handle. - /// true to reliably release the handle during the finalization phase; false to prevent - /// reliable release (not recommended). - public SafeEncryptedFileRawHandle(IntPtr handle, bool ownsHandle) - : base(ownsHandle) - { - SetHandle(handle); - } - - /// When overridden in a derived class, executes the code required to free the handle. - /// if the handle is released successfully; otherwise, in the event of a catastrophic failure, . In this case, it generates a ReleaseHandleFailed Managed Debugging Assistant. - protected override bool ReleaseHandle() - { - NativeMethods.CloseEncryptedFileRaw(handle); - return true; - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindFileHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindFileHandle.cs deleted file mode 100644 index 33c3dee..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindFileHandle.cs +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents a wrapper class for a handle used by the FindFirstFile/FindNextFile Win32 API functions. - [SecurityCritical] - public sealed class SafeFindFileHandle : SafeHandleZeroOrMinusOneIsInvalid - { - /// Initializes a new instance of the class. - private SafeFindFileHandle() : base(true) - { - } - - /// Initializes a new instance of the class. - /// The handle. - /// [owns handle]. - public SafeFindFileHandle(IntPtr handle, bool callerHandle) : base(callerHandle) - { - SetHandle(handle); - } - - /// When overridden in a derived class, executes the code required to free the handle. - /// if the handle is released successfully; otherwise, in the event of a catastrophic failure, . In this case, it generates a ReleaseHandleFailed Managed Debugging Assistant. - protected override bool ReleaseHandle() - { - return NativeMethods.FindClose(handle); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeHandle.cs deleted file mode 100644 index 4020784..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeHandle.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents a wrapper class for a handle used by the FindFirstVolume/FindNextVolume methods of the Win32 API. - [SecurityCritical] - public sealed class SafeFindVolumeHandle : SafeHandleZeroOrMinusOneIsInvalid - { - /// Initializes a new instance of the class. - private SafeFindVolumeHandle() - : base(true) - { - } - - /// Initializes a new instance of the class. - /// The handle. - /// [owns handle]. - public SafeFindVolumeHandle(IntPtr handle, bool callerHandle) : base(callerHandle) - { - SetHandle(handle); - } - - /// When overridden in a derived class, executes the code required to free the handle. - /// if the handle is released successfully; otherwise, in the event of a catastrophic failure, . In this case, it generates a ReleaseHandleFailed Managed Debugging Assistant. - /// - protected override bool ReleaseHandle() - { - return NativeMethods.FindVolumeClose(handle); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeMountPointHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeMountPointHandle.cs deleted file mode 100644 index 2ecdf17..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeFindVolumeMountPointHandle.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Security; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents a wrapper class for a handle used by the FindFirstVolumeMountPoint/FindVolumeMountPointClose methods of the Win32 API. - [SecurityCritical] - internal sealed class SafeFindVolumeMountPointHandle : SafeHandleZeroOrMinusOneIsInvalid - { - /// Initializes a new instance of the class. - private SafeFindVolumeMountPointHandle() - : base(true) - { - } - - /// Initializes a new instance of the class. - /// The handle. - /// [owns handle]. - public SafeFindVolumeMountPointHandle(IntPtr handle, bool callerHandle) : base(callerHandle) - { - SetHandle(handle); - } - - /// When overridden in a derived class, executes the code required to free the handle. - /// if the handle is released successfully; otherwise, in the event of a catastrophic failure, . - /// - protected override bool ReleaseHandle() - { - return NativeMethods.FindVolumeMountPointClose(handle); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeKernelTransactionHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeKernelTransactionHandle.cs deleted file mode 100644 index 0a81af3..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeKernelTransactionHandle.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides a concrete implementation of SafeHandle supporting transactions. - internal class SafeKernelTransactionHandle : SafeHandleMinusOneIsInvalid - { - /// Initializes a new instance of the class. - public SafeKernelTransactionHandle() - : base(true) - { - } - - /// When overridden in a derived class, executes the code required to free the handle. - /// if the handle is released successfully; otherwise, in the event of a catastrophic failure, . In this case, it generates a ReleaseHandleFailed Managed Debugging Assistant. - [SecurityCritical] - protected override bool ReleaseHandle() - { - return NativeMethods.CloseHandle(handle); - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeLocalMemoryBufferHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeLocalMemoryBufferHandle.cs deleted file mode 100644 index 781050d..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeLocalMemoryBufferHandle.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; -using Microsoft.Win32.SafeHandles; - -namespace Alphaleonis.Win32.Security -{ - /// An IntPtr wrapper which can be used as the result of a Marshal.AllocHGlobal operation. - /// Calls Marshal.FreeHGlobal when disposed or finalized. - /// - internal sealed class SafeLocalMemoryBufferHandle : SafeHandleZeroOrMinusOneIsInvalid - { - #region Constructors - - /// Creates new instance with zero IntPtr. - public SafeLocalMemoryBufferHandle() : base(true) - { - } - - #endregion // Constructors - - #region Methods - - #region CopyFrom - - /// Copies data from a one-dimensional, managed 8-bit unsigned integer array to the unmanaged memory pointer referenced by this instance. - /// The one-dimensional array to copy from. - /// The zero-based index into the array where Copy should start. - /// The number of array elements to copy. - public void CopyFrom(byte[] source, int startIndex, int length) - { - Marshal.Copy(source, startIndex, handle, length); - } - - #endregion // CopyFrom - - #region CopyTo - - public void CopyTo(byte[] destination, int destinationOffset, int length) - { - if (destination == null) - throw new ArgumentNullException("destination"); - - if (destinationOffset < 0) - throw new ArgumentOutOfRangeException("destinationOffset", Resources.Negative_Destination_Offset); - - if (length < 0) - throw new ArgumentOutOfRangeException("length", Resources.Negative_Length); - - if (destinationOffset + length > destination.Length) - throw new ArgumentException(Resources.Destination_Buffer_Not_Large_Enough); - - Marshal.Copy(handle, destination, destinationOffset, length); - } - - #endregion // CopyTo - - #region ToByteArray - - public byte[] ToByteArray(int startIndex, int length) - { - if (IsInvalid) - return null; - - byte[] arr = new byte[length]; - Marshal.Copy(handle, arr, startIndex, length); - return arr; - } - - #endregion // ToByteArray - - #region ReleaseHandle - - /// Called when object is disposed or finalized. - protected override bool ReleaseHandle() - { - return handle == IntPtr.Zero || NativeMethods.LocalFree(handle) == IntPtr.Zero; - } - - #endregion // ReleaseHandle - - #endregion // Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeSetupDiClassDevsExHandle.cs b/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeSetupDiClassDevsExHandle.cs deleted file mode 100644 index 2cab614..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Safe Handles/SafeSetupDiClassDevsExHandle.cs +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System.Security; - -namespace Alphaleonis.Win32.Filesystem -{ - internal static partial class NativeMethods - { - /// Represents a wrapper class for a handle used by the SetupDiGetClassDevs/SetupDiDestroyDeviceInfoList Win32 API functions. - [SecurityCritical] - internal sealed class SafeSetupDiClassDevsExHandle : SafeHandleZeroOrMinusOneIsInvalid - { - /// Initializes a new instance of the class. - public SafeSetupDiClassDevsExHandle() - : base(true) - { - } - - protected override bool ReleaseHandle() - { - return SetupDiDestroyDeviceInfoList(handle); - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Shell32.cs b/FolderMonitor/AlphaFS/Filesystem/Shell32.cs deleted file mode 100644 index 74e1a3f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Shell32.cs +++ /dev/null @@ -1,842 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Provides access to a file system object, using Shell32. - public static class Shell32 - { - /// Provides information for the IQueryAssociations interface methods, used by Shell32. - [Flags] - public enum AssociationAttributes - { - /// None. - None = 0, - - /// Instructs not to map CLSID values to ProgID values. - InitNoRemapClsid = 1, - - /// Identifies the value of the supplied file parameter (3rd parameter of function GetFileAssociation()) as an executable file name. - /// If this flag is not set, the root key will be set to the ProgID associated with the .exe key instead of the executable file's ProgID. - InitByExeName = 2, - - /// Specifies that when an IQueryAssociation method does not find the requested value under the root key, it should attempt to retrieve the comparable value from the * subkey. - InitDefaultToStar = 4, - - /// Specifies that when an IQueryAssociation method does not find the requested value under the root key, it should attempt to retrieve the comparable value from the Folder subkey. - InitDefaultToFolder = 8, - - /// Specifies that only HKEY_CLASSES_ROOT should be searched, and that HKEY_CURRENT_USER should be ignored. - NoUserSettings = 16, - - /// Specifies that the return string should not be truncated. Instead, return an error value and the required size for the complete string. - NoTruncate = 32, - - /// - /// Instructs IQueryAssociations methods to verify that data is accurate. - /// This setting allows IQueryAssociations methods to read data from the user's hard disk for verification. - /// For example, they can check the friendly name in the registry against the one stored in the .exe file. - /// - /// Setting this flag typically reduces the efficiency of the method. - Verify = 64, - - /// - /// Instructs IQueryAssociations methods to ignore Rundll.exe and return information about its target. - /// Typically IQueryAssociations methods return information about the first .exe or .dll in a command string. - /// If a command uses Rundll.exe, setting this flag tells the method to ignore Rundll.exe and return information about its target. - /// - RemapRunDll = 128, - - /// Instructs IQueryAssociations methods not to fix errors in the registry, such as the friendly name of a function not matching the one found in the .exe file. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "FixUps")] - NoFixUps = 256, - - /// Specifies that the BaseClass value should be ignored. - IgnoreBaseClass = 512, - - /// Specifies that the "Unknown" ProgID should be ignored; instead, fail. - /// Introduced in Windows 7. - InitIgnoreUnknown = 1024, - - /// Specifies that the supplied ProgID should be mapped using the system defaults, rather than the current user defaults. - /// Introduced in Windows 8. - InitFixedProgId = 2048, - - /// Specifies that the value is a protocol, and should be mapped using the current user defaults. - /// Introduced in Windows 8. - IsProtocol = 4096 - } - - - //internal enum AssociationData - //{ - // MsiDescriptor = 1, - // NoActivateHandler = 2 , - // QueryClassStore = 3, - // HasPerUserAssoc = 4, - // EditFlags = 5, - // Value = 6 - //} - - - //internal enum AssociationKey - //{ - // ShellExecClass = 1, - // App = 2, - // Class = 3, - // BaseClass = 4 - //} - - - /// ASSOCSTR enumeration - Used by the AssocQueryString() function to define the type of string that is to be returned. - public enum AssociationString - { - /// None. - None = 0, - - /// A command string associated with a Shell verb. - Command = 1, - - /// - /// An executable from a Shell verb command string. - /// For example, this string is found as the (Default) value for a subkey such as HKEY_CLASSES_ROOT\ApplicationName\shell\Open\command. - /// If the command uses Rundll.exe, set the flag in the attributes parameter of IQueryAssociations::GetString to retrieve the target executable. - /// - Executable = 2, - - /// The friendly name of a document type. - FriendlyDocName = 3, - - /// The friendly name of an executable file. - FriendlyAppName = 4, - - /// Ignore the information associated with the open subkey. - NoOpen = 5, - - /// Look under the ShellNew subkey. - ShellNewValue = 6, - - /// A template for DDE commands. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dde")] - DdeCommand = 7, - - /// The DDE command to use to create a process. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dde")] - DdeIfExec = 8, - - /// The application name in a DDE broadcast. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dde")] - DdeApplication = 9, - - /// The topic name in a DDE broadcast. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dde")] - DdeTopic = 10, - - /// - /// Corresponds to the InfoTip registry value. - /// Returns an info tip for an item, or list of properties in the form of an IPropertyDescriptionList from which to create an info tip, such as when hovering the cursor over a file name. - /// The list of properties can be parsed with PSGetPropertyDescriptionListFromString. - /// - InfoTip = 11, - - /// - /// Corresponds to the QuickTip registry value. This is the same as , except that it always returns a list of property names in the form of an IPropertyDescriptionList. - /// The difference between this value and is that this returns properties that are safe for any scenario that causes slow property retrieval, such as offline or slow networks. - /// Some of the properties returned from might not be appropriate for slow property retrieval scenarios. - /// The list of properties can be parsed with PSGetPropertyDescriptionListFromString. - /// - QuickTip = 12, - - /// - /// Corresponds to the TileInfo registry value. Contains a list of properties to be displayed for a particular file type in a Windows Explorer window that is in tile view. - /// This is the same as , but, like , it also returns a list of property names in the form of an IPropertyDescriptionList. - /// The list of properties can be parsed with PSGetPropertyDescriptionListFromString. - /// - TileInfo = 13, - - /// - /// Describes a general type of MIME file association, such as image and bmp, - /// so that applications can make general assumptions about a specific file type. - /// - ContentType = 14, - - /// - /// Returns the path to the icon resources to use by default for this association. - /// Positive numbers indicate an index into the dll's resource table, while negative numbers indicate a resource ID. - /// An example of the syntax for the resource is "c:\myfolder\myfile.dll,-1". - /// - DefaultIcon = 15, - - /// - /// For an object that has a Shell extension associated with it, - /// you can use this to retrieve the CLSID of that Shell extension object by passing a string representation - /// of the IID of the interface you want to retrieve as the pwszExtra parameter of IQueryAssociations::GetString. - /// For example, if you want to retrieve a handler that implements the IExtractImage interface, - /// you would specify "{BB2E617C-0920-11d1-9A0B-00C04FC2D6C1}", which is the IID of IExtractImage. - /// - ShellExtension = 16, - - /// - /// For a verb invoked through COM and the IDropTarget interface, you can use this flag to retrieve the IDropTarget object's CLSID. - /// This CLSID is registered in the DropTarget subkey. - /// The verb is specified in the supplied file parameter in the call to IQueryAssociations::GetString. - /// - DropTarget = 17, - - /// - /// For a verb invoked through COM and the IExecuteCommand interface, you can use this flag to retrieve the IExecuteCommand object's CLSID. - /// This CLSID is registered in the verb's command subkey as the DelegateExecute entry. - /// The verb is specified in the supplied file parameter in the call to IQueryAssociations::GetString. - /// - DelegateExecute = 18, - - /// (No description available on MSDN) - /// Introduced in Windows 8. - SupportedUriProtocols = 19, - - /// The maximum defined value, used for validation purposes. - Max = 20 - } - - - /// Shell32 FileAttributes structure, used to retrieve the different types of a file system object. - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] - [Flags] - public enum FileAttributes - { - /// 0x000000000 - Get file system object large icon. - /// The flag must also be set. - LargeIcon = 0, - - /// 0x000000001 - Get file system object small icon. - /// The flag must also be set. - SmallIcon = 1, - - /// 0x000000002 - Get file system object open icon. - /// A container object displays an open icon to indicate that the container is open. - /// The and/or flag must also be set. - OpenIcon = 2, - - /// 0x000000004 - Get file system object Shell-sized icon. - /// If this attribute is not specified the function sizes the icon according to the system metric values. - ShellIconSize = 4, - - /// 0x000000008 - Get file system object by its PIDL. - /// Indicate that the given file contains the address of an ITEMIDLIST structure rather than a path name. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pidl")] - Pidl = 8, - - /// 0x000000010 - Indicates that the given file should not be accessed. Rather, it should act as if the given file exists and use the supplied attributes. - /// This flag cannot be combined with the , or attributes. - UseFileAttributes = 16, - - /// 0x000000020 - Apply the appropriate overlays to the file's icon. - /// The flag must also be set. - AddOverlays = 32, - - /// 0x000000040 - Returns the index of the overlay icon. - /// The value of the overlay index is returned in the upper eight bits of the iIcon member of the structure specified by psfi. - OverlayIndex = 64, - - /// 0x000000100 - Retrieve the handle to the icon that represents the file and the index of the icon within the system image list. The handle is copied to the member of the structure, and the index is copied to the member. - Icon = 256, - - /// 0x000000200 - Retrieve the display name for the file. The name is copied to the member of the structure. - /// The returned display name uses the long file name, if there is one, rather than the 8.3 form of the file name. - DisplayName = 512, - - /// 0x000000400 - Retrieve the string that describes the file's type. - TypeName = 1024, - - /// 0x000000800 - Retrieve the item attributes. The attributes are copied to the member of the structure. - /// Will touch every file, degrading performance. - Attributes = 2048, - - /// 0x000001000 - Retrieve the name of the file that contains the icon representing the file specified by pszPath. The name of the file containing the icon is copied to the member of the structure. The icon's index is copied to that structure's member. - IconLocation = 4096, - - /// 0x000002000 - Retrieve the type of the executable file if pszPath identifies an executable file. - /// This flag cannot be specified with any other attributes. - ExeType = 8192, - - /// 0x000004000 - Retrieve the index of a system image list icon. - SysIconIndex = 16384, - - /// 0x000008000 - Add the link overlay to the file's icon. - /// The flag must also be set. - LinkOverlay = 32768, - - /// 0x000010000 - Blend the file's icon with the system highlight color. - Selected = 65536, - - /// 0x000020000 - Modify to indicate that contains specific attributes that are desired. - /// This flag cannot be specified with the attribute. Will touch every file, degrading performance. - AttributesSpecified = 131072 - } - - - /// SHFILEINFO structure, contains information about a file system object. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Sh")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sh")] - [SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - [SuppressMessage("Microsoft.Performance", "CA1815:OverrideEqualsAndOperatorEqualsOnValueTypes")] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - public struct FileInfo - { - /// A handle to the icon that represents the file. - /// Caller is responsible for destroying this handle with DestroyIcon() when no longer needed. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - public readonly IntPtr IconHandle; - - /// The index of the icon image within the system image list. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - public int IconIndex; - - /// An array of values that indicates the attributes of the file object. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - [MarshalAs(UnmanagedType.U4)] - public readonly GetAttributesOf Attributes; - - /// The name of the file as it appears in the Windows Shell, or the path and file name of the file that contains the icon representing the file. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = NativeMethods.MaxPath)] - public string DisplayName; - - /// The type of file. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)] - public string TypeName; - } - - - /// SFGAO - Attributes that can be retrieved from a file system object. - [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags"), SuppressMessage("Microsoft.Design", "CA1034:NestedTypesShouldNotBeVisible")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Sh")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Sh")] - [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")] - [Flags] - public enum GetAttributesOf - { - /// 0x00000000 - None. - None = 0, - - /// 0x00000001 - The specified items can be copied. - CanCopy = 1, - - /// 0x00000002 - The specified items can be moved. - CanMove = 2, - - /// 0x00000004 - Shortcuts can be created for the specified items. - CanLink = 4, - - /// 0x00000008 - The specified items can be bound to an IStorage object through IShellFolder::BindToObject. For more information about namespace manipulation capabilities, see IStorage. - Storage = 8, - - /// 0x00000010 - The specified items can be renamed. Note that this value is essentially a suggestion; not all namespace clients allow items to be renamed. However, those that do must have this attribute set. - CanRename = 16, - - /// 0x00000020 - The specified items can be deleted. - CanDelete = 32, - - /// 0x00000040 - The specified items have property sheets. - HasPropSheet = 64, - - /// 0x00000100 - The specified items are drop targets. - DropTarget = 256, - - /// 0x00001000 - The specified items are system items. - /// Windows 7 and later. - System = 4096, - - /// 0x00002000 - The specified items are encrypted and might require special presentation. - Encrypted = 8192, - - /// 0x00004000 - Accessing the item (through IStream or other storage interfaces) is expected to be a slow operation. - IsSlow = 16384, - - /// 0x00008000 - The specified items are shown as dimmed and unavailable to the user. - Ghosted = 32768, - - /// 0x00010000 - The specified items are shortcuts. - Link = 65536, - - /// 0x00020000 - The specified objects are shared. - Share = 131072, - - /// 0x00040000 - The specified items are read-only. In the case of folders, this means that new items cannot be created in those folders. - ReadOnly = 262144, - - /// 0x00080000 - The item is hidden and should not be displayed unless the Show hidden files and folders option is enabled in Folder Settings. - Hidden = 524288, - - /// 0x00100000 - The items are nonenumerated items and should be hidden. They are not returned through an enumerator such as that created by the IShellFolder::EnumObjects method. - NonEnumerated = 1048576, - - /// 0x00200000 - The items contain new content, as defined by the particular application. - NewContent = 2097152, - - /// 0x00400000 - Indicates that the item has a stream associated with it. - Stream = 4194304, - - /// 0x00800000 - Children of this item are accessible through IStream or IStorage. - StorageAncestor = 8388608, - - /// 0x01000000 - When specified as input, instructs the folder to validate that the items contained in a folder or Shell item array exist. - Validate = 16777216, - - /// 0x02000000 - The specified items are on removable media or are themselves removable devices. - Removable = 33554432, - - /// 0x04000000 - The specified items are compressed. - Compressed = 67108864, - - /// 0x08000000 - The specified items can be hosted inside a web browser or Windows Explorer frame. - Browsable = 134217728, - - /// 0x10000000 - The specified folders are either file system folders or contain at least one descendant (child, grandchild, or later) that is a file system folder. - FileSysAncestor = 268435456, - - /// 0x20000000 - The specified items are folders. - Folder = 536870912, - - /// 0x40000000 - The specified folders or files are part of the file system (that is, they are files, directories, or root directories). - FileSystem = 1073741824, - - /// 0x80000000 - The specified folders have subfolders. - [SuppressMessage("Microsoft.Naming", "CA1702:CompoundWordsShouldBeCasedCorrectly", MessageId = "SubFolder")] - HasSubFolder = unchecked ((int)0x80000000) - } - - - /// Used by method UrlIs() to define a URL type. - public enum UrlType - { - /// Is the URL valid? - IsUrl = 0, - - /// Is the URL opaque? - IsOpaque = 1, - - /// Is the URL a URL that is not typically tracked in navigation history? - IsNoHistory = 2, - - /// Is the URL a file URL? - IsFileUrl = 3, - - /// Attempt to determine a valid scheme for the URL. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Appliable")] - IsAppliable = 4, - - /// Does the URL string end with a directory? - IsDirectory = 5, - - /// Does the URL have an appended query string? - IsHasQuery = 6 - } - - - #region Methods - - /// Destroys an icon and frees any memory the icon occupied. - /// An handle to an icon. - public static void DestroyIcon(IntPtr iconHandle) - { - if (IntPtr.Zero != iconHandle) - NativeMethods.DestroyIcon(iconHandle); - } - - - /// Gets the file or protocol that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related string from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileAssociation(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.Executable); - } - - - /// Gets the content-type that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related content-type from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileContentType(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.ContentType); - } - - - /// Gets the default icon that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related default icon from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileDefaultIcon(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.DefaultIcon); - } - - - /// Gets the friendly application name that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related friendly application name from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileFriendlyAppName(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.InitByExeName, AssociationString.FriendlyAppName); - } - - - /// Gets the friendly document name that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related friendly document name from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileFriendlyDocName(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.FriendlyDocName); - } - - - /// Gets an handle to the Shell icon that represents the file. - /// Caller is responsible for destroying this handle with DestroyIcon() when no longer needed. - /// - /// The path to the file system object which should not exceed maximum path length. Both absolute and - /// relative paths are valid. - /// - /// - /// Icon size or . Can also be combined - /// with and others. - /// - /// An handle to the Shell icon that represents the file, or IntPtr.Zero on failure. - [SecurityCritical] - public static IntPtr GetFileIcon(string filePath, FileAttributes iconAttributes) - { - if (Utils.IsNullOrWhiteSpace(filePath)) - return IntPtr.Zero; - - var fileInfo = GetFileInfoCore(filePath, System.IO.FileAttributes.Normal, FileAttributes.Icon | iconAttributes, true, true); - return fileInfo.IconHandle == IntPtr.Zero ? IntPtr.Zero : fileInfo.IconHandle; - } - - - /// Retrieves information about an object in the file system, such as a file, folder, directory, or drive root. - /// A struct instance. - /// - /// You should call this function from a background thread. - /// Failure to do so could cause the UI to stop responding. - /// Unicode path are supported. - /// - /// The path to the file system object which should not exceed the maximum path length. Both absolute and relative paths are valid. - /// A attribute. - /// One ore more attributes. - /// - /// suppress any Exception that might be thrown as a result from a failure, - /// such as ACLs protected directories or non-accessible reparse points. - /// - [SecurityCritical] - public static FileInfo GetFileInfo(string filePath, System.IO.FileAttributes attributes, FileAttributes fileAttributes, bool continueOnException) - { - return GetFileInfoCore(filePath, attributes, fileAttributes, true, continueOnException); - } - - - /// Retrieves an instance of containing information about the specified file. - /// A path to the file. - /// A class instance. - [SecurityCritical] - public static Shell32Info GetShell32Info(string path) - { - return new Shell32Info(path); - } - - /// Retrieves an instance of containing information about the specified file. - /// A path to the file. - /// Indicates the format of the path parameter(s). - /// A class instance. - [SecurityCritical] - public static Shell32Info GetShell32Info(string path, PathFormat pathFormat) - { - return new Shell32Info(path, pathFormat); - } - - - /// Gets the "Open With" command that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related "Open With" command from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileOpenWithAppName(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.FriendlyAppName); - } - - - /// Gets the Shell command that is associated with from the registry. - /// A path to the file. - /// The associated file- or protocol-related Shell command from the registry or string.Empty if no association can be found. - [SecurityCritical] - public static string GetFileVerbCommand(string path) - { - return GetFileAssociationCore(path, AssociationAttributes.Verify, AssociationString.Command); - } - - - /// Converts a file URL to a Microsoft MS-DOS path. - /// The file URL. - /// - /// The Microsoft MS-DOS path. If no path can be created, string.Empty is returned. - /// If is , will also be returned. - /// - [SecurityCritical] - internal static string PathCreateFromUrl(string urlPath) - { - if (urlPath == null) - return null; - - var buffer = new StringBuilder(NativeMethods.MaxPathUnicode); - var bufferSize = (uint) buffer.Capacity; - - var lastError = NativeMethods.PathCreateFromUrl(urlPath, buffer, ref bufferSize, 0); - - // Don't throw exception, but return string.Empty; - return lastError == Win32Errors.S_OK ? buffer.ToString() : string.Empty; - } - - - /// Creates a path from a file URL. - /// The URL. - /// - /// The file path. If no path can be created, string.Empty is returned. - /// If is , will also be returned. - /// - [SecurityCritical] - internal static string PathCreateFromUrlAlloc(string urlPath) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - if (urlPath == null) - return null; - - StringBuilder buffer; - var lastError = NativeMethods.PathCreateFromUrlAlloc(urlPath, out buffer, 0); - - // Don't throw exception, but return string.Empty; - return lastError == Win32Errors.S_OK ? buffer.ToString() : string.Empty; - } - - - /// Determines whether a path to a file system object such as a file or folder is valid. - /// The full path of maximum length the maximum path length to the object to verify. - /// if the file exists; otherwise - [SuppressMessage("Microsoft.Performance", "CA1804:RemoveUnusedLocals", MessageId = "lastError")] - [SecurityCritical] - public static bool PathFileExists(string path) - { - // PathFileExists() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - return !Utils.IsNullOrWhiteSpace(path) && NativeMethods.PathFileExists(Path.GetFullPathCore(null, path, GetFullPathOptions.AsLongPath | GetFullPathOptions.FullCheck | GetFullPathOptions.ContinueOnNonExist)); - } - - - /// Tests whether a URL is a specified type. - /// The URL. - /// - /// - /// For all but one of the URL types, UrlIs returns if the URL is the specified type, or otherwise. - /// If UrlIs is set to , UrlIs will attempt to determine the URL scheme. - /// If the function is able to determine a scheme, it returns , or otherwise. - /// - [SecurityCritical] - internal static bool UrlIs(string url, UrlType urlType) - { - return NativeMethods.UrlIs(url, urlType); - } - - - /// Converts a Microsoft MS-DOS path to a canonicalized URL. - /// The full MS-DOS path of maximum length . - /// - /// The URL. If no URL can be created string.Empty is returned. - /// If is , will also be returned. - /// - [SecurityCritical] - internal static string UrlCreateFromPath(string path) - { - if (path == null) - return null; - - // UrlCreateFromPath does not support extended paths. - var pathRp = Path.GetRegularPathCore(path, GetFullPathOptions.CheckInvalidPathChars, false); - - var buffer = new StringBuilder(NativeMethods.MaxPathUnicode); - var bufferSize = (uint) buffer.Capacity; - - var lastError = NativeMethods.UrlCreateFromPath(pathRp, buffer, ref bufferSize, 0); - - // Don't throw exception, but return null; - var url = buffer.ToString(); - if (Utils.IsNullOrWhiteSpace(url)) - url = string.Empty; - - return lastError == Win32Errors.S_OK ? url : string.Empty; - } - - - /// Tests a URL to determine if it is a file URL. - /// The URL. - /// if the URL is a file URL, or otherwise. - [SecurityCritical] - internal static bool UrlIsFileUrl(string url) - { - return NativeMethods.UrlIs(url, UrlType.IsFileUrl); - } - - - /// Returns whether a URL is a URL that browsers typically do not include in navigation history. - /// The URL. - /// if the URL is a URL that is not included in navigation history, or otherwise. - [SecurityCritical] - internal static bool UrlIsNoHistory(string url) - { - return NativeMethods.UrlIs(url, UrlType.IsNoHistory); - } - - - /// Returns whether a URL is opaque. - /// The URL. - /// if the URL is opaque, or otherwise. - [SecurityCritical] - internal static bool UrlIsOpaque(string url) - { - return NativeMethods.UrlIs(url, UrlType.IsOpaque); - } - - - #region Internal Methods - - /// Searches for and retrieves a file or protocol association-related string from the registry. - /// A path to a file. - /// One or more attributes. Only one "InitXXX" attribute can be used. - /// A attribute. - /// The associated file- or protocol-related string from the registry or string.Empty if no association can be found. - /// - [SecurityCritical] - private static string GetFileAssociationCore(string path, AssociationAttributes attributes, AssociationString associationType) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - attributes = attributes | AssociationAttributes.NoTruncate | AssociationAttributes.RemapRunDll; - - uint bufferSize = NativeMethods.MaxPath; - StringBuilder buffer; - uint retVal; - - do - { - buffer = new StringBuilder((int)bufferSize); - - // AssocQueryString() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-02-05: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - // However, the function fails when using Unicode format. - - retVal = NativeMethods.AssocQueryString(attributes, associationType, path, null, buffer, out bufferSize); - - // No Exception is thrown, just return empty string on error. - - //switch (retVal) - //{ - // // 0x80070483: No application is associated with the specified file for this operation. - // case 2147943555: - // case Win32Errors.E_POINTER: - // case Win32Errors.S_OK: - // break; - - // default: - // NativeError.ThrowException(retVal); - // break; - //} - - } while (retVal == Win32Errors.E_POINTER); - - return buffer.ToString(); - } - - - /// Retrieve information about an object in the file system, such as a file, folder, directory, or drive root. - /// A struct instance. - /// - /// You should call this function from a background thread. - /// Failure to do so could cause the UI to stop responding. - /// Unicode path are not supported. - /// - /// The path to the file system object which should not exceed the maximum path length in length. Both absolute and relative paths are valid. - /// A attribute. - /// A attribute. - /// Checks that the path contains only valid path-characters. - /// - /// suppress any Exception that might be thrown as a result from a failure, - /// such as ACLs protected directories or non-accessible reparse points. - /// - [SecurityCritical] - internal static FileInfo GetFileInfoCore(string path, System.IO.FileAttributes attributes, FileAttributes fileAttributes, bool checkInvalidPathChars, bool continueOnException) - { - // Prevent possible crash. - var fileInfo = new FileInfo - { - DisplayName = string.Empty, - TypeName = string.Empty, - IconIndex = 0 - }; - - if (!Utils.IsNullOrWhiteSpace(path)) - { - // ShGetFileInfo() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - // However, the function fails when using Unicode format. - - var shGetFileInfo = NativeMethods.ShGetFileInfo(Path.GetRegularPathCore(path, checkInvalidPathChars ? GetFullPathOptions.CheckInvalidPathChars : 0, false), attributes, out fileInfo, (uint) Marshal.SizeOf(fileInfo), fileAttributes); - - if (shGetFileInfo == IntPtr.Zero && !continueOnException) - NativeError.ThrowException(Marshal.GetLastWin32Error(), path); - } - - return fileInfo; - } - - #endregion // Internal Methods - - #endregion // Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Shell32Info.cs b/FolderMonitor/AlphaFS/Filesystem/Shell32Info.cs deleted file mode 100644 index d958738..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Shell32Info.cs +++ /dev/null @@ -1,337 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Contains Shell32 information about a file. - [SerializableAttribute] - [SecurityCritical] - public sealed class Shell32Info - { - #region Constructors - - /// Initializes a Shell32Info instance. - /// Shell32 is limited to MAX_PATH length. - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - /// - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - public Shell32Info(string fileName) : this(fileName, PathFormat.RelativePath) - { - } - - /// Initializes a Shell32Info instance. - /// Shell32 is limited to MAX_PATH length. - /// This constructor does not check if a file exists. This constructor is a placeholder for a string that is used to access the file in subsequent operations. - /// - /// The fully qualified name of the new file, or the relative file name. Do not end the path with the directory separator character. - /// Indicates the format of the path parameter(s). - public Shell32Info(string fileName, PathFormat pathFormat) - { - if (Utils.IsNullOrWhiteSpace(fileName)) - throw new ArgumentNullException("fileName"); - - // Shell32 is limited to MAX_PATH length. - // Get a full path of regular format. - - FullPath = Path.GetExtendedLengthPathCore(null, fileName, pathFormat, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - Initialize(); - } - - #endregion // Constructors - - - #region Methods - - /// Gets an handle to the Shell icon that represents the file. - /// Icon size or . Can also be combined with and others. - /// An handle to the Shell icon that represents the file. - /// Caller is responsible for destroying this handle with DestroyIcon() when no longer needed. - [SecurityCritical] - public IntPtr GetIcon(Shell32.FileAttributes iconAttributes) - { - return Shell32.GetFileIcon(FullPath, iconAttributes); - } - - - /// Gets the Shell command association from the registry. - /// The shell verb. - /// - /// Returns the associated file- or protocol-related Shell command from the registry or string.Empty if no association can be - /// found. - /// - [SecurityCritical] - public string GetVerbCommand(string shellVerb) - { - return GetString(_iQaNone, Shell32.AssociationString.Command, shellVerb); - } - - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - private static string GetString(NativeMethods.IQueryAssociations iQa, Shell32.AssociationString assocString, string shellVerb) - { - // GetString() throws Exceptions. - try - { - // Use a large buffer to prevent calling this function twice. - var size = NativeMethods.DefaultFileBufferSize; - var buffer = new StringBuilder(size); - - iQa.GetString(Shell32.AssociationAttributes.NoTruncate | Shell32.AssociationAttributes.RemapRunDll, assocString, shellVerb, buffer, out size); - - return buffer.ToString(); - } - catch - { - return string.Empty; - } - } - - - private NativeMethods.IQueryAssociations _iQaNone; // Retrieve info from Shell. - private NativeMethods.IQueryAssociations _iQaByExe; // Retrieve info from exe file. - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - private void Initialize() - { - if (Initialized) - return; - - var iidIQueryAssociations = new Guid(NativeMethods.QueryAssociationsGuid); - - if (NativeMethods.AssocCreate(NativeMethods.ClsidQueryAssociations, ref iidIQueryAssociations, out _iQaNone) == Win32Errors.S_OK) - { - try - { - _iQaNone.Init(Shell32.AssociationAttributes.None, FullPath, IntPtr.Zero, IntPtr.Zero); - - if (NativeMethods.AssocCreate(NativeMethods.ClsidQueryAssociations, ref iidIQueryAssociations, out _iQaByExe) == Win32Errors.S_OK) - { - _iQaByExe.Init(Shell32.AssociationAttributes.InitByExeName, FullPath, IntPtr.Zero, IntPtr.Zero); - - Initialized = true; - } - } - catch - { - } - } - } - - - /// Refreshes the state of the object. - [SecurityCritical] - public void Refresh() - { - Association = Command = ContentType = DdeApplication = DefaultIcon = FriendlyAppName = FriendlyDocName = OpenWithAppName = null; - Attributes = Shell32.GetAttributesOf.None; - Initialized = false; - Initialize(); - } - - - /// Returns the path as a string. - /// The path. - public override string ToString() - { - return FullPath; - } - - #endregion // Methods - - - #region Properties - - private string _association; - - /// Gets the Shell file or protocol association from the registry. - public string Association - { - get - { - if (_association == null) - _association = GetString(_iQaNone, Shell32.AssociationString.Executable, null); - - return _association; - } - - private set { _association = value; } - } - - - private Shell32.GetAttributesOf _attributes; - - /// The attributes of the file object. - public Shell32.GetAttributesOf Attributes - { - get - { - if (_attributes == Shell32.GetAttributesOf.None) - { - var fileInfo = Shell32.GetFileInfoCore(FullPath, FileAttributes.Normal, Shell32.FileAttributes.Attributes, false, true); - _attributes = fileInfo.Attributes; - } - - return _attributes; - } - - private set { _attributes = value; } - } - - - private string _command; - - /// Gets the Shell command association from the registry. - public string Command - { - get - { - if (_command == null) - _command = GetString(_iQaNone, Shell32.AssociationString.Command, null); - - return _command; - } - - private set { _command = value; } - } - - - private string _contentType; - - /// Gets the Shell command association from the registry. - public string ContentType - { - get - { - if (_contentType == null) - _contentType = GetString(_iQaNone, Shell32.AssociationString.ContentType, null); - - return _contentType; - } - - private set { _contentType = value; } - } - - - private string _ddeApplication; - - /// Gets the Shell DDE association from the registry. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dde")] - public string DdeApplication - { - get - { - if (_ddeApplication == null) - _ddeApplication = GetString(_iQaNone, Shell32.AssociationString.DdeApplication, null); - - return _ddeApplication; - } - - private set { _ddeApplication = value; } - } - - - private string _defaultIcon; - - /// Gets the Shell default icon association from the registry. - public string DefaultIcon - { - get - { - if (_defaultIcon == null) - _defaultIcon = GetString(_iQaNone, Shell32.AssociationString.DefaultIcon, null); - - return _defaultIcon; - } - - private set { _defaultIcon = value; } - } - - - /// Represents the fully qualified path of the file. - public string FullPath { get; private set; } - - - private string _friendlyAppName; - - /// Gets the Shell friendly application name association from the registry. - public string FriendlyAppName - { - get - { - if (_friendlyAppName == null) - _friendlyAppName = GetString(_iQaByExe, Shell32.AssociationString.FriendlyAppName, null); - - return _friendlyAppName; - } - - private set { _friendlyAppName = value; } - } - - - private string _friendlyDocName; - - /// Gets the Shell friendly document name association from the registry. - public string FriendlyDocName - { - get - { - if (_friendlyDocName == null) - _friendlyDocName = GetString(_iQaNone, Shell32.AssociationString.FriendlyDocName, null); - - return _friendlyDocName; - } - - private set { _friendlyDocName = value; } - } - - - /// Reflects the initialization state of the instance. - internal bool Initialized { get; set; } - - - private string _openWithAppName; - - /// Gets the Shell "Open With" command association from the registry. - public string OpenWithAppName - { - get - { - if (_openWithAppName == null) - _openWithAppName = GetString(_iQaNone, Shell32.AssociationString.FriendlyAppName, null); - - return _openWithAppName; - } - - private set { _openWithAppName = value; } - } - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/SymbolicLinkTargetInfo.cs b/FolderMonitor/AlphaFS/Filesystem/SymbolicLinkTargetInfo.cs deleted file mode 100644 index 4e47790..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/SymbolicLinkTargetInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Filesystem -{ - /// Represents information about a symbolic link. - public class SymbolicLinkTargetInfo : LinkTargetInfo - { - internal SymbolicLinkTargetInfo(string substituteName, string printName, SymbolicLinkType type) : base(substituteName, printName) - { - LinkType = type; - } - - /// Gets the type of the link. - /// The type of the link. - public SymbolicLinkType LinkType { get; private set; } - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/Volume.cs b/FolderMonitor/AlphaFS/Filesystem/Volume.cs deleted file mode 100644 index 7c42636..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/Volume.cs +++ /dev/null @@ -1,1146 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Static class providing utility methods for working with Microsoft Windows devices and volumes. - public static class Volume - { - #region DosDevice - - #region DefineDosDevice - - /// Defines, redefines, or deletes MS-DOS device names. - /// An MS-DOS device name string specifying the device the function is defining, redefining, or deleting. - /// An MS-DOS path that will implement this device. - - [SecurityCritical] - public static void DefineDosDevice(string deviceName, string targetPath) - { - DefineDosDeviceCore(true, deviceName, targetPath, DosDeviceAttributes.None, false); - } - - /// Defines, redefines, or deletes MS-DOS device names. - /// - /// An MS-DOS device name string specifying the device the function is defining, redefining, or deleting. - /// - /// - /// >An MS-DOS path that will implement this device. If parameter has the - /// flag specified, is used as is. - /// - /// - /// The controllable aspects of the DefineDosDevice function, flags which will be combined with the - /// default. - /// - [SecurityCritical] - public static void DefineDosDevice(string deviceName, string targetPath, DosDeviceAttributes deviceAttributes) - { - DefineDosDeviceCore(true, deviceName, targetPath, deviceAttributes, false); - } - - #endregion // DefineDosDevice - - #region DeleteDosDevice - - /// Deletes an MS-DOS device name. - /// An MS-DOS device name specifying the device to delete. - [SecurityCritical] - public static void DeleteDosDevice(string deviceName) - { - DefineDosDeviceCore(false, deviceName, null, DosDeviceAttributes.RemoveDefinition, false); - } - - /// Deletes an MS-DOS device name. - /// An MS-DOS device name string specifying the device to delete. - /// - /// A pointer to a path string that will implement this device. The string is an MS-DOS path string unless the - /// flag is specified, in which case this string is a path string. - /// - [SecurityCritical] - public static void DeleteDosDevice(string deviceName, string targetPath) - { - DefineDosDeviceCore(false, deviceName, targetPath, DosDeviceAttributes.RemoveDefinition, false); - } - - /// Deletes an MS-DOS device name. - /// An MS-DOS device name string specifying the device to delete. - /// - /// A pointer to a path string that will implement this device. The string is an MS-DOS path string unless the - /// flag is specified, in which case this string is a path string. - /// - /// - /// Only delete MS-DOS device on an exact name match. If is , - /// must be the same path used to create the mapping. - /// - [SecurityCritical] - public static void DeleteDosDevice(string deviceName, string targetPath, bool exactMatch) - { - DefineDosDeviceCore(false, deviceName, targetPath, DosDeviceAttributes.RemoveDefinition, exactMatch); - } - - /// Deletes an MS-DOS device name. - /// An MS-DOS device name string specifying the device to delete. - /// - /// A pointer to a path string that will implement this device. The string is an MS-DOS path string unless the - /// flag is specified, in which case this string is a path string. - /// - /// - /// The controllable aspects of the DefineDosDevice function flags which will be combined with the - /// default. - /// - /// - /// Only delete MS-DOS device on an exact name match. If is , - /// must be the same path used to create the mapping. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static void DeleteDosDevice(string deviceName, string targetPath, DosDeviceAttributes deviceAttributes, bool exactMatch) - { - DefineDosDeviceCore(false, deviceName, targetPath, deviceAttributes, exactMatch); - } - - #endregion // DeleteDosDevice - - #region QueryAllDosDevices - - /// Retrieves a list of all existing MS-DOS device names. - /// An with one or more existing MS-DOS device names. - [SecurityCritical] - public static IEnumerable QueryAllDosDevices() - { - return QueryDosDevice(null, null); - } - - /// Retrieves a list of all existing MS-DOS device names. - /// - /// (Optional, default: ) An MS-DOS device name string specifying the target of the query. This parameter can be - /// "sort". In that case a sorted list of all existing MS-DOS device names is returned. This parameter can be . - /// In that case, the function will store a list of all existing MS-DOS device names into the buffer. - /// - /// An with or more existing MS-DOS device names. - [SecurityCritical] - public static IEnumerable QueryAllDosDevices(string deviceName) - { - return QueryDosDevice(null, deviceName); - } - - #endregion // QueryAllDosDevices - - #region QueryDosDevice - - /// - /// Retrieves information about MS-DOS device names. The function can obtain the current mapping for a particular MS-DOS device name. - /// The function can also obtain a list of all existing MS-DOS device names. - /// - /// - /// An MS-DOS device name string, or part of, specifying the target of the query. This parameter can be . In that - /// case, the QueryDosDevice function will store a list of all existing MS-DOS device names into the buffer. - /// - /// - /// (Optional, default: ) If options[0] = a sorted list will be returned. - /// - /// An with one or more existing MS-DOS device names. - [SecurityCritical] - public static IEnumerable QueryDosDevice(string deviceName, params string[] options) - { - // deviceName is allowed to be null. - // The deviceName cannot have a trailing backslash. - deviceName = Path.RemoveTrailingDirectorySeparator(deviceName, false); - - var searchFilter = deviceName != null; - - // Only process options if a device is supplied. - if (searchFilter) - { - // Check that at least one "options[]" has something to say. If so, rebuild them. - options = options != null && options.Any() ? new[] { deviceName, options[0] } : new[] { deviceName, string.Empty }; - - deviceName = null; - } - - // Choose sorted output. - var doSort = options != null && - options.Any(s => s != null && s.Equals("sort", StringComparison.OrdinalIgnoreCase)); - - // Start with a larger buffer when using a searchFilter. - var bufferSize = (uint) (searchFilter || doSort || (options == null) ? 8*NativeMethods.DefaultFileBufferSize : 256); - uint bufferResult = 0; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - while (bufferResult == 0) - { - var cBuffer = new char[bufferSize]; - - // QueryDosDevice() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-01-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - bufferResult = NativeMethods.QueryDosDevice(deviceName, cBuffer, bufferSize); - var lastError = Marshal.GetLastWin32Error(); - - if (bufferResult == 0) - switch ((uint) lastError) - { - case Win32Errors.ERROR_MORE_DATA: - case Win32Errors.ERROR_INSUFFICIENT_BUFFER: - bufferSize *= 2; - continue; - - default: - NativeError.ThrowException(lastError, deviceName); - break; - } - - var dosDev = new List(); - var buffer = new StringBuilder(); - - for (var i = 0; i < bufferResult; i++) - { - if (cBuffer[i] != Path.StringTerminatorChar) - buffer.Append(cBuffer[i]); - - else if (buffer.Length > 0) - { - dosDev.Add(buffer.ToString()); - buffer.Length = 0; - } - } - - // Choose the yield back query; filtered or list. - var selectQuery = searchFilter - ? dosDev.Where(dev => options != null && dev.StartsWith(options[0], StringComparison.OrdinalIgnoreCase)) - : dosDev; - - foreach (var dev in (doSort) ? selectQuery.OrderBy(n => n) : selectQuery) - yield return dev; - } - } - - #endregion // QueryDosDevice - - #endregion // DosDevice - - #region Drive - - #region GetDriveFormat - - /// Gets the name of the file system, such as NTFS or FAT32. - /// Use DriveFormat to determine what formatting a drive uses. - /// - /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// The name of the file system on the specified drive or on failure or if not available. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static string GetDriveFormat(string drivePath) - { - var fsName = new VolumeInfo(drivePath, true, true).FileSystemName; - return Utils.IsNullOrWhiteSpace(fsName) ? null : fsName; - } - - #endregion // GetDriveFormat - - #region GetDriveNameForNtDeviceName - - /// Gets the drive letter from an MS-DOS device name. For example: "\Device\HarddiskVolume2" returns "C:\". - /// An MS-DOS device name. - /// The drive letter from an MS-DOS device name. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Nt")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nt")] - public static string GetDriveNameForNtDeviceName(string deviceName) - { - return (from drive in Directory.EnumerateLogicalDrivesCore(false, false) - where drive.DosDeviceName.Equals(deviceName, StringComparison.OrdinalIgnoreCase) - select drive.Name).FirstOrDefault(); - } - - #endregion // GetDriveNameForNtDeviceName - - #region GetCurrentDriveType - - /// - /// Determines, based on the root of the current directory, whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network - /// drive. - /// - /// A object. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static DriveType GetCurrentDriveType() - { - return GetDriveType(null); - } - - #endregion // GetCurrentDriveType - - #region GetDriveType - - /// Determines whether a disk drive is a removable, fixed, CD-ROM, RAM disk, or network drive. - /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\" - /// A object. - [SecurityCritical] - public static DriveType GetDriveType(string drivePath) - { - // drivePath is allowed to be == null. - - drivePath = Path.AddTrailingDirectorySeparator(drivePath, false); - - // ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups. - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - return NativeMethods.GetDriveType(drivePath); - } - - #endregion // GetDriveType - - #region GetDiskFreeSpace - - /// - /// Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total - /// amount of free space, and the total amount of free space available to the user that is associated with the calling thread. - /// - /// The calling application must have FILE_LIST_DIRECTORY access rights for this directory. - /// - /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// A class instance. - [SecurityCritical] - public static DiskSpaceInfo GetDiskFreeSpace(string drivePath) - { - return new DiskSpaceInfo(drivePath, null, true, true); - } - - /// - /// Retrieves information about the amount of space that is available on a disk volume, which is the total amount of space, the total - /// amount of free space, and the total amount of free space available to the user that is associated with the calling thread. - /// - /// The calling application must have FILE_LIST_DIRECTORY access rights for this directory. - /// - /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// - /// gets both size- and disk cluster information. Get only disk cluster information, - /// Get only size information. - /// - /// A class instance. - [SecurityCritical] - public static DiskSpaceInfo GetDiskFreeSpace(string drivePath, bool? spaceInfoType) - { - return new DiskSpaceInfo(drivePath, spaceInfoType, true, true); - } - - #endregion // GetDiskFreeSpace - - #region IsReady - - /// Gets a value indicating whether a drive is ready. - /// - /// A path to a drive. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// if is ready; otherwise, . - [SecurityCritical] - public static bool IsReady(string drivePath) - { - return File.ExistsCore(true, null, drivePath, PathFormat.FullPath); - } - - #endregion // IsReady - - #endregion // Drive - - #region Volume - - #region DeleteCurrentVolumeLabel - - /// Deletes the label of the file system volume that is the root of the current directory. - /// - [SecurityCritical] - public static void DeleteCurrentVolumeLabel() - { - SetVolumeLabel(null, null); - } - #endregion // DeleteCurrentVolumeLabel - - #region DeleteVolumeLabel - - /// Deletes the label of a file system volume. - /// - /// The root directory of a file system volume. This is the volume the function will remove the label. - [SecurityCritical] - public static void DeleteVolumeLabel(string rootPathName) - { - if (Utils.IsNullOrWhiteSpace(rootPathName)) - throw new ArgumentNullException("rootPathName"); - - SetVolumeLabel(rootPathName, null); - } - - #endregion // DeleteVolumeLabel - - #region DeleteVolumeMountPoint - - /// Deletes a Drive letter or mounted folder. - /// Deleting a mounted folder does not cause the underlying directory to be deleted. - /// - /// If the parameter is a directory that is not a mounted folder, the function does nothing. The - /// directory is not deleted. - /// - /// - /// It's not an error to attempt to unmount a volume from a volume mount point when there is no volume actually mounted at that volume - /// mount point. - /// - /// The Drive letter or mounted folder to be deleted. For example, X:\ or Y:\MountX\. - [SecurityCritical] - public static void DeleteVolumeMountPoint(string volumeMountPoint) - { - DeleteVolumeMountPointCore(volumeMountPoint, false); - } - - #endregion // DeleteVolumeMountPoint - - #region EnumerateVolumeMountPoints - - /// - /// Returns an enumerable collection of of all mounted folders (volume mount points) on the specified volume. - /// - /// - /// - /// A containing the volume . - /// An enumerable collection of of all volume mount points on the specified volume. - [SecurityCritical] - public static IEnumerable EnumerateVolumeMountPoints(string volumeGuid) - { - if (Utils.IsNullOrWhiteSpace(volumeGuid)) - throw new ArgumentNullException("volumeGuid"); - - if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(Resources.Not_A_Valid_Guid, volumeGuid); - - // A trailing backslash is required. - volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false); - - var buffer = new StringBuilder(NativeMethods.MaxPathUnicode); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - using (var handle = NativeMethods.FindFirstVolumeMountPoint(volumeGuid, buffer, (uint)buffer.Capacity)) - { - var lastError = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - handle.Close(); - - switch ((uint) lastError) - { - case Win32Errors.ERROR_NO_MORE_FILES: - case Win32Errors.ERROR_PATH_NOT_FOUND: // Observed with USB stick, FAT32 formatted. - yield break; - - default: - NativeError.ThrowException(lastError, volumeGuid); - break; - } - } - - yield return buffer.ToString(); - - - while (NativeMethods.FindNextVolumeMountPoint(handle, buffer, (uint)buffer.Capacity)) - { - lastError = Marshal.GetLastWin32Error(); - - if (handle.IsInvalid) - { - handle.Close(); - - switch ((uint) lastError) - { - case Win32Errors.ERROR_NO_MORE_FILES: - case Win32Errors.ERROR_PATH_NOT_FOUND: // Observed with USB stick, FAT32 formatted. - case Win32Errors.ERROR_MORE_DATA: - yield break; - - default: - NativeError.ThrowException(lastError, volumeGuid); - break; - } - } - - yield return buffer.ToString(); - } - } - } - - #endregion // EnumerateVolumeMountPoints - - #region EnumerateVolumePathNames - - /// - /// Returns an enumerable collection of drive letters and mounted folder paths for the specified volume. - /// - /// - /// - /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\. - /// An enumerable collection of containing the path names for the specified volume. - [SecurityCritical] - public static IEnumerable EnumerateVolumePathNames(string volumeGuid) - { - if (Utils.IsNullOrWhiteSpace(volumeGuid)) - throw new ArgumentNullException("volumeGuid"); - - if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(Resources.Not_A_Valid_Guid, volumeGuid); - - var volName = Path.AddTrailingDirectorySeparator(volumeGuid, false); - - uint requiredLength = 10; - var cBuffer = new char[requiredLength]; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - while (!NativeMethods.GetVolumePathNamesForVolumeName(volName, cBuffer, (uint)cBuffer.Length, out requiredLength)) - { - var lastError = Marshal.GetLastWin32Error(); - - switch ((uint)lastError) - { - case Win32Errors.ERROR_MORE_DATA: - case Win32Errors.ERROR_INSUFFICIENT_BUFFER: - cBuffer = new char[requiredLength]; - break; - - default: - NativeError.ThrowException(lastError, volumeGuid); - break; - } - } - - var buffer = new StringBuilder(cBuffer.Length); - foreach (var c in cBuffer) - { - if (c != Path.StringTerminatorChar) - buffer.Append(c); - else - { - if (buffer.Length > 0) - { - yield return buffer.ToString(); - buffer.Length = 0; - } - } - } - } - - #endregion // EnumerateVolumePathNames - - #region EnumerateVolumes - - /// Returns an enumerable collection of volumes on the computer. - /// An enumerable collection of volume names on the computer. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static IEnumerable EnumerateVolumes() - { - var buffer = new StringBuilder(NativeMethods.MaxPathUnicode); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - using (var handle = NativeMethods.FindFirstVolume(buffer, (uint)buffer.Capacity)) - { - while (handle != null && !handle.IsInvalid) - { - if (NativeMethods.FindNextVolume(handle, buffer, (uint)buffer.Capacity)) - yield return buffer.ToString(); - - else - { - var lastError = Marshal.GetLastWin32Error(); - - handle.Close(); - - if (lastError == Win32Errors.ERROR_NO_MORE_FILES) - yield break; - - NativeError.ThrowException(lastError); - } - } - } - } - - #endregion // EnumerateVolumes - - #region GetUniqueVolumeNameForPath - - /// - /// Get the unique volume name for the given path. - /// - /// - /// - /// A path string. Both absolute and relative file and directory names, for example "..", is acceptable in this path. If you specify a - /// relative file or directory name without a volume qualifier, GetUniqueVolumeNameForPath returns the Drive letter of the current - /// volume. - /// - /// - /// Returns the unique volume name in the form: "\\?\Volume{GUID}\", - /// or on error or if unavailable. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static string GetUniqueVolumeNameForPath(string volumePathName) - { - if (Utils.IsNullOrWhiteSpace(volumePathName)) - throw new ArgumentNullException("volumePathName"); - - try - { - return GetVolumeGuid(GetVolumePathName(volumePathName)); - } - catch - { - return null; - } - } - - #endregion // GetUniqueVolumeNameForPath - - #region GetVolumeDeviceName - - /// Retrieves the Win32 Device name from the Volume name. - /// - /// Name of the Volume. - /// - /// The Win32 Device name from the Volume name (for example: "\Device\HarddiskVolume2"), or on error or if - /// unavailable. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static string GetVolumeDeviceName(string volumeName) - { - if (Utils.IsNullOrWhiteSpace(volumeName)) - throw new ArgumentNullException("volumeName"); - - volumeName = Path.RemoveTrailingDirectorySeparator(volumeName, false); - - #region GlobalRoot - - if (volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase)) - return volumeName.Substring(Path.GlobalRootPrefix.Length); - - #endregion // GlobalRoot - - bool doQueryDos; - - #region Volume - - if (volumeName.StartsWith(Path.VolumePrefix, StringComparison.OrdinalIgnoreCase)) - { - // Isolate the DOS Device from the Volume name, in the format: Volume{GUID} - volumeName = volumeName.Substring(Path.LongPathPrefix.Length); - doQueryDos = true; - } - - #endregion // Volume - - #region Logical Drive - - // Check for Logical Drives: C:, D:, ... - else - { - // Don't use char.IsLetter() here as that can be misleading. - // The only valid drive letters are: a-z and A-Z. - var c = volumeName[0]; - doQueryDos = (volumeName[1] == Path.VolumeSeparatorChar && ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))); - } - - #endregion // Logical Drive - - if (doQueryDos) - { - try - { - // Get the real Device underneath. - var dev = QueryDosDevice(volumeName).FirstOrDefault(); - return !Utils.IsNullOrWhiteSpace(dev) ? dev : null; - } - catch - { - } - } - - return null; - } - - #endregion // GetVolumeDeviceName - - #region GetVolumeDisplayName - - /// Gets the shortest display name for the specified . - /// This method basically returns the shortest string returned by - /// A volume path: \\?\Volume{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}\. - /// - /// The shortest display name for the specified volume found, or if no display names were found. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static string GetVolumeDisplayName(string volumeName) - { - string[] smallestMountPoint = { new string(Path.WildcardStarMatchAllChar, NativeMethods.MaxPathUnicode) }; - - try - { - foreach (var m in EnumerateVolumePathNames(volumeName).Where(m => !Utils.IsNullOrWhiteSpace(m) && m.Length < smallestMountPoint[0].Length)) - smallestMountPoint[0] = m; - } - catch - { - } - - var result = smallestMountPoint[0][0] == Path.WildcardStarMatchAllChar ? null : smallestMountPoint[0]; - return Utils.IsNullOrWhiteSpace(result) ? null : result; - } - - #endregion // GetVolumeDisplayName - - #region GetVolumeGuid - - /// - /// Retrieves a volume path for the volume that is associated with the specified volume mount point (drive letter, - /// volume GUID path, or mounted folder). - /// - /// - /// - /// The path of a mounted folder (for example, "Y:\MountX\") or a drive letter (for example, "X:\"). - /// - /// The unique volume name of the form: "\\?\Volume{GUID}\". - [SuppressMessage("Microsoft.Interoperability", "CA1404:CallGetLastErrorImmediatelyAfterPInvoke", Justification = "Marshal.GetLastWin32Error() is manipulated.")] - [SecurityCritical] - public static string GetVolumeGuid(string volumeMountPoint) - { - if (Utils.IsNullOrWhiteSpace(volumeMountPoint)) - throw new ArgumentNullException("volumeMountPoint"); - - // The string must end with a trailing backslash ('\'). - volumeMountPoint = Path.GetFullPathCore(null, volumeMountPoint, GetFullPathOptions.AsLongPath | GetFullPathOptions.AddTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - var volumeGuid = new StringBuilder(100); - var uniqueName = new StringBuilder(100); - - try - { - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - // GetVolumeNameForVolumeMountPoint() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - return NativeMethods.GetVolumeNameForVolumeMountPoint(volumeMountPoint, volumeGuid, (uint) volumeGuid.Capacity) - ? NativeMethods.GetVolumeNameForVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeGuid.ToString(), false), uniqueName, (uint) uniqueName.Capacity) - ? uniqueName.ToString() - : null - : null; - } - } - finally - { - var lastError = (uint) Marshal.GetLastWin32Error(); - - switch (lastError) - { - case Win32Errors.ERROR_INVALID_NAME: - NativeError.ThrowException(lastError, volumeMountPoint); - break; - - case Win32Errors.ERROR_MORE_DATA: - // (1) When GetVolumeNameForVolumeMountPoint() succeeds, lastError is set to Win32Errors.ERROR_MORE_DATA. - break; - - default: - // (2) When volumeMountPoint is a network drive mapping or UNC path, lastError is set to Win32Errors.ERROR_INVALID_PARAMETER. - - // Throw IOException. - NativeError.ThrowException(lastError, volumeMountPoint); - break; - } - } - } - - #endregion // GetVolumeGuid - - #region GetVolumeGuidForNtDeviceName - - /// - /// Tranlates DosDevicePath to a Volume GUID. For example: "\Device\HarddiskVolumeX\path\filename.ext" can translate to: "\path\ - /// filename.ext" or: "\\?\Volume{GUID}\path\filename.ext". - /// - /// A DosDevicePath, for example: \Device\HarddiskVolumeX\path\filename.ext. - /// A translated dos path. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Nt")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Nt")] - public static string GetVolumeGuidForNtDeviceName(string dosDevice) - { - return (from drive in Directory.EnumerateLogicalDrivesCore(false, false) - where drive.DosDeviceName.Equals(dosDevice, StringComparison.OrdinalIgnoreCase) - select drive.VolumeInfo.Guid).FirstOrDefault(); - } - - #endregion // GetVolumeGuidForNtDeviceName - - #region GetVolumeInfo - - /// Retrieves information about the file system and volume associated with the specified root file or directorystream. - /// A path that contains the root directory. - /// A instance describing the volume associatied with the specified root directory. - [SecurityCritical] - public static VolumeInfo GetVolumeInfo(string volumePath) - { - return new VolumeInfo(volumePath, true, false); - } - - /// Retrieves information about the file system and volume associated with the specified root file or directorystream. - /// An instance to a handle. - /// A instance describing the volume associatied with the specified root directory. - [SecurityCritical] - public static VolumeInfo GetVolumeInfo(SafeFileHandle volumeHandle) - { - return new VolumeInfo(volumeHandle, true, true); - } - - #endregion // GetVolumeInfo - - #region GetVolumeLabel - - /// Retrieve the label of a file system volume. - /// - /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// - /// The the label of the file system volume. This function can return string.Empty since a volume label is generally not - /// mandatory. - /// - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static string GetVolumeLabel(string volumePath) - { - return new VolumeInfo(volumePath, true, true).Name; - } - - #endregion // GetVolumeLabel - - #region GetVolumePathName - - /// Retrieves the volume mount point where the specified path is mounted. - /// - /// The path to the volume, for example: "C:\Windows". - /// - /// Returns the nearest volume root path for a given directory. - /// The volume path name, for example: "C:\Windows" returns: "C:\". - /// - [SecurityCritical] - public static string GetVolumePathName(string path) - { - if (Utils.IsNullOrWhiteSpace(path)) - throw new ArgumentNullException("path"); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - var volumeRootPath = new StringBuilder(NativeMethods.MaxPathUnicode / 32); - var pathLp = Path.GetFullPathCore(null, path, GetFullPathOptions.AsLongPath | GetFullPathOptions.FullCheck); - - // GetVolumePathName() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - var getOk = NativeMethods.GetVolumePathName(pathLp, volumeRootPath, (uint) volumeRootPath.Capacity); - var lastError = Marshal.GetLastWin32Error(); - - if (getOk) - return Path.GetRegularPathCore(volumeRootPath.ToString(), GetFullPathOptions.None, false); - - switch ((uint) lastError) - { - // Don't throw exception on these errors. - case Win32Errors.ERROR_NO_MORE_FILES: - case Win32Errors.ERROR_INVALID_PARAMETER: - case Win32Errors.ERROR_INVALID_NAME: - break; - - default: - NativeError.ThrowException(lastError, path); - break; - } - - // Return original path. - return path; - } - } - - #endregion // GetVolumePathName - - #region IsSameVolume - - /// Determines whether the volume of two file system objects is the same. - /// The first filesystem ojbect with full path information. - /// The second file system object with full path information. - /// if both filesytem objects reside on the same volume, otherwise. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - [SecurityCritical] - public static bool IsSameVolume(string path1, string path2) - { - try - { - var volInfo1 = new VolumeInfo(GetVolumePathName(path1), true, true); - var volInfo2 = new VolumeInfo(GetVolumePathName(path2), true, true); - - return volInfo1.SerialNumber == volInfo2.SerialNumber; - } - catch { } - - return false; - } - - #endregion // IsSameVolume - - #region IsVolume - - /// Determines whether the specified volume name is a defined volume on the current computer. - /// - /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\". - /// - /// on success, otherwise. - [SecurityCritical] - public static bool IsVolume(string volumeMountPoint) - { - return !Utils.IsNullOrWhiteSpace(GetVolumeGuid(volumeMountPoint)); - } - - #endregion // IsVolume - - #region SetCurrentVolumeLabel - - /// Sets the label of the file system volume that is the root of the current directory. - /// - /// A name for the volume. - [SecurityCritical] - public static void SetCurrentVolumeLabel(string volumeName) - { - if (Utils.IsNullOrWhiteSpace(volumeName)) - throw new ArgumentNullException("volumeName"); - - if (!NativeMethods.SetVolumeLabel(null, volumeName)) - Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); - } - - #endregion // SetCurrentVolumeLabel - - #region SetVolumeLabel - - /// Sets the label of a file system volume. - /// - /// A path to a volume. For example: "C:\", "\\server\share", or "\\?\Volume{c0580d5e-2ad6-11dc-9924-806e6f6e6963}\" - /// If this parameter is , the function uses the current drive. - /// - /// - /// A name for the volume. - /// If this parameter is , the function deletes any existing label - /// from the specified volume and does not assign a new label. - /// - [SecurityCritical] - public static void SetVolumeLabel(string volumePath, string volumeName) - { - // rootPathName == null is allowed, means current drive. - - // Setting volume label only applies to Logical Drives pointing to local resources. - //if (!Path.IsLocalPath(rootPathName)) - //return false; - - volumePath = Path.AddTrailingDirectorySeparator(volumePath, false); - - // NTFS uses a limit of 32 characters for the volume label as of Windows Server 2003. - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - if (!NativeMethods.SetVolumeLabel(volumePath, volumeName)) - NativeError.ThrowException(volumePath, volumeName); - } - - #endregion // SetVolumeLabel - - #region SetVolumeMountPoint - - /// Associates a volume with a Drive letter or a directory on another volume. - /// - /// - /// - /// The user-mode path to be associated with the volume. This may be a Drive letter (for example, "X:\") - /// or a directory on another volume (for example, "Y:\MountX\"). - /// - /// A containing the volume . - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "1", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public static void SetVolumeMountPoint(string volumeMountPoint, string volumeGuid) - { - if (Utils.IsNullOrWhiteSpace(volumeMountPoint)) - throw new ArgumentNullException("volumeMountPoint"); - - if (Utils.IsNullOrWhiteSpace(volumeGuid)) - throw new ArgumentNullException("volumeGuid"); - - if (!volumeGuid.StartsWith(Path.VolumePrefix + "{", StringComparison.OrdinalIgnoreCase)) - throw new ArgumentException(Resources.Not_A_Valid_Guid, volumeGuid); - - volumeMountPoint = Path.GetFullPathCore(null, volumeMountPoint, GetFullPathOptions.AsLongPath | GetFullPathOptions.AddTrailingDirectorySeparator | GetFullPathOptions.FullCheck); - - // This string must be of the form "\\?\Volume{GUID}\" - volumeGuid = Path.AddTrailingDirectorySeparator(volumeGuid, false); - - - // ChangeErrorMode is for the Win32 SetThreadErrorMode() method, used to suppress possible pop-ups. - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - - // SetVolumeMountPoint() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2014-01-29: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!NativeMethods.SetVolumeMountPoint(volumeMountPoint, volumeGuid)) - { - var lastError = Marshal.GetLastWin32Error(); - - // If the lpszVolumeMountPoint parameter contains a path to a mounted folder, - // GetLastError returns ERROR_DIR_NOT_EMPTY, even if the directory is empty. - - if (lastError != Win32Errors.ERROR_DIR_NOT_EMPTY) - NativeError.ThrowException(lastError, volumeGuid); - } - } - - #endregion // SetVolumeMountPoint - - #endregion // Volume - - - #region Internal Methods - - /// Defines, redefines, or deletes MS-DOS device names. - /// - /// - /// defines a new MS-DOS device. deletes a previously defined MS-DOS device. - /// - /// - /// An MS-DOS device name string specifying the device the function is defining, redefining, or deleting. - /// - /// - /// A pointer to a path string that will implement this device. The string is an MS-DOS path string unless the - /// flag is specified, in which case this string is a path string. - /// - /// - /// The controllable aspects of the DefineDosDevice function, flags which will be combined with the - /// default. - /// - /// - /// Only delete MS-DOS device on an exact name match. If is , - /// must be the same path used to create the mapping. - /// - /// - /// on success, otherwise. - [SecurityCritical] - internal static void DefineDosDeviceCore(bool isDefine, string deviceName, string targetPath, DosDeviceAttributes deviceAttributes, bool exactMatch) - { - if (Utils.IsNullOrWhiteSpace(deviceName)) - throw new ArgumentNullException("deviceName"); - - if (isDefine) - { - // targetPath is allowed to be null. - - // In no case is a trailing backslash ("\") allowed. - deviceName = Path.GetRegularPathCore(deviceName, GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.CheckInvalidPathChars, false); - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - if (!NativeMethods.DefineDosDevice(deviceAttributes, deviceName, targetPath)) - NativeError.ThrowException(deviceName, targetPath); - } - else - { - // A pointer to a path string that will implement this device. - // The string is an MS-DOS path string unless the DDD_RAW_TARGET_PATH flag is specified, in which case this string is a path string. - - if (exactMatch && !Utils.IsNullOrWhiteSpace(targetPath)) - deviceAttributes = deviceAttributes | DosDeviceAttributes.ExactMatchOnRemove | DosDeviceAttributes.RawTargetPath; - - // Remove the MS-DOS device name. First, get the name of the Windows NT device - // from the symbolic link and then delete the symbolic link from the namespace. - - DefineDosDevice(deviceName, targetPath, deviceAttributes); - } - } - - /// Deletes a Drive letter or mounted folder. - /// - /// It's not an error to attempt to unmount a volume from a volume mount point when there is no volume actually mounted at that volume mount point. - /// Deleting a mounted folder does not cause the underlying directory to be deleted. - /// - /// - /// The Drive letter or mounted folder to be deleted. For example, X:\ or Y:\MountX\. - /// - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - /// - /// If completed successfully returns , otherwise the last error number. - [SecurityCritical] - internal static int DeleteVolumeMountPointCore(string volumeMountPoint, bool continueOnException) - { - if (Utils.IsNullOrWhiteSpace(volumeMountPoint)) - throw new ArgumentNullException("volumeMountPoint"); - - var lastError = (int) Win32Errors.ERROR_SUCCESS; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - // DeleteVolumeMountPoint() - // In the ANSI version of this function, the name is limited to MAX_PATH characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-01-13: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - if (!NativeMethods.DeleteVolumeMountPoint(Path.AddTrailingDirectorySeparator(volumeMountPoint, false))) - lastError = Marshal.GetLastWin32Error(); - - if (lastError != Win32Errors.ERROR_SUCCESS && !continueOnException) - { - if (lastError == Win32Errors.ERROR_FILE_NOT_FOUND) - lastError = (int) Win32Errors.ERROR_PATH_NOT_FOUND; - - NativeError.ThrowException(lastError, volumeMountPoint); - } - } - - return lastError; - } - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Filesystem/VolumeInfo.cs b/FolderMonitor/AlphaFS/Filesystem/VolumeInfo.cs deleted file mode 100644 index 164215f..0000000 --- a/FolderMonitor/AlphaFS/Filesystem/VolumeInfo.cs +++ /dev/null @@ -1,462 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using Microsoft.Win32.SafeHandles; -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Filesystem -{ - /// Contains information about a filesystem Volume. - [SerializableAttribute] - [SecurityCritical] - public sealed class VolumeInfo - { - #region Constructor - - /// Initializes a VolumeInfo instance. - /// - /// - /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: \\server\share. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - public VolumeInfo(string volumeName) - { - if (Utils.IsNullOrWhiteSpace(volumeName)) - throw new ArgumentNullException("volumeName"); - - if (!volumeName.StartsWith(Path.LongPathPrefix, StringComparison.OrdinalIgnoreCase)) - volumeName = Path.IsUncPathCore(volumeName, false, false) - ? Path.GetLongPathCore(volumeName, GetFullPathOptions.None) - : Path.LongPathPrefix + volumeName; - else - { - if (volumeName.Length == 1) - volumeName += Path.VolumeSeparatorChar; - else if (!volumeName.StartsWith(Path.GlobalRootPrefix, StringComparison.OrdinalIgnoreCase)) - volumeName = Path.GetPathRoot(volumeName, false); - } - - if (Utils.IsNullOrWhiteSpace(volumeName)) - throw new ArgumentException("Argument must be a drive letter (\"C\"), RootDir (\"C:\\\") or UNC path (\"\\\\server\\share\")"); - - Name = Path.AddTrailingDirectorySeparator(volumeName, false); - - _volumeHandle = null; - } - - /// Initializes a VolumeInfo instance. - /// A valid drive path or drive letter. This can be either uppercase or lowercase, 'a' to 'z' or a network share in the format: "\\server\share". - /// Refreshes the state of the object. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public VolumeInfo(string driveName, bool refresh, bool continueOnException) : this(driveName) - { - _continueOnAccessError = continueOnException; - - if (refresh) - Refresh(); - } - - /// Initializes a VolumeInfo instance. - /// An instance to a handle. - [SecurityCritical] - public VolumeInfo(SafeFileHandle volumeHandle) - { - _volumeHandle = volumeHandle; - } - - /// Initializes a VolumeInfo instance. - /// An instance to a handle. - /// Refreshes the state of the object. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public VolumeInfo(SafeFileHandle volumeHandle, bool refresh, bool continueOnException) : this(volumeHandle) - { - _continueOnAccessError = continueOnException; - - if (refresh) - Refresh(); - } - - #endregion // Constructor - - #region Fields - - [NonSerialized] private readonly bool _continueOnAccessError; - [NonSerialized] private readonly SafeFileHandle _volumeHandle; - [NonSerialized] private NativeMethods.VolumeInfoAttributes _volumeInfoAttributes; - #endregion // Fields - - #region Methods - - #region Refresh - - /// Refreshes the state of the object. - public void Refresh() - { - var volumeNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1); - var fileSystemNameBuffer = new StringBuilder(NativeMethods.MaxPath + 1); - int maximumComponentLength; - uint serialNumber; - - using (new NativeMethods.ChangeErrorMode(NativeMethods.ErrorMode.FailCriticalErrors)) - { - // GetVolumeInformationXxx() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - uint lastError; - - do - { - if (!(_volumeHandle != null && NativeMethods.IsAtLeastWindowsVista - - // GetVolumeInformationByHandle() / GetVolumeInformation() - // In the ANSI version of this function, the name is limited to 248 characters. - // To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. - // 2013-07-18: MSDN does not confirm LongPath usage but a Unicode version of this function exists. - - ? NativeMethods.GetVolumeInformationByHandle(_volumeHandle, volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity) - : NativeMethods.GetVolumeInformation(Path.AddTrailingDirectorySeparator(Name, false), volumeNameBuffer, (uint) volumeNameBuffer.Capacity, out serialNumber, out maximumComponentLength, out _volumeInfoAttributes, fileSystemNameBuffer, (uint) fileSystemNameBuffer.Capacity)) - // A trailing backslash is required. - ) - { - lastError = (uint) Marshal.GetLastWin32Error(); - switch (lastError) - { - case Win32Errors.ERROR_NOT_READY: - if (!_continueOnAccessError) - throw new DeviceNotReadyException(); - break; - - case Win32Errors.ERROR_MORE_DATA: - // With a large enough buffer this code never executes. - volumeNameBuffer.Capacity = volumeNameBuffer.Capacity*2; - fileSystemNameBuffer.Capacity = fileSystemNameBuffer.Capacity*2; - break; - - default: - if (!_continueOnAccessError) - NativeError.ThrowException(Name); - break; - } - } - else - break; - - } while (lastError == Win32Errors.ERROR_MORE_DATA); - } - - FullPath = Path.GetRegularPathCore(Name, GetFullPathOptions.None, false); - Name = volumeNameBuffer.ToString(); - - FileSystemName = fileSystemNameBuffer.ToString(); - FileSystemName = Utils.IsNullOrWhiteSpace(FileSystemName) ? null : FileSystemName; - - MaximumComponentLength = maximumComponentLength; - SerialNumber = serialNumber; - } - - #endregion // Refresh - - #region ToString - - /// Returns the full path of the volume. - /// A string that represents this instance. - public override string ToString() - { - return Guid; - } - - #endregion // ToString - - #endregion // Methods - - #region Properties - - #region CasePreservedNames - - /// The specified volume supports preserved case of file names when it places a name on disk. - public bool CasePreservedNames - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.CasePreservedNames) == NativeMethods.VolumeInfoAttributes.CasePreservedNames; } - } - - #endregion // CasePreservedNames - - #region CaseSensitiveSearch - - /// The specified volume supports case-sensitive file names. - public bool CaseSensitiveSearch - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.CaseSensitiveSearch) == NativeMethods.VolumeInfoAttributes.CaseSensitiveSearch; } - } - - #endregion // CaseSensitiveSearch - - #region Compression - - /// The specified volume supports file-based compression. - public bool Compression - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.Compression) == NativeMethods.VolumeInfoAttributes.Compression; } - } - - #endregion // Compression - - #region FileSystemName - - /// Gets the name of the file system, for example, the FAT file system or the NTFS file system. - /// The name of the file system. - public string FileSystemName { get; private set; } - - #endregion // FileSystemName - - #region FullPath - - /// The full path to the volume. - public string FullPath { get; private set; } - - #endregion // FullPath - - #region Guid - - private string _guid; - - /// The volume GUID. - - public string Guid - { - get - { - if (Utils.IsNullOrWhiteSpace(_guid)) - _guid = !Utils.IsNullOrWhiteSpace(FullPath) ? Volume.GetUniqueVolumeNameForPath(FullPath) : null; - - return _guid; - } - } - - #endregion // Guid - - #region MaximumComponentLength - - /// Gets the maximum length of a file name component that the file system supports. - /// The maximum length of a file name component that the file system supports. - public int MaximumComponentLength { get; set; } - - #endregion // MaximumComponentLength - - #region Name - - /// Gets the label of the volume. - /// The label of the volume. - /// This property is the label assigned to the volume, such "MyDrive" - public string Name { get; private set; } - - #endregion // Name - - #region NamedStreams - - /// The specified volume supports named streams. - public bool NamedStreams - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.NamedStreams) == NativeMethods.VolumeInfoAttributes.NamedStreams; } - } - - #endregion // NamedStreams - - #region PersistentAcls - - /// The specified volume preserves and enforces access control lists (ACL). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Acls")] - public bool PersistentAcls - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.PersistentAcls) == NativeMethods.VolumeInfoAttributes.PersistentAcls; } - } - - #endregion // PersistentAcls - - #region ReadOnlyVolume - - /// The specified volume is read-only. - public bool ReadOnlyVolume - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.ReadOnlyVolume) == NativeMethods.VolumeInfoAttributes.ReadOnlyVolume; } - } - - #endregion // ReadOnlyVolume - - #region SequentialWriteOnce - - /// The specified volume supports a single sequential write. - public bool SequentialWriteOnce - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SequentialWriteOnce) == NativeMethods.VolumeInfoAttributes.SequentialWriteOnce; } - } - - #endregion // SequentialWriteOnce - - #region SerialNumber - - /// Gets the volume serial number that the operating system assigns when a hard disk is formatted. - /// The volume serial number that the operating system assigns when a hard disk is formatted. - public long SerialNumber { get; private set; } - - #endregion // SerialNumber - - #region SupportsEncryption - - /// The specified volume supports the Encrypted File System (EFS). - public bool SupportsEncryption - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsEncryption) == NativeMethods.VolumeInfoAttributes.SupportsEncryption; } - } - - #endregion // SupportsEncryption - - #region SupportsExtendedAttributes - - /// The specified volume supports extended attributes. - public bool SupportsExtendedAttributes - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsExtendedAttributes) == NativeMethods.VolumeInfoAttributes.SupportsExtendedAttributes; } - } - - #endregion // SupportsExtendedAttributes - - #region SupportsHardLinks - - /// The specified volume supports hard links. - public bool SupportsHardLinks - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsHardLinks) == NativeMethods.VolumeInfoAttributes.SupportsHardLinks; } - } - - #endregion // SupportsHardLinks - - #region SupportsObjectIds - - /// The specified volume supports object identifiers. - public bool SupportsObjectIds - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsObjectIds) == NativeMethods.VolumeInfoAttributes.SupportsObjectIds; } - } - - #endregion // SupportsObjectIds - - #region SupportsOpenByFileId - - /// The file system supports open by FileID. - public bool SupportsOpenByFileId - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsOpenByFileId) == NativeMethods.VolumeInfoAttributes.SupportsOpenByFileId; } - } - - #endregion // SupportsOpenByFileId - - #region SupportsRemoteStorage - - /// The specified volume supports remote storage. (This property does not appear on MSDN) - public bool SupportsRemoteStorage - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsRemoteStorage) == NativeMethods.VolumeInfoAttributes.SupportsRemoteStorage; } - } - - #endregion // SupportsRemoteStorage - - #region SupportsReparsePoints - - /// The specified volume supports re-parse points. - public bool SupportsReparsePoints - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsReparsePoints) == NativeMethods.VolumeInfoAttributes.SupportsReparsePoints; } - } - - #endregion // SupportsReparsePoints - - #region SupportsSparseFiles - - /// The specified volume supports sparse files. - public bool SupportsSparseFiles - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsSparseFiles) == NativeMethods.VolumeInfoAttributes.SupportsSparseFiles; } - } - - #endregion // SupportsSparseFiles - - #region SupportsTransactions - - /// The specified volume supports transactions. - public bool SupportsTransactions - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsTransactions) == NativeMethods.VolumeInfoAttributes.SupportsTransactions; } - } - - #endregion // SupportsTransactions - - #region SupportsUsnJournal - - /// The specified volume supports update sequence number (USN) journals. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Usn")] - public bool SupportsUsnJournal - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.SupportsUsnJournal) == NativeMethods.VolumeInfoAttributes.SupportsUsnJournal; } - } - - #endregion // SupportsUsnJournal - - #region UnicodeOnDisk - - /// The specified volume supports Unicode in file names as they appear on disk. - public bool UnicodeOnDisk - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.UnicodeOnDisk) == NativeMethods.VolumeInfoAttributes.UnicodeOnDisk; } - } - - #endregion // UnicodeOnDisk - - #region VolumeIsCompressed - - /// The specified volume is a compressed volume, for example, a DoubleSpace volume. - public bool VolumeIsCompressed - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.VolumeIsCompressed) == NativeMethods.VolumeInfoAttributes.VolumeIsCompressed; } - } - - #endregion // VolumeIsCompressed - - #region VolumeQuotas - - /// The specified volume supports disk quotas. - public bool VolumeQuotas - { - get { return (_volumeInfoAttributes & NativeMethods.VolumeInfoAttributes.VolumeQuotas) == NativeMethods.VolumeInfoAttributes.VolumeQuotas; } - } - - #endregion // VolumeQuotas - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/NativeError.cs b/FolderMonitor/AlphaFS/NativeError.cs deleted file mode 100644 index c526a4b..0000000 --- a/FolderMonitor/AlphaFS/NativeError.cs +++ /dev/null @@ -1,118 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Runtime.InteropServices; -using System.Security.Policy; - -namespace Alphaleonis.Win32 -{ - internal static class NativeError - { - internal static void ThrowException() - { - ThrowException((uint)Marshal.GetLastWin32Error(), null, null); - } - - public static void ThrowException(int errorCode) - { - ThrowException((uint)errorCode, null, null); - } - - public static void ThrowException(int errorCode, string readPath) - { - ThrowException((uint)errorCode, readPath, null); - } - - public static void ThrowException(int errorCode, string readPath, string writePath) - { - ThrowException((uint)errorCode, readPath, writePath); - } - - public static void ThrowException(uint errorCode, string readPath) - { - ThrowException(errorCode, readPath, null); - } - - [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")] - public static void ThrowException(uint errorCode, string readPath, string writePath) - { - string errorMessage = string.Format(CultureInfo.CurrentCulture, "({0}) {1}.", errorCode, new Win32Exception((int)errorCode).Message); - - if (!Utils.IsNullOrWhiteSpace(readPath)) - errorMessage = string.Format(CultureInfo.CurrentCulture, "{0}: [{1}]", errorMessage.TrimEnd('.'), readPath); - - if (!Utils.IsNullOrWhiteSpace(writePath)) - errorMessage = string.Format(CultureInfo.CurrentCulture, "{0}: [{1}]", errorMessage.TrimEnd('.'), writePath); - - switch (errorCode) - { - case Win32Errors.ERROR_INVALID_DRIVE: - throw new DriveNotFoundException(errorMessage); - - case Win32Errors.ERROR_OPERATION_ABORTED: - throw new OperationCanceledException(errorMessage); - - case Win32Errors.ERROR_FILE_NOT_FOUND: - throw new FileNotFoundException(errorMessage); - - case Win32Errors.ERROR_PATH_NOT_FOUND: - throw new DirectoryNotFoundException(errorMessage); - - case Win32Errors.ERROR_BAD_RECOVERY_POLICY: - throw new PolicyException(errorMessage); - - case Win32Errors.ERROR_FILE_READ_ONLY: - case Win32Errors.ERROR_ACCESS_DENIED: - case Win32Errors.ERROR_NETWORK_ACCESS_DENIED: - throw new UnauthorizedAccessException(errorMessage); - - - - case Win32Errors.ERROR_SUCCESS: - case Win32Errors.ERROR_SUCCESS_REBOOT_INITIATED: - case Win32Errors.ERROR_SUCCESS_REBOOT_REQUIRED: - case Win32Errors.ERROR_SUCCESS_RESTART_REQUIRED: - // We should really never get here, throwing an exception for a successful operation. - throw new NotImplementedException(string.Format(CultureInfo.CurrentCulture, "{0} {1}", Resources.Exception_From_Successful_Operation, errorMessage)); - - default: - // We don't have a specific exception to generate for this error. - throw new IOException(errorMessage, Win32Errors.GetHrFromWin32Error(errorCode)); - } - } - - - public static void ThrowException(string readPath) - { - ThrowException((uint)Marshal.GetLastWin32Error(), readPath, null); - } - - public static void ThrowException(string readPath, string writePath) - { - ThrowException((uint)Marshal.GetLastWin32Error(), readPath, writePath); - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/DfsInfo.cs b/FolderMonitor/AlphaFS/Network/DfsInfo.cs deleted file mode 100644 index b8a9e12..0000000 --- a/FolderMonitor/AlphaFS/Network/DfsInfo.cs +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{/* - /// Contains information about a Distributed File System (DFS) root or link. This class cannot be inherited. - /// This structure contains the name, status, GUID, time-out, number of targets, and information about each target of the root or link. - /// - [SerializableAttribute] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - public sealed class DfsInfo - { - #region Constructor - - /// Initializes a new instance of the class which acts as a wrapper for a DFS root or link target. - public DfsInfo() - { - } - - /// Initializes a new instance of the class, which acts as a wrapper for a DFS root or link target. - /// An initialized instance. - internal DfsInfo(NativeMethods.DFS_INFO_9 structure) - { - Comment = structure.Comment; - EntryPath = structure.EntryPath; - State = structure.State; - Timeout = structure.Timeout; - Guid = structure.Guid; - MetadataSize = structure.MetadataSize; - PropertyFlags = structure.PropertyFlags; - SecurityDescriptor = structure.pSecurityDescriptor; - - if (structure.NumberOfStorages > 0) - { - var typeOfStruct = typeof (NativeMethods.DFS_STORAGE_INFO_1); - var sizeOfStruct = Marshal.SizeOf(typeOfStruct); - - for (int i = 0; i < structure.NumberOfStorages; i++) - _storageInfoCollection.Add(new DfsStorageInfo((NativeMethods.DFS_STORAGE_INFO_1) Marshal.PtrToStructure(new IntPtr(structure.Storage.ToInt64() + i*sizeOfStruct), typeOfStruct))); - } - } - - #endregion // Constructor - - #region Methods - - /// Returns the Universal Naming Convention (UNC) path of the DFS root or link. - /// A string that represents this instance. - public override string ToString() - { - return EntryPath; - } - - #endregion // Methods - - #region Properties - - private DirectoryInfo _directoryInfo; - - /// The instance of the DFS root or link. - public DirectoryInfo DirectoryInfo - { - get - { - // Do not use ?? expression here. - if (_directoryInfo == null) - _directoryInfo = new DirectoryInfo(null, EntryPath, PathFormat.FullPath); - - return _directoryInfo; - } - } - - /// The comment of the DFS root or link. - public string Comment { get; internal set; } - - /// The Universal Naming Convention (UNC) path of the DFS root or link. - public string EntryPath { get; internal set; } - - /// Specifies the GUID of the DFS root or link. - public Guid Guid { get; internal set; } - - - private readonly List _storageInfoCollection = new List(); - - /// The collection of DFS targets of the DFS root or link. - public IEnumerable StorageInfoCollection - { - get { return _storageInfoCollection; } - } - - /// An enum that specifies a set of bit flags that describe the DFS root or link. - public DfsVolumeStates State { get; internal set; } - - //DfsVolumeStates flavorBits = (structure3.State & (DfsVolumeStates) DfsNamespaceFlavors.All); - //If (flavorBits == DFS_VOLUME_FLAVOR_STANDALONE) // Namespace is stand-alone DFS. - //else if (flavorBits == DFS_VOLUME_FLAVOR_AD_BLOB) // Namespace is AD Blob. - //else StateBits = (Flavor & DFS_VOLUME_STATES) // Unknown flavor. - // StateBits can be one of the following: - // (DFS_VOLUME_STATE_OK, DFS_VOLUME_STATE_INCONSISTENT, - // DFS_VOLUME_STATE_OFFLINE or DFS_VOLUME_STATE_ONLINE) - //State = flavorBits | structure3.State; - - /// Specifies the time-out, in seconds, of the DFS root or link. - public long Timeout { get; internal set; } - - /// Specifies a set of flags that describe specific properties of a DFS namespace, root, or link. - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")] - public DfsPropertyFlags PropertyFlags { get; internal set; } - - /// For domain-based DFS namespaces, this member specifies the size of the corresponding Active Directory data blob, in bytes. - /// For stand-alone DFS namespaces, this field specifies the size of the metadata stored in the registry, - /// including the key names and value names, in addition to the specific data items associated with them. This field is valid for DFS roots only. - /// - public long MetadataSize { get; internal set; } - - - /// Pointer to a SECURITY_DESCRIPTOR structure that specifies a self-relative security descriptor to be associated with the DFS link's reparse point. - /// This field is valid for DFS links only. - /// - public IntPtr SecurityDescriptor { get; internal set; } - - #endregion // Properties - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/DfsStorageInfo.cs b/FolderMonitor/AlphaFS/Network/DfsStorageInfo.cs deleted file mode 100644 index 0e0e033..0000000 --- a/FolderMonitor/AlphaFS/Network/DfsStorageInfo.cs +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// Contains information about a DFS root or link target in a DFS namespace or from the cache maintained by the DFS client. - /// This class cannot be inherited. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - public sealed class DfsStorageInfo - { - #region Constructor - - /// Initializes a new instance of the class, which acts as a wrapper for a DFS root or link target. - public DfsStorageInfo() - { - } - - /// Initializes a new instance of the class, which acts as a wrapper for a DFS root or link target. - /// An initialized instance. - internal DfsStorageInfo(NativeMethods.DFS_STORAGE_INFO_1 structure) - { - ServerName = structure.ServerName; - ShareName = structure.ShareName; - - State = structure.State; - - TargetPriorityClass = structure.TargetPriority.TargetPriorityClass; - TargetPriorityRank = structure.TargetPriority.TargetPriorityRank; - } - - #endregion // Constructor - - #region Methods - - /// The share name of the DFS root target or link target. - /// A string that represents this instance. - public override string ToString() - { - return ShareName; - } - - #endregion // Methods - - #region Properties - - /// The server name of the DFS root target or link target. - public string ServerName { get; private set; } - - /// The share name of the DFS root target or link target. - public string ShareName { get; private set; } - - /// An enum of the DFS root target or link target. - public DfsStorageStates State { get; private set; } - - /// Contains a DFS target's priority class and rank. - public DfsTargetPriorityClass TargetPriorityClass { get; private set; } - - /// Specifies the priority rank value of the target. The default value is 0, which indicates the highest priority rank within a priority class. - public int TargetPriorityRank { get; private set; } - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/AccessPermissions.cs b/FolderMonitor/AlphaFS/Network/Enumerations/AccessPermissions.cs deleted file mode 100644 index c87ecde..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/AccessPermissions.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Network -{ - /// A set of bit flags that describe the permissions for the shared resource's on servers running with share-level security. - /// Note that Windows does not support share-level security. This member is ignored on a server running user-level security. - [Flags] - public enum AccessPermissions - { - /// No permissions. - None = 0, - - /// ACCESS_READ - /// Permission to read data from a resource and, by default, to execute the resource. - /// - Read = 1, - - /// ACCESS_WRITE - /// Permission to write data to the resource. - /// - Write = 2, - - /// ACCESS_CREATE - /// Permission to create an instance of the resource (such as a file); data can be written to the resource as the resource is created. - /// - Create = 4, - - /// ACCESS_EXEC - /// Permission to execute the resource. - /// - Execute = 8, - - /// ACCESS_DELETE - /// Permission to delete the resource. - /// - Delete = 16, - - /// ACCESS_ATRIB - /// Permission to modify the resource's attributes, such as the date and time when a file was last modified. - /// - Attributes = 32, - - /// ACCESS_PERM - /// Permission to modify the permissions (read, write, create, execute, and delete) assigned to a resource for a user or application. - /// - Permissions = 64, - - /// ACCESS_ALL - /// Permission to read, write, create, execute, and delete resources, and to modify their attributes and permissions. - /// - All = 32768 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/DfsNamespaceFlavors.cs b/FolderMonitor/AlphaFS/Network/Enumerations/DfsNamespaceFlavors.cs deleted file mode 100644 index 50959cb..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/DfsNamespaceFlavors.cs +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the name and type (domain-based or stand-alone) of a DFS namespace. - /// Minimum supported client: Windows XP with SP1 [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [Flags] - internal enum DfsNamespaceFlavors - { - /// - Unknown = 0, - - /// DFS_VOLUME_FLAVOR_STANDALONE - /// Specifies a stand-alone DFS namespace. - /// - Standalone = 256, - - /// DFS_VOLUME_FLAVOR_AD_BLOB - /// Specifies a domain-based DFS namespace. - /// - AdBlob = 512, - - /// DFS_VOLUME_FLAVORS bitmask (0x00000300) - /// Used to extract the DFS namespace flavor. - /// - All = 768 - } - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/DfsPropertyFlags.cs b/FolderMonitor/AlphaFS/Network/Enumerations/DfsPropertyFlags.cs deleted file mode 100644 index 5472f50..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/DfsPropertyFlags.cs +++ /dev/null @@ -1,104 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// A set of bit flags that describe specific properties of a DFS namespace, root, or link. - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [Flags] - public enum DfsPropertyFlags - { - /// No property flag. - None = 0, - - /// DFS_PROPERTY_FLAG_INSITE_REFERRALS - /// - /// Scope: Domain roots, stand-alone roots, and links. - /// If this flag is set at the DFS root, it applies to all links; otherwise, the value of this flag is considered for each individual link. - /// - /// - /// When this flag is set, a DFS referral response from a DFS server for a DFS root or link with the "INSITE" option enabled contains only - /// those targets which are in the same site as the DFS client requesting the referral. - /// Targets in the two global priority classes are always returned, regardless of their site location. - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Insite")] - InsiteReferrals = 1, - - /// DFS_PROPERTY_FLAG_ROOT_SCALABILITY - /// - /// Scope: The entire DFS namespace for a domain-based DFS namespace only. - /// - /// - /// By default, a DFS root target server polls the PDS to detect changes to the DFS metadata. - /// To prevent heavy server load on the PDC, root scalability can be enabled for the DFS namespace. - /// Setting this flag will cause the DFS server to poll the nearest domain controller instead of the PDC for DFS metadata changes for the common namespace. - /// Note that any changes made to the metadata must still occur on the PDC, however. - /// - /// - RootScalability = 2, - - /// DFS_PROPERTY_FLAG_SITE_COSTING - /// - /// Scope: The entire DFS namespace for both domain-based and stand-alone DFS namespaces. - /// - /// - /// By default, targets returned in a referral response from a DFS server to a DFS client for a DFS root or link - /// consists of two groups: targets in the same site as the client, and targets outside the site. - /// - /// - /// If site-costing is enabled for the Active Directory, the response can have more than two groups, - /// with each group containing targets with the same site cost for the specific DFS client requesting the referral. - /// The groups are ordered by increasing site cost. For more information about how site-costing is used to prioritize targets. - /// - /// - SiteCosting = 4, - - /// DFS_PROPERTY_FLAG_TARGET_FAILBACK - /// - /// Scope: Domain-based DFS roots, stand-alone DFS roots, and DFS links. - /// If this flag is set at the DFS root, it applies to all links; otherwise, the value of this flag is considered for each individual link. - /// - /// - /// When this flag is set, optimal target failback is enabled for V4 DFS clients, - /// allowing them to fail back to an optimal target after failing over to a non-optimal one. - /// The target failback setting is provided to the DFS client in a V4 referral response by a DFS server. - /// - /// - TargetFailback = 8, - - /// DFS_PROPERTY_FLAG_CLUSTER_ENABLED - /// Scope: Stand-alone DFS roots and links only. - /// The DFS root is clustered to provide high availability for storage failover. - /// - ClusterEnabled = 16, - - /// DFS_PROPERTY_FLAG_ABDE - /// Scope: Domain-based DFS roots and stand-alone DFS roots. - /// When this flag is set, Access-Based Directory Enumeration (ABDE) mode support is enabled on the entire DFS root target share of the DFS namespace. - /// - AccessBasedDirectoryEnumeration = 32 - } -} diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/DfsStorageStates.cs b/FolderMonitor/AlphaFS/Network/Enumerations/DfsStorageStates.cs deleted file mode 100644 index 3ddb140..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/DfsStorageStates.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// A set of bit flags that describe the storage state of the DFS root or link target. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [Flags] - public enum DfsStorageStates - { - /// No storage state. - None = 0, - - /// DFS_STORAGE_STATE_OFFLINE - /// The DFS root or link target is offline. - /// - /// Windows Server 2003: The state of a root target cannot be set to DFS_STORAGE_STATE_OFFLINE. - Offline = 1, - - /// DFS_STORAGE_STATE_ONLINE - /// The DFS root or link target is online. - /// - Online = 2, - - /// DFS_STORAGE_STATE_ACTIVE - /// The DFS root or link target is the active target. - /// - Active = 4 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/DfsTargetPriorityClass.cs b/FolderMonitor/AlphaFS/Network/Enumerations/DfsTargetPriorityClass.cs deleted file mode 100644 index 5f456cc..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/DfsTargetPriorityClass.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// Defines the set of possible DFS target priority class settings. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - public enum DfsTargetPriorityClass - { - /// The priority class is not valid. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsInvalidPriorityClass = -1, - - /// The middle or "normal" site cost priority class for a DFS target. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsSiteCostNormalPriorityClass = 0, - - /// The highest priority class for a DFS target. Targets assigned this class receive global preference. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsGlobalHighPriorityClass = 1, - - /// The highest site cost priority class for a DFS target. Targets assigned this class receive the most preference among targets of the same site cost for a given DFS client. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsSiteCostHighPriorityClass = 2, - - /// The lowest site cost priority class for a DFS target. Targets assigned this class receive the least preference among targets of the same site cost for a given DFS client. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsSiteCostLowPriorityClass = 3, - - /// The lowest level of priority class for a DFS target. Targets assigned this class receive the least preference globally. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsGlobalLowPriorityClass = 4 - } -} diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/DfsVolumeStates.cs b/FolderMonitor/AlphaFS/Network/Enumerations/DfsVolumeStates.cs deleted file mode 100644 index 817ddf2..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/DfsVolumeStates.cs +++ /dev/null @@ -1,72 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// A set of bit flags that describe the state of the DFS root or link; - /// the state of the DFS namespace root cannot be changed. - /// One flag is set, and one DFS_VOLUME_FLAVOR flag is set. - /// - [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [Flags] - public enum DfsVolumeStates - { - /// No volume state. - None = 0, - - /// DFS_VOLUME_STATE_OK - /// The specified DFS root or link is in the normal state. - /// - Ok = 1, - - /// DFS_VOLUME_STATE_INCONSISTENT - /// The internal DFS database is inconsistent with the specified DFS root or link. - /// Attempts to repair the inconsistency have failed. - /// - Inconsistent = 2, - - /// DFS_VOLUME_STATE_OFFLINE - /// The specified DFS root or link is offline or unavailable. - /// - Offline = 3, - - /// DFS_VOLUME_STATE_ONLINE - /// The specified DFS root or link is available. - /// - Online = 4, - - /// DFS_VOLUME_FLAVOR_STANDALONE - /// The system sets this flag if the root is associated with a stand-alone DFS namespace. - /// - /// Windows XP: This value is not supported. - FlavorStandalone = 256, - - /// DFS_VOLUME_FLAVOR_AD_BLOB - /// The system sets this flag if the root is associated with a domain-based DFS namespace. - /// - /// Windows XP: This value is not supported. - FlavorAdBlob = 512 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ShareInfoLevel.cs b/FolderMonitor/AlphaFS/Network/Enumerations/ShareInfoLevel.cs deleted file mode 100644 index d942fd4..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ShareInfoLevel.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Network -{ - /// The information level. - public enum ShareInfoLevel - { - /// No specific information level used. - None = 0, - - /// Contains information about the shared resource, including the name and type of the resource, and a comment associated with the resource. - Info1 = 1, - - /// Contains information about the shared resource, including the name, type, and permissions of the resource, comments associated with the resource, - /// the maximum number of concurrent connections, the number of current connections, the local path for the resource, and a password for the current connection. - /// - Info2 = 2, - - /// Contains information about the shared resource, including the server name, name of the resource, type, and permissions, - /// the number of connections, and other pertinent information. - /// - Info503 = 503, - - /// Contains information about the shared resource. - Info1005 = 1005 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ShareResourceTypes.cs b/FolderMonitor/AlphaFS/Network/Enumerations/ShareResourceTypes.cs deleted file mode 100644 index 42a69e3..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ShareResourceTypes.cs +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// Contains information about the shared resource. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [Flags] - public enum ShareResourceTypes - { - /// No specific resource type used. - None = 0, - - /// SHI1005_FLAGS_DFS - /// The specified share is present in a DFS tree structure. This flag cannot be set with NetShareSetInfo. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - Dfs = 1, - - /// SHI1005_FLAGS_DFS_ROOT - /// The specified share is the root volume in a DFS tree structure. This flag cannot be set with NetShareSetInfo. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - DfsRoot = 2, - - /// SHI1005_FLAGS_RESTRICT_EXCLUSIVE_OPENS - /// The specified share disallows exclusive file opens, where reads to an open file are disallowed. - /// - RestrictExclusiveOpens = 256, - - /// SHI1005_FLAGS_FORCE_SHARED_DELETE - /// Shared files in the specified share can be forcibly deleted. - /// - ForceSharedDelete = 512, - - /// SHI1005_FLAGS_ALLOW_NAMESPACE_CACHING - /// Clients are allowed to cache the namespace of the specified share. - /// - AllowNamespaceCaching = 1024, - - /// SHI1005_FLAGS_ACCESS_BASED_DIRECTORY_ENUM - /// The server will filter directory entries based on the access permissions that the user on the client computer has for the server on which the files reside. - /// Only files for which the user has read access and directories for which the user has FILE_LIST_DIRECTORY access will be returned. If the user has SeBackupPrivilege, all available information will be returned. - /// - /// This flag is supported only on servers running Windows Server 2003 with SP1 or later. - AccessBasedDirectoryEnum = 2048, - - /// SHI1005_FLAGS_FORCE_LEVELII_OPLOCK - /// Prevents exclusive caching modes that can cause delays for highly shared read-only data. - /// - /// This flag is supported only on servers running Windows Server 2008 R2 or later. - ForceLevel2OpLock = 4096, - - /// SHI1005_FLAGS_ENABLE_HASH - /// Enables server-side functionality needed for peer caching support. - /// Clients on high-latency or low-bandwidth connections can use alternate methods to retrieve data from peers if available, instead of sending requests to the server. - /// This is only supported on shares configured for manual caching (CSC_CACHE_MANUAL_REINT). - /// This flag is supported only on servers running Windows Server 2008 R2 or later. - EnableHash = 8192, - - /// SHI1005_FLAGS_ENABLE_CA (0X4000) - Enables server-side functionality needed for peer caching support. Clients on high-latency or low-bandwidth connections can use alternate methods to retrieve data from peers if available, instead of sending requests to the server. This is only supported on shares configured for manual caching (CSC_CACHE_MANUAL_REINT). - /// Windows 7, Windows Server 2008 R2, Windows Vista, Windows Server 2008, and Windows Server 2003: This flag is not supported. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ca")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ca")] - EnableCa = 16384 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ShareType.cs b/FolderMonitor/AlphaFS/Network/Enumerations/ShareType.cs deleted file mode 100644 index a35966f..0000000 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ShareType.cs +++ /dev/null @@ -1,79 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Network -{ - /// The type of the shared resource. - /// MSDN: 2.2.2.4 Share Types - /// http://msdn.microsoft.com/en-us/library/cc247110.aspx - /// - [SuppressMessage("Microsoft.Naming", "CA1714:FlagsEnumsShouldHavePluralNames")] - [SuppressMessage("Microsoft.Usage", "CA2217:DoNotMarkEnumsWithFlags")] - [SuppressMessage("Microsoft.Design", "CA1008:EnumsShouldHaveZeroValue")] - [Flags] // Needs Flags attribute to combine attributes. - public enum ShareType - { - /// Disk drive. - DiskTree = 0, - - /// Print queue. - PrintQueue = 1, - - /// Communication device. - Device = 2, - - /// Interprocess communication (IPC). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ipc")] - Ipc = 3, - - /// A cluster share. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Fs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fs")] - ClusterFs = 33554432, - - /// A Scale-Out cluster share. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Fs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Fs")] - ClusterSoFs = 67108864, - - /// A DFS share in a cluster. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - ClusterDfs = 134217728, - - - // The following table of values can be OR'd with the values in the preceding table to further specify the characteristics of a shared resource. - // It is possible to use both values in this OR operation. - - /// Special share reserved for interprocess communication (IPC$) or remote administration of the server (ADMIN$). - /// Can also refer to administrative shares such as C$, D$, E$, and so forth. - /// - Special = -2147483648, - - /// A temporary share that is not persisted for creation each time the file server initializes. - Temporary = 1073741824, - - /// Retriev all known - All = DiskTree | PrintQueue | Device | Ipc | ClusterFs | ClusterSoFs | ClusterDfs | Special | Temporary - } -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/DistributedFileSystem.cs b/FolderMonitor/AlphaFS/Network/Host Class/DistributedFileSystem.cs deleted file mode 100644 index 93409bc..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/DistributedFileSystem.cs +++ /dev/null @@ -1,295 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Net.NetworkInformation; -using System.Security; - -namespace Alphaleonis.Win32.Network -{/* - partial class Host - { - #region EnumerateDfsLinks - - /// Enumerates the DFS Links from a DFS namespace. - /// of DFS namespaces. - /// - /// - /// - /// The Universal Naming Convention (UNC) path of a DFS root or link. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dfs")] - [SecurityCritical] - public static IEnumerable EnumerateDfsLinks(string dfsName) - { - if (!NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - if (Utils.IsNullOrWhiteSpace(dfsName)) - throw new ArgumentNullException("dfsName"); - - var fd = new FunctionData(); - - return EnumerateNetworkObjectCore(fd, (NativeMethods.DFS_INFO_9 structure, SafeGlobalMemoryBufferHandle buffer) => - - new DfsInfo(structure), - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle1) => - { - totalEntries = 0; - return NativeMethods.NetDfsEnum(dfsName, 9, prefMaxLen, out buffer, out entriesRead, out resumeHandle1); - - }, false); - } - - #endregion // EnumerateDfsLinks - - #region EnumerateDfsRoot - - /// Enumerates the DFS namespaces from the local host. - /// of DFS Root namespaces from the local host. - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - public static IEnumerable EnumerateDfsRoot() - { - return EnumerateDfsRootCore(null, false); - } - - /// Enumerates the DFS namespaces from a host. - /// of DFS Root namespaces from a host. - /// - /// - /// The DNS or NetBIOS name of a host. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - public static IEnumerable EnumerateDfsRoot(string host, bool continueOnException) - { - return EnumerateDfsRootCore(host, continueOnException); - } - - #endregion // EnumerateDfsRoot - - #region EnumerateDomainDfsRoot - - /// Enumerates the DFS namespaces from the domain. - /// of DFS Root namespaces from the domain. - /// - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - public static IEnumerable EnumerateDomainDfsRoot() - { - return EnumerateDomainDfsRootCore(null, false); - } - - /// Enumerates the DFS namespaces from a domain. - /// of DFS Root namespaces from a domain. - /// - /// - /// A domain name. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - public static IEnumerable EnumerateDomainDfsRoot(string domain, bool continueOnException) - { - return EnumerateDomainDfsRootCore(domain, continueOnException); - } - - #endregion // EnumerateDomainDfsRoot - - - #region GetDfsClientInfo - - /// Gets information about a DFS root or link from the cache maintained by the DFS client. - /// A instance. - /// - /// - /// The Universal Naming Convention (UNC) path of a DFS root or link. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dfs")] - [SecurityCritical] - public static DfsInfo GetDfsClientInfo(string dfsName) - { - return GetDfsInfoCore(true, dfsName, null, null); - } - - /// Gets information about a DFS root or link from the cache maintained by the DFS client. - /// A instance. - /// - /// - /// The Universal Naming Convention (UNC) path of a DFS root or link. - /// The name of the DFS root target or link target server. - /// The name of the share corresponding to the DFS root target or link target. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dfs")] - [SecurityCritical] - public static DfsInfo GetDfsClientInfo(string dfsName, string serverName, string shareName) - { - return GetDfsInfoCore(true, dfsName, serverName, shareName); - } - - #endregion // GetDfsClientInfo - - #region GetDfsInfo - - /// Gets information about a specified DFS root or link in a DFS namespace. - /// A instance. - /// - /// - /// The Universal Naming Convention (UNC) path of a DFS root or link. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "dfs")] - [SecurityCritical] - public static DfsInfo GetDfsInfo(string dfsName) - { - return GetDfsInfoCore(false, dfsName, null, null); - } - - #endregion // GetDfsInfo - - - #region Internal Methods - - /// Enumerates the DFS namespaces from a host. - /// of DFS Root namespaces from a host. - /// - /// - /// - /// The DNS or NetBIOS name of a host. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - private static IEnumerable EnumerateDfsRootCore(string host, bool continueOnException) - { - if (!Filesystem.NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - return EnumerateNetworkObjectCore(new FunctionData(), (NativeMethods.DFS_INFO_300 structure, SafeGlobalMemoryBufferHandle buffer) => - - new DfsInfo { EntryPath = structure.DfsName }, - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - { - totalEntries = 0; - - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - string stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(Path.UncPrefix, string.Empty); - - return NativeMethods.NetDfsEnum(stripUnc, 300, prefMaxLen, out buffer, out entriesRead, out resumeHandle); - - }, continueOnException).Select(dfs => dfs.EntryPath); - } - - - /// Enumerates the DFS namespaces from a domain. - /// of DFS Root namespaces from a domain. - /// - /// - /// - /// A domain name. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [SecurityCritical] - private static IEnumerable EnumerateDomainDfsRootCore(string domain, bool continueOnException) - { - if (!Filesystem.NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - return EnumerateNetworkObjectCore(new FunctionData(), (NativeMethods.DFS_INFO_200 structure, SafeGlobalMemoryBufferHandle buffer) => - - new DfsInfo { EntryPath = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}{3}", Path.UncPrefix, NativeMethods.ComputerDomain, Path.DirectorySeparatorChar, structure.FtDfsName) }, - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - { - totalEntries = 0; - - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - string stripUnc = Utils.IsNullOrWhiteSpace(domain) ? NativeMethods.ComputerDomain : Path.GetRegularPathCore(domain, GetFullPathOptions.CheckInvalidPathChars, false).Replace(Path.UncPrefix, string.Empty); - - return NativeMethods.NetDfsEnum(stripUnc, 200, prefMaxLen, out buffer, out entriesRead, out resumeHandle); - - }, continueOnException).Select(dfs => dfs.EntryPath); - } - - - /// Retrieves information about a specified DFS root or link in a DFS namespace. - /// A instance. - /// - /// - /// - /// - /// retrieves information about a Distributed File System (DFS) root or link from the cache maintained by the - /// DFS client. When retrieves information about a specified Distributed File System (DFS) root or link in a - /// DFS namespace. - /// - /// The Universal Naming Convention (UNC) path of a DFS root or link. - /// - /// The name of the DFS root target or link target server. If is , this - /// parameter is always . - /// - /// - /// The name of the share corresponding to the DFS root target or link target. If is - /// , this parameter is always . - /// - [SecurityCritical] - private static DfsInfo GetDfsInfoCore(bool getFromClient, string dfsName, string serverName, string shareName) - { - if (!Filesystem.NativeMethods.IsAtLeastWindowsVista) - throw new PlatformNotSupportedException(Resources.Requires_Windows_Vista_Or_Higher); - - if (Utils.IsNullOrWhiteSpace(dfsName)) - throw new ArgumentNullException("dfsName"); - - serverName = Utils.IsNullOrWhiteSpace(serverName) ? null : serverName; - shareName = Utils.IsNullOrWhiteSpace(shareName) ? null : shareName; - - SafeGlobalMemoryBufferHandle safeBuffer; - - // Level 9 = DFS_INFO_9 - - uint lastError = getFromClient - ? NativeMethods.NetDfsGetClientInfo(dfsName, serverName, shareName, 9, out safeBuffer) - : NativeMethods.NetDfsGetInfo(dfsName, null, null, 9, out safeBuffer); - - if (lastError == Win32Errors.NERR_Success) - return new DfsInfo(safeBuffer.PtrToStructure(0)); - - throw new NetworkInformationException((int) lastError); - } - - #endregion // Internal Methods - } - - */ -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/DriveConnection.cs b/FolderMonitor/AlphaFS/Network/Host Class/DriveConnection.cs deleted file mode 100644 index f947cb4..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/DriveConnection.cs +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Net; - -namespace Alphaleonis.Win32.Network -{/* - /// Used to create a temporary connection to a network resource that will be disconnected once this instance is disposed. - public sealed class DriveConnection : IDisposable - { - #region Constructors - - /// Creates a temporary connection to a network resource. The function can redirect a local device to a network resource, using the current user credentials. - /// The network resource to connect to. The string can be up to MAX_PATH characters in length. - public DriveConnection(string remoteName) - { - Share = remoteName; - - LocalName = Host.ConnectDisconnectCore(new Host.ConnectDisconnectArguments - { - RemoteName = Share, - IsDeviceMap = true - }); - } - - /// Creates a temporary connection to a network resource. The function can redirect a local device to a network resource, using a user name and password. - /// The network resource to connect to. The string can be up to MAX_PATH characters in length. - /// - /// The user name for making the connection. If is , the function uses the default - /// user name. (The user context for the process provides the default user name) - /// - /// - /// The password to be used for making the network connection. If is , the function - /// uses the current default password associated with the user specified by . - /// - /// always pops-up an authentication dialog box. - public DriveConnection(string remoteName, string userName, string password, bool prompt) - { - Share = remoteName; - - LocalName = Host.ConnectDisconnectCore(new Host.ConnectDisconnectArguments - { - RemoteName = Share, - UserName = userName, - Password = password, - Prompt = prompt, - IsDeviceMap = true - }); - } - - /// Creates a temporary connection to a network resource. The function can redirect a local device to a network resource, can be supplied. - /// The network resource to connect to. The string can be up to MAX_PATH characters in length. - /// An instance of which provides credentials for password-based authentication schemes such as basic, digest, NTLM, and Kerberos authentication. - /// always pops-up an authentication dialog box. - public DriveConnection(string remoteName, NetworkCredential credentials, bool prompt) - { - Share = remoteName; - - LocalName = Host.ConnectDisconnectCore(new Host.ConnectDisconnectArguments - { - RemoteName = Share, - Credential = credentials, - Prompt = prompt, - IsDeviceMap = true - }); - } - - /// class destructor. - ~DriveConnection() - { - Dispose(false); - } - - #endregion // Constructors - - #region Methods - - #region Dispose - - /// Releases all resources used by the class. - public void Dispose() - { - GC.SuppressFinalize(this); - Dispose(true); - } - - [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "isDisposing")] - private void Dispose(bool isDisposing) - { - if (!Utils.IsNullOrWhiteSpace(LocalName)) - { - Host.ConnectDisconnectCore(new Host.ConnectDisconnectArguments - { - LocalName = LocalName, - Prompt = true, // Use value of prompt variable for force value. - IsDeviceMap = true, - IsDisconnect = true - }); - - LocalName = null; - } - } - - #endregion // Dispose - - #region ToString - - /// Returns the last available drive letter used for this connection. - /// A string that represents this instance. - public override string ToString() - { - return LocalName; - } - - #endregion // ToString - - #endregion // Methods - - #region Properties - - /// The last available drive letter used for this connection. - /// The last available drive letter used for this connection. - public string LocalName { get; private set; } - - /// The path originally specified by the user. - /// The path originally specified by the user. - public string Share { get; private set; } - - #endregion // Properties - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/EnumerateDrives.cs b/FolderMonitor/AlphaFS/Network/Host Class/EnumerateDrives.cs deleted file mode 100644 index 9f0dcbd..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/EnumerateDrives.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Net.NetworkInformation; -using System.Security; - -namespace Alphaleonis.Win32.Network -{/* - partial class Host - { - /// Enumerates drives from the local host. - /// drives from the local host. - /// - [SecurityCritical] - public static IEnumerable EnumerateDrives() - { - return EnumerateDrivesCore(null, false); - } - - /// Enumerates local drives from the specified host. - /// drives from the specified host. - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// - /// suppress any Exception that might be thrown as a result from a failure, - /// such as unavailable resources. - /// - [SecurityCritical] - public static IEnumerable EnumerateDrives(string host, bool continueOnException) - { - return EnumerateDrivesCore(host, continueOnException); - } - - - - /// Enumerates local drives from the specified host. - /// drives from the specified host. - /// - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// - /// suppress any Exception that might be thrown as a result from a failure, - /// such as unavailable resources. - /// - [SecurityCritical] - private static IEnumerable EnumerateDrivesCore(string host, bool continueOnException) - { - return EnumerateNetworkObjectCore(new FunctionData { EnumType = 1 }, (string structure, SafeGlobalMemoryBufferHandle buffer) => - - structure, - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resume) => - { - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - string stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(Path.UncPrefix, string.Empty); - - return NativeMethods.NetServerDiskEnum(stripUnc, 0, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resume); - - }, continueOnException); - } - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/EnumerateOpenResources.cs b/FolderMonitor/AlphaFS/Network/Host Class/EnumerateOpenResources.cs deleted file mode 100644 index cd98ecb..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/EnumerateOpenResources.cs +++ /dev/null @@ -1,113 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Security; - -namespace Alphaleonis.Win32.Network -{/* - partial class Host - { - #region EnumerateOpenResources - - /// Enumerates open resources from the local host. - /// open resources from the local host. - /// - /// - [SecurityCritical] - public static IEnumerable EnumerateOpenResources() - { - return EnumerateOpenResourcesCore(null, null, null, false); - } - - /// Enumerates open resources from the specified host. - /// open resources from the specified . - /// - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// - /// This parameter may be . Enumerates only resources that have the value of the basepath parameter as a prefix. - /// (A prefix is the portion of a path that comes before a backslash.) - /// - /// - /// This parameter may be . The name of the user or the name of the connection; If - /// does not begin with two backslashes ("\\") it indicates the name of the user. If begins with two - /// backslashes ("\\") it indicates the name of the connection. - /// - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static IEnumerable EnumerateOpenResources(string host, string basePath, string typeName, bool continueOnException) - { - return EnumerateOpenResourcesCore(host, basePath, typeName, continueOnException); - } - - #endregion // EnumerateOpenResources - - - #region Internal Methods - - /// >Enumerates open resources from the specified host. - /// open resources from the specified . - /// - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// - /// This parameter may be . Enumerates only resources that have the value of the basepath parameter as a prefix. - /// (A prefix is the portion of a path that comes before a backslash.) - /// - /// - /// This parameter may be . The name of the user or the name of the connection; If - /// does not begin with two backslashes ("\\") it indicates the name of the user. If begins with two - /// backslashes ("\\") it indicates the name of the connection. - /// - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - private static IEnumerable EnumerateOpenResourcesCore(string host, string basePath, string typeName, bool continueOnException) - { - basePath = Utils.IsNullOrWhiteSpace(basePath) ? null : Path.GetRegularPathCore(basePath, GetFullPathOptions.CheckInvalidPathChars, false); - typeName = Utils.IsNullOrWhiteSpace(typeName) ? null : typeName; - - - var fd = new FunctionData { ExtraData1 = basePath, ExtraData2 = typeName }; - - return EnumerateNetworkObjectCore(fd, (NativeMethods.FILE_INFO_3 structure, SafeGlobalMemoryBufferHandle buffer) => - - new OpenResourceInfo(host, structure), - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - { - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - string stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(Path.UncPrefix, string.Empty); - - return NativeMethods.NetFileEnum(stripUnc, fd.ExtraData1, fd.ExtraData2, 3, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle); - - }, - continueOnException); - } - - #endregion // Internal Methods - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/Host.cs b/FolderMonitor/AlphaFS/Network/Host Class/Host.cs deleted file mode 100644 index 85e5e79..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/Host.cs +++ /dev/null @@ -1,149 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.IO; -using System.Net; -using System.Net.NetworkInformation; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; -using Path = System.IO.Path ; -using FolderMonitor; - -namespace Alphaleonis.Win32.Network -{ - /// Provides static methods to retrieve network resource information from a local- or remote host. - public static partial class Host - { - #region GetUncName - - /// Return the host name in UNC format, for example: \\hostname. - /// The unc name. - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static string GetUncName() - { - return string.Format(CultureInfo.InvariantCulture, "{0}{1}", MyExtensions .UncPrefix, Environment.MachineName); - } - - /// Return the host name in UNC format, for example: \\hostname. - /// Name of the computer. - /// The unc name. - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] - [SecurityCritical] - public static string GetUncName(string computerName) - { - return Utils.IsNullOrWhiteSpace(computerName) - ? GetUncName() - : (computerName.StartsWith(MyExtensions .UncPrefix, StringComparison.OrdinalIgnoreCase) - ? computerName.Trim() - : MyExtensions.UncPrefix + computerName.Trim()); - } - - #endregion // GetUncName - - #region Internal Methods - - private delegate uint EnumerateNetworkObjectDelegate( - FunctionData functionData, out SafeGlobalMemoryBufferHandle netApiBuffer, [MarshalAs(UnmanagedType.I4)] int prefMaxLen, - [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint totalEntries, - [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - - /// Structure is used to pass additional data to the Win32 function. - private struct FunctionData - { - public int EnumType; - public string ExtraData1; - public string ExtraData2; - } - - [SecurityCritical] - private static IEnumerable EnumerateNetworkObjectCore(FunctionData functionData, Func createTStruct, EnumerateNetworkObjectDelegate enumerateNetworkObject, bool continueOnException) - { - Type objectType; - int objectSize; - bool isString; - - switch (functionData.EnumType) - { - // Logical Drives - case 1: - objectType = typeof(IntPtr); - isString = true; - objectSize = Marshal.SizeOf(objectType) + UnicodeEncoding.CharSize; - break; - - default: - objectType = typeof(TNative); - isString = objectType == typeof(string); - objectSize = isString ? 0 : Marshal.SizeOf(objectType); - break; - } - - - uint lastError; - do - { - uint entriesRead; - uint totalEntries; - uint resumeHandle; - SafeGlobalMemoryBufferHandle buffer; - - lastError = enumerateNetworkObject(functionData, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle); - - using (buffer) - switch (lastError) - { - case Win32Errors.NERR_Success: - case Win32Errors.ERROR_MORE_DATA: - if (entriesRead > 0) - { - for (int i = 0, itemOffset = 0; i < entriesRead; i++, itemOffset += objectSize) - yield return (TStruct) (isString - ? buffer.PtrToStringUni(itemOffset, 2) - : (object) createTStruct(buffer.PtrToStructure(itemOffset), buffer)); - } - break; - - case Win32Errors.ERROR_BAD_NETPATH: - break; - - // Observed when SHARE_INFO_503 is requested but not supported/possible. - case Win32Errors.RPC_X_BAD_STUB_DATA: - yield break; - } - - } while (lastError == Win32Errors.ERROR_MORE_DATA); - - if (lastError != Win32Errors.NO_ERROR && !continueOnException) - throw new NetworkInformationException((int) lastError); - } - - - - #endregion // Internal Methods - } -} diff --git a/FolderMonitor/AlphaFS/Network/Host Class/ServerMessageBlock.cs b/FolderMonitor/AlphaFS/Network/Host Class/ServerMessageBlock.cs deleted file mode 100644 index 32c63c2..0000000 --- a/FolderMonitor/AlphaFS/Network/Host Class/ServerMessageBlock.cs +++ /dev/null @@ -1,395 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - - -using System; -using System.IO; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Net.NetworkInformation; -using System.Security; -using FolderMonitor; - -namespace Alphaleonis.Win32.Network -{/* - partial class Host - { - #region EnumerateOpenConnections - - /// Enumerates open connections from the local host. - /// connection information from the local host. - /// - /// - [SecurityCritical] - public static IEnumerable EnumerateOpenConnections() - { - return EnumerateOpenConnectionsCore(null, null, false); - } - - /// Enumerates open connections from the specified host. - /// connection information from the specified . - /// - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// The name of the Server Message Block (SMB) share. - /// - /// suppress any Exception that might be thrown as a result from a failure, - /// such as unavailable resources. - /// - [SecurityCritical] - public static IEnumerable EnumerateOpenConnections(string host, string share, bool continueOnException) - { - return EnumerateOpenConnectionsCore(host, share, continueOnException); - } - - #endregion // EnumerateOpenConnections - - #region EnumerateShares - - /// Enumerates Server Message Block (SMB) shares from the local host. - /// shares from the specified host. - /// This method also enumerates hidden shares. - [SecurityCritical] - public static IEnumerable EnumerateShares() - { - return EnumerateSharesCore(null, ShareType.All, false); - } - - /// Enumerates Server Message Block (SMB) shares from the local host. - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static IEnumerable EnumerateShares(bool continueOnException) - { - return EnumerateSharesCore(null, ShareType.All, continueOnException); - } - - /// Enumerates Server Message Block (SMB) shares from the local host. - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// The type of the shared resource to retrieve. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static IEnumerable EnumerateShares(ShareType shareType, bool continueOnException) - { - return EnumerateSharesCore(null, shareType, continueOnException); - } - - /// Enumerates Server Message Block (SMB) shares from the specified . - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// The DNS or NetBIOS name of the specified host. - [SecurityCritical] - public static IEnumerable EnumerateShares(string host) - { - return EnumerateSharesCore(host, ShareType.All, false); - } - - /// Enumerates Server Message Block (SMB) shares from the specified . - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// The DNS or NetBIOS name of the specified host. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static IEnumerable EnumerateShares(string host, bool continueOnException) - { - return EnumerateSharesCore(host, ShareType.All, continueOnException); - } - - /// Enumerates Server Message Block (SMB) shares from the specified . - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// The DNS or NetBIOS name of the specified host. - /// The type of the shared resource to retrieve. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static IEnumerable EnumerateShares(string host, ShareType shareType, bool continueOnException) - { - return EnumerateSharesCore(host, shareType, continueOnException); - } - - #endregion // EnumerateShares - - #region GetHostShareFromPath - - /// Gets the host and share path name for the given . - /// The share in the format: \\host\share. - /// The host and share path. For example, if is: "\\SERVER001\C$\WINDOWS\System32", - /// its is returned as string[0] = "SERVER001" and string[1] = "\C$\WINDOWS\System32". - /// If the conversion from local path to UNC path fails, is returned. - /// - [SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Justification = "Utils.IsNullOrWhiteSpace validates arguments.")] - [SecurityCritical] - public static string[] GetHostShareFromPath(string uncPath) - { - if (Utils.IsNullOrWhiteSpace(uncPath)) - return null; - - Uri uri; - if (Uri.TryCreate(Path.GetRegularPathCore(uncPath, GetFullPathOptions.None, false), UriKind.Absolute, out uri) && uri.IsUnc) - { - return new[] - { - uri.Host, - uri.AbsolutePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar) - }; - } - - return null; - } - - #endregion // GetHostShareFromPath - - #region GetShareInfo - - /// Retrieves information about the Server Message Block (SMB) share as defined on the specified host. - /// A class, or on failure or when not available, and is . - /// The share in the format: \\host\share. - /// to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static ShareInfo GetShareInfo(string uncPath, bool continueOnException) - { - var unc = GetHostShareFromPath(uncPath); - return GetShareInfoCore(ShareInfoLevel.Info503, unc[0], unc[1], continueOnException); - } - - /// Retrieves information about the Server Message Block (SMB) share as defined on the specified host. - /// A class, or on failure or when not available, and is . - /// One of the options. - /// The share in the format: \\host\share. - /// to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static ShareInfo GetShareInfo(ShareInfoLevel shareLevel, string uncPath, bool continueOnException) - { - var unc = GetHostShareFromPath(uncPath); - return GetShareInfoCore(shareLevel, unc[0], unc[1], continueOnException); - } - - /// Retrieves information about the Server Message Block (SMB) share as defined on the specified host. - /// A class, or on failure or when not available, and is . - /// The DNS or NetBIOS name of the specified host. - /// The name of the Server Message Block (SMB) share. - /// to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static ShareInfo GetShareInfo(string host, string share, bool continueOnException) - { - return GetShareInfoCore(ShareInfoLevel.Info503, host, share, continueOnException); - } - - /// Retrieves information about the Server Message Block (SMB) share as defined on the specified host. - /// A class, or on failure or when not available, and is . - /// One of the options. - /// A string that specifies the DNS or NetBIOS name of the specified . - /// A string that specifies the name of the Server Message Block (SMB) share. - /// to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - public static ShareInfo GetShareInfo(ShareInfoLevel shareLevel, string host, string share, bool continueOnException) - { - return GetShareInfoCore(shareLevel, host, share, continueOnException); - } - - #endregion // GetShareInfo - - #region Internal Methods - - #region EnumerateOpenConnectionsCore - - /// Enumerates open connections from the specified host and . - /// connection information from the specified . - /// - /// - /// The DNS or NetBIOS name of the remote server. refers to the local host. - /// The name of the Server Message Block (SMB) share. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - private static IEnumerable EnumerateOpenConnectionsCore(string host, string share, bool continueOnException) - { - if (Utils.IsNullOrWhiteSpace(share)) - throw new ArgumentNullException("share"); - - return EnumerateNetworkObjectCore(new FunctionData { ExtraData1 = share }, (NativeMethods.CONNECTION_INFO_1 structure, SafeGlobalMemoryBufferHandle buffer) => - - new OpenConnectionInfo(host, structure), - - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - { - // When host == null, the local computer is used. - // However, the resulting OpenResourceInfo.Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - string stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(MyExtensions.UncPrefix, string.Empty); - - return NativeMethods.NetConnectionEnum(stripUnc, functionData.ExtraData1, 1, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle); - - }, - - continueOnException); - } - - #endregion // EnumerateOpenConnectionsCore - - #region EnumerateSharesCore - - /// Enumerates Server Message Block (SMB) shares from a local or remote host. - /// shares from the specified host. - /// This method also enumerates hidden shares. - /// - /// - /// The DNS or NetBIOS name of the specified host. - /// The type of the shared resource to retrieve. - /// suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - internal static IEnumerable EnumerateSharesCore(string host, ShareType shareType, bool continueOnException) - { - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - var stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(MyExtensions.UncPrefix, string.Empty); - - var fd = new FunctionData(); - var hasItems = false; - var yieldAll = shareType == ShareType.All; - - // Try SHARE_INFO_503 structure. - foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_503 structure, SafeGlobalMemoryBufferHandle buffer) => - new ShareInfo(stripUnc, ShareInfoLevel.Info503, structure), - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - NativeMethods.NetShareEnum(stripUnc, 503, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType)) - { - yield return si; - hasItems = true; - } - - // SHARE_INFO_503 is requested, but not supported/possible. - // Try again with SHARE_INFO_2 structure. - if (!hasItems) - foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_2 structure, SafeGlobalMemoryBufferHandle buffer) => - new ShareInfo(stripUnc, ShareInfoLevel.Info2, structure), - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - NativeMethods.NetShareEnum(stripUnc, 2, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType)) - { - yield return si; - hasItems = true; - } - - // SHARE_INFO_2 is requested, but not supported/possible. - // Try again with SHARE_INFO_1 structure. - if (!hasItems) - foreach (var si in EnumerateNetworkObjectCore(fd, (NativeMethods.SHARE_INFO_1 structure, SafeGlobalMemoryBufferHandle buffer) => - new ShareInfo(stripUnc, ShareInfoLevel.Info1, structure), - (FunctionData functionData, out SafeGlobalMemoryBufferHandle buffer, int prefMaxLen, out uint entriesRead, out uint totalEntries, out uint resumeHandle) => - NativeMethods.NetShareEnum(stripUnc, 1, out buffer, NativeMethods.MaxPreferredLength, out entriesRead, out totalEntries, out resumeHandle), continueOnException).Where(si => yieldAll || si.ShareType == shareType)) - { - yield return si; - } - } - - #endregion // EnumerateSharesCore - - #region GetShareInfoCore - - /// Gets the structure of a Server Message Block (SMB) share. - /// A class, or on failure or when not available, and is . - /// - /// One of the options. - /// A string that specifies the DNS or NetBIOS name of the specified . - /// A string that specifies the name of the Server Message Block (SMB) share. - /// to suppress any Exception that might be thrown as a result from a failure, such as unavailable resources. - [SecurityCritical] - internal static ShareInfo GetShareInfoCore(ShareInfoLevel shareLevel, string host, string share, bool continueOnException) - { - if (Utils.IsNullOrWhiteSpace(share)) - return null; - - // When host == null, the local computer is used. - // However, the resulting Host property will be empty. - // So, explicitly state Environment.MachineName to prevent this. - // Furthermore, the UNC prefix: \\ is not required and always removed. - var stripUnc = Utils.IsNullOrWhiteSpace(host) ? Environment.MachineName : Path.GetRegularPathCore(host, GetFullPathOptions.CheckInvalidPathChars, false).Replace(MyExtensions.UncPrefix, string.Empty); - - var fallback = false; - - - startNetShareGetInfo: - - SafeGlobalMemoryBufferHandle safeBuffer; - - uint structureLevel = Convert.ToUInt16(shareLevel, CultureInfo.InvariantCulture); - var lastError = NativeMethods.NetShareGetInfo(stripUnc, share, structureLevel, out safeBuffer); - - using (safeBuffer) - { - switch (lastError) - { - case Win32Errors.NERR_Success: - switch (shareLevel) - { - case ShareInfoLevel.Info1005: - return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0)) - { - NetFullPath = Path.Combine(false, MyExtensions.UncPrefix + stripUnc, share) - }; - - case ShareInfoLevel.Info503: - return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0)); - - case ShareInfoLevel.Info2: - return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0)); - - case ShareInfoLevel.Info1: - return new ShareInfo(stripUnc, shareLevel, safeBuffer.PtrToStructure(0)); - } - break; - - - // Observed when SHARE_INFO_503 is requested, but not supported/possible. - // Fall back on SHARE_INFO_2 structure and try again. - case Win32Errors.RPC_X_BAD_STUB_DATA: - - case Win32Errors.ERROR_ACCESS_DENIED: - if (!fallback && shareLevel != ShareInfoLevel.Info2) - { - shareLevel = ShareInfoLevel.Info2; - fallback = true; - goto startNetShareGetInfo; - } - break; - - default: - if (!continueOnException) - throw new NetworkInformationException((int) lastError); - break; - } - - return null; - } - } - - #endregion // GetShareInfoCore - - #endregion // Internal Methods - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.DistributedFileSystem.cs b/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.DistributedFileSystem.cs deleted file mode 100644 index 7ddf229..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.DistributedFileSystem.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace FolderMonitor.Network -{ - internal static partial class NativeMethods - { - /// Enumerates the Distributed File System (DFS) namespaces hosted on a server or DFS links of a namespace hosted by a server. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// No special group membership is required for using the NetDfsEnum function. - /// Minimum supported client: Windows Vista - /// Minimum supported server: Windows Server 2003 - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetDfsEnum([MarshalAs(UnmanagedType.LPWStr)] string dfsName, [MarshalAs(UnmanagedType.U4)] uint level, [MarshalAs(UnmanagedType.U4)] int prefMaxLen, out SafeGlobalMemoryBufferHandle buffer, [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - - - /// Retrieves information about a Distributed File System (DFS) root or link from the cache maintained by the DFS client. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// No special group membership is required for using the NetDfsGetClientInfo function. - /// Minimum supported client: Windows Vista - /// Minimum supported server: Windows Server 2003 - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetDfsGetClientInfo([MarshalAs(UnmanagedType.LPWStr)] string dfsEntryPath, [MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string shareName, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle buffer); - - - /// Retrieves information about a specified Distributed File System (DFS) root or link in a DFS namespace. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// No special group membership is required for using the NetDfsGetInfo function. - /// Minimum supported client: Windows Vista - /// Minimum supported server: Windows Server 2003 - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetDfsGetInfo([MarshalAs(UnmanagedType.LPWStr)] string dfsEntryPath, [MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string shareName, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle buffer); - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkManagement.cs b/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkManagement.cs deleted file mode 100644 index 11dda12..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkManagement.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace FolderMonitor.Network -{ - partial class NativeMethods - { - /// The NetServerDiskEnum function retrieves a list of disk drives on a server. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// The function returns an array of three-character strings (a drive letter, a colon, and a terminating null character). - /// Only members of the Administrators or Server Operators local group can successfully execute the NetServerDiskEnum function on a remote computer. - /// Minimum supported client: Windows 2000 Professional [desktop apps only] - /// Minimum supported server: Windows 2000 Server [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetServerDiskEnum([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle bufPtr, [MarshalAs(UnmanagedType.I4)] int prefMaxLen, [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint totalEntries, [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkShareManagement.cs b/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkShareManagement.cs deleted file mode 100644 index dddbd48..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.NetworkShareManagement.cs +++ /dev/null @@ -1,117 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace FolderMonitor.Network -{ - partial class NativeMethods - { - /// Lists all connections made to a shared resource on the server or all connections established from a particular computer. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// If there is more than one user using this connection, then it is possible to get more than one structure for the same connection, but with a different user name. - /// Administrator, Server or Print Operator, or Power User group membership is required to successfully execute the NetConnectionEnum function. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetConnectionEnum([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string qualifier, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle bufPtr, [MarshalAs(UnmanagedType.I4)] int prefMaxLen, [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint totalEntries, [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - - - /// Forces a resource to close. This function can be used when an error prevents closure by any other means. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// You should use NetFileClose with caution because it does not write data cached on the client system to the file before closing the file. - /// Only members of the Administrators or Server Operators local group can successfully execute the NetFileEnum function. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetFileClose([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.U4)] uint fileid); - - - /// Returns information about some or all open files on a server, depending on the parameters specified. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// Only members of the Administrators or Server Operators local group can successfully execute the NetFileEnum function. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetFileEnum([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string basepath, [MarshalAs(UnmanagedType.LPWStr)] string username, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle buffer, [MarshalAs(UnmanagedType.I4)] int prefmaxlen, [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint totalentries, [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - - - /// Retrieves information about each (hidden) Server Message Block (SMB) resource/share on a server. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// For interactive users (users who are logged on locally to the machine), no special group membership is required to execute the NetShareEnum function. - /// For non-interactive users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareEnum function at levels 2, 502, and 503. No special group membership is required for level 0 or level 1 calls. - /// This function applies only to Server Message Block (SMB) shares. - /// Windows Server 2003 and Windows XP: For all users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareEnum function at levels 2 and 502. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetShareEnum([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle bufPtr, [MarshalAs(UnmanagedType.I4)] int prefMaxLen, [MarshalAs(UnmanagedType.U4)] out uint entriesRead, [MarshalAs(UnmanagedType.U4)] out uint totalEntries, [MarshalAs(UnmanagedType.U4)] out uint resumeHandle); - - - /// Retrieves information about a particular Server Message Block (SMB) shared resource on a server. - /// - /// If the function succeeds, the return value is NERR_Success. - /// If the function fails, the return value is a system error code. - /// - /// - /// For interactive users (users who are logged on locally to the machine), no special group membership is required to execute the NetShareGetInfo function. - /// For non-interactive users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareGetInfo function at levels 2, 502, and 503. - /// This function applies only to Server Message Block (SMB) shares. - /// Windows Server 2003 and Windows XP: For all users, Administrator, Power User, Print Operator, or Server Operator group membership is required to successfully execute the NetShareGetInfo function at levels 2 and 502. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("netapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint NetShareGetInfo([MarshalAs(UnmanagedType.LPWStr)] string serverName, [MarshalAs(UnmanagedType.LPWStr)] string netName, [MarshalAs(UnmanagedType.U4)] uint level, out SafeGlobalMemoryBufferHandle lpBuffer); - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.cs b/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.cs deleted file mode 100644 index fc33f77..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.cs +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Net; - -namespace FolderMonitor.Network -{ - internal static partial class NativeMethods - { - #region Constants - - /// A constant of type DWORD that is set to –1. This value is valid as an input parameter to any method in section 3.1.4 that takes a PreferedMaximumLength parameter. When specified as an input parameter, this value indicates that the method MUST allocate as much space as the data requires. - /// MSDN "2.2.2.2 MAX_PREFERRED_LENGTH": http://msdn.microsoft.com/en-us/library/cc247107.aspx - internal const int MaxPreferredLength = -1; - - #endregion // Constants - - #region GetComputerDomain - - internal static readonly string ComputerDomain = GetComputerDomain(); - - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - private static string GetComputerDomain(bool fdqn = false) - { - string domain = Environment.UserDomainName; - string machine = Environment.MachineName.ToUpper(CultureInfo.InvariantCulture); - - try - { - if (fdqn) - { - domain = Dns.GetHostEntry("LocalHost").HostName.ToUpper(CultureInfo.InvariantCulture).Replace(machine + ".", string.Empty); - domain = domain.Replace(machine, string.Empty); - } - } - catch - { - } - - return domain; - } - - #endregion // GetComputerDomain - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/CONNECTION_INFO_1.cs b/FolderMonitor/AlphaFS/Network/Native Structures/CONNECTION_INFO_1.cs deleted file mode 100644 index 35343b5..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/CONNECTION_INFO_1.cs +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the identification number of a connection, number of open files, connection time, number of users on the connection, and the type of connection. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct CONNECTION_INFO_1 - { - /// Specifies a connection identification number. - [MarshalAs(UnmanagedType.U4)] public readonly uint coni1_id; - - /// A combination of values that specify the type of connection made from the local device name to the shared resource. - [MarshalAs(UnmanagedType.U4)] public readonly ShareType coni1_type; - - /// Specifies the number of files currently open as a result of the connection. - [MarshalAs(UnmanagedType.U4)] public readonly uint coni1_num_opens; - - /// Specifies the number of users on the connection. - [MarshalAs(UnmanagedType.U4)] public readonly uint coni1_num_users; - - /// Specifies the number of seconds that the connection has been established. - [MarshalAs(UnmanagedType.U4)] public readonly uint coni1_time; - - /// If the server sharing the resource is running with user-level security, the UserName member describes which user made the connection. If the server is running with share-level security, coni1_username describes which computer (computername) made the connection. - /// Note that Windows does not support share-level security. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string coni1_username; - - /// String that specifies either the share name of the server's shared resource or the computername of the client. The value of this member depends on which name was specified as the qualifier parameter to the NetConnectionEnum function. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string oni1_netname; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_200.cs b/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_200.cs deleted file mode 100644 index 585cc2b..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_200.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the name of a domain-based Distributed File System (DFS) namespace. - /// This structure is only for use with the NetDfsEnum, NetDfsGetClientInfo, and NetDfsGetInfo functions. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct DFS_INFO_200 - { - /// The name of a domain-based DFS namespace. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string FtDfsName; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_300.cs b/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_300.cs deleted file mode 100644 index 345b888..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_300.cs +++ /dev/null @@ -1,53 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the name and type (domain-based or stand-alone) of a DFS namespace. - /// The DFS functions use the structure to enumerate DFS namespaces hosted on a machine. - /// Minimum supported client: Windows XP with SP1 [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct DFS_INFO_300 - { - /// Value that specifies the type of the DFS namespace. This member can be one of the values. - [SuppressMessage("Microsoft.Naming", "CA1726:UsePreferredTerms", MessageId = "Flags")] - [MarshalAs(UnmanagedType.U4)] public readonly DfsNamespaceFlavors Flags; - - /// The name of a DFS namespace. - /// This member can have one of the following two formats: - /// The first format is: \ServerName\DfsName - /// where ServerName is the name of the root target server that hosts the stand-alone DFS namespace and DfsName is the name of the DFS namespace. - /// The second format is: - /// \DomainName\DomDfsName - /// where DomainName is the name of the domain that hosts the domain-based DFS namespace and DomDfsname is the name of the DFS namespace. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [MarshalAs(UnmanagedType.LPWStr)] public readonly string DfsName; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_9.cs b/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_9.cs deleted file mode 100644 index 5cdde49..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_INFO_9.cs +++ /dev/null @@ -1,77 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the name, status, GUID, time-out, property flags, metadata size, DFS target information, link reparse point security descriptor, and a list of DFS targets for a root or link. - /// Minimum supported client: Windows Vista with SP1 - /// Minimum supported server: Windows Server 2008 - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Dfs")] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct DFS_INFO_9 - { - /// The Universal Naming Convention (UNC) path of a DFS root or link. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string EntryPath; - - /// The comment associated with the DFS root or link. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string Comment; - - /// A that specifies a set of bit flags that describe the DFS root or link. - [MarshalAs(UnmanagedType.U4)] public readonly DfsVolumeStates State; - - /// Specifies the time-out, in seconds, of the DFS root or link. - [MarshalAs(UnmanagedType.U4)] public readonly uint Timeout; - - /// Specifies the GUID of the DFS root or link. - public readonly Guid Guid; - - /// Specifies a set of flags that describe specific properties of a DFS namespace, root, or link. - [MarshalAs(UnmanagedType.U4)] public readonly DfsPropertyFlags PropertyFlags; - - /// For domain-based DFS namespaces, this member specifies the size of the corresponding Active Directory data blob, in bytes. - /// For stand-alone DFS namespaces, this field specifies the size of the metadata stored in the registry, - /// including the key names and value names, in addition to the specific data items associated with them. - /// This field is valid for DFS roots only. - /// - [MarshalAs(UnmanagedType.U4)] public readonly uint MetadataSize; - - /// This member is reserved for system use. - [MarshalAs(UnmanagedType.U4)] public readonly uint SdLengthReserved; - - /// Pointer to a SECURITY_DESCRIPTOR structure that specifies a self-relative security descriptor to be associated with the DFS link's reparse point. - /// This field is valid for DFS links only. - /// - public IntPtr pSecurityDescriptor; - - /// Specifies the number of DFS targets. - [MarshalAs(UnmanagedType.U4)] public readonly uint NumberOfStorages; - - /// An array of structures. - public readonly IntPtr Storage; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_STORAGE_INFO_1.cs b/FolderMonitor/AlphaFS/Network/Native Structures/DFS_STORAGE_INFO_1.cs deleted file mode 100644 index 6078678..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_STORAGE_INFO_1.cs +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains information about a DFS target, including the DFS target server name and share name as well as the target's state and priority. - /// Minimum supported client: Windows Vista - /// Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct DFS_STORAGE_INFO_1 - { - /// State of the target. - [MarshalAs(UnmanagedType.U4)] public readonly DfsStorageStates State; - - /// The DFS root target or link target server name. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string ServerName; - - /// The DFS root target or link target share name. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string ShareName; - - /// DFS_TARGET_PRIORITY structure that contains a DFS target's priority class and rank. - [MarshalAs(UnmanagedType.Struct)] public readonly DFS_TARGET_PRIORITY TargetPriority; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_TARGET_PRIORITY.cs b/FolderMonitor/AlphaFS/Network/Native Structures/DFS_TARGET_PRIORITY.cs deleted file mode 100644 index 14bdb97..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/DFS_TARGET_PRIORITY.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the priority class and rank of a specific DFS target. - /// Minimum supported client: Windows Vista - /// Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct DFS_TARGET_PRIORITY - { - /// DFS_TARGET_PRIORITY_CLASS enumeration value that specifies the priority class of the target. - [MarshalAs(UnmanagedType.I4)] public readonly DfsTargetPriorityClass TargetPriorityClass; - - /// Specifies the priority rank value of the target. The default value is 0, which indicates the highest priority rank within a priority class. - public readonly ushort TargetPriorityRank; - - /// This member is reserved and must be zero. - public readonly ushort Reserved; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/FILE_INFO_3.cs b/FolderMonitor/AlphaFS/Network/Native Structures/FILE_INFO_3.cs deleted file mode 100644 index 9b9220b..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/FILE_INFO_3.cs +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains the identifier and other pertinent information about files, devices, and pipes. - /// This structure is only for use with the NetFileEnum function. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct FILE_INFO_3 - { - /// The identification number assigned to the resource when it is opened. - [MarshalAs(UnmanagedType.U4)] public readonly uint fi3_id; - - /// The access permissions associated with the opening application. This member can be one or more of the following values. - [MarshalAs(UnmanagedType.U4)] public readonly AccessPermissions fi3_permissions; - - /// The number of file locks on the file, device, or pipe. - [MarshalAs(UnmanagedType.U4)] public readonly uint fi3_num_locks; - - /// The path of the opened resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string fi3_pathname; - - /// Specifies which user (on servers that have user-level security) or which computer (on servers that have share-level security) opened the resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string fi3_username; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/REMOTE_NAME_INFO.cs b/FolderMonitor/AlphaFS/Network/Native Structures/REMOTE_NAME_INFO.cs deleted file mode 100644 index 62e890e..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/REMOTE_NAME_INFO.cs +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - ///Contains path and name information for a network resource. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct REMOTE_NAME_INFO - { - /// Identifies a network resource. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] [MarshalAs(UnmanagedType.LPWStr)] public string lpUniversalName; - - /// The name of a network connection. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] [MarshalAs(UnmanagedType.LPWStr)] public string lpConnectionName; - - /// The remaing path. - [SuppressMessage("Microsoft.Design", "CA1051:DoNotDeclareVisibleInstanceFields")] [MarshalAs(UnmanagedType.LPWStr)] public string lpRemainingPath; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1.cs b/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1.cs deleted file mode 100644 index b1f8d2a..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1.cs +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains information about the shared resource, including the name and type of the resource, and a comment associated with the resource. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SHARE_INFO_1 - { - /// The name of a shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi1_netname; - - /// The type of share. - [MarshalAs(UnmanagedType.U4)] public readonly ShareType shi1_type; - - /// An optional comment about the shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi1_remark; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1005.cs b/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1005.cs deleted file mode 100644 index 8ab9eb2..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_1005.cs +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains information about the shared resource. - /// This structure can be retrieved by calling the NetShareGetInfo function. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SHARE_INFO_1005 - { - /// A bitmask of flags that specify information about the shared resource. - [MarshalAs(UnmanagedType.U4)] public readonly ShareResourceTypes shi1005_flags; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_2.cs b/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_2.cs deleted file mode 100644 index 9223623..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_2.cs +++ /dev/null @@ -1,65 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains information about the shared resource, including the name, type, and permissions of the resource, comments associated with the resource, - /// the maximum number of concurrent connections, the number of current connections, the local path for the resource, and a password for the current connection. - /// - /// Share information, NT, level 2, requires admin rights to work. - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SHARE_INFO_2 - { - /// The name of a shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi2_netname; - - /// The type of share. - [MarshalAs(UnmanagedType.U4)] public readonly ShareType shi2_type; - - /// An optional comment about the shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi2_remark; - - /// The shared resource's permissions for servers running with share-level security. - /// Note that Windows does not support share-level security. This member is ignored on a server running user-level security. - [MarshalAs(UnmanagedType.U4)] public readonly AccessPermissions shi2_permissions; - - /// The maximum number of concurrent connections that the shared resource can accommodate. - /// The number of connections is unlimited if the value specified in this member is –1. - [MarshalAs(UnmanagedType.U4)] public readonly uint shi2_max_uses; - - /// The number of current connections to the resource. - [MarshalAs(UnmanagedType.U4)] public readonly uint shi2_current_uses; - - /// The local path for the shared resource. - /// For disks, this member is the path being shared. For print queues, this member is the name of the print queue being shared. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi2_path; - - /// The share's password (when the server is running with share-level security). - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi2_passwd; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_503.cs b/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_503.cs deleted file mode 100644 index 4ac57d3..0000000 --- a/FolderMonitor/AlphaFS/Network/Native Structures/SHARE_INFO_503.cs +++ /dev/null @@ -1,75 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Network -{ - internal static partial class NativeMethods - { - /// Contains information about the shared resource, including the server name, name of the resource, type, and permissions, - /// the number of connections, and other pertinent information. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SHARE_INFO_503 - { - /// The name of a shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi503_netname; - - /// The type of share. - [MarshalAs(UnmanagedType.U4)] public readonly ShareType shi503_type; - - /// An optional comment about the shared resource. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi503_remark; - - /// The shared resource's permissions for servers running with share-level security. - /// Note that Windows does not support share-level security. This member is ignored on a server running user-level security. - [MarshalAs(UnmanagedType.U4)] public readonly AccessPermissions shi503_permissions; - - /// The maximum number of concurrent connections that the shared resource can accommodate. - /// The number of connections is unlimited if the value specified in this member is –1. - [MarshalAs(UnmanagedType.U4)] public readonly uint shi503_max_uses; - - /// The number of current connections to the resource. - [MarshalAs(UnmanagedType.U4)] public readonly uint shi503_current_uses; - - /// The local path for the shared resource. - /// For disks, this member is the path being shared. For print queues, this member is the name of the print queue being shared. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi503_path; - - /// The share's password (when the server is running with share-level security). - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi503_passwd; - - /// The DNS or NetBIOS name of the remote server on which the shared resource resides. - /// A value of "*" indicates no configured server name. - [MarshalAs(UnmanagedType.LPWStr)] public readonly string shi503_servername; - - /// Reserved; must be zero. - [MarshalAs(UnmanagedType.U4)] public readonly uint shi503_reserved; - - /// Specifies the SECURITY_DESCRIPTOR associated with this share. - public IntPtr shi503_security_descriptor; - } - } -} diff --git a/FolderMonitor/AlphaFS/Network/OpenConnectionInfo.cs b/FolderMonitor/AlphaFS/Network/OpenConnectionInfo.cs deleted file mode 100644 index 66653b7..0000000 --- a/FolderMonitor/AlphaFS/Network/OpenConnectionInfo.cs +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; - -namespace Alphaleonis.Win32.Network -{/* - /// Contains the identification number of a connection, number of open files, connection time, number of users on the connection, and the type of connection. - [SerializableAttribute] - public sealed class OpenConnectionInfo - { - #region Constructor - - /// Create a OpenConnectionInfo instance. - internal OpenConnectionInfo(string host, NativeMethods.CONNECTION_INFO_1 connectionInfo) - { - Host = host; - Id = connectionInfo.coni1_id; - ShareType = connectionInfo.coni1_type; - TotalOpenFiles = connectionInfo.coni1_num_opens; - TotalUsers = connectionInfo.coni1_num_users; - ConnectedSeconds = connectionInfo.coni1_time; - UserName = connectionInfo.coni1_username; - NetName = connectionInfo.oni1_netname.Replace(Path.LongPathUncPrefix, string.Empty).Replace(Path.UncPrefix, string.Empty); - } - - #endregion // Constructor - - #region Methods - - /// Returns the full path to the share. - /// A string that represents this instance. - public override string ToString() - { - return Id.ToString(CultureInfo.InvariantCulture); - } - - #endregion // Methods - - #region Properties - - /// The local or remote Host. - public string Host { get; private set; } - - /// Specifies a connection identification number. - public long Id { get; private set; } - - /// The type of share. - public ShareType ShareType { get; private set; } - - /// Specifies the number of files currently open as a result of the connection. - public long TotalOpenFiles { get; private set; } - - /// Specifies the number of users on the connection. - public long TotalUsers { get; private set; } - - /// Specifies the number of seconds that the connection has been established. - public long ConnectedSeconds { get; private set; } - - /// If the server sharing the resource is running with user-level security, the UserName member describes which user made the connection. If the server is running with share-level security, coni1_username describes which computer (computername) made the connection. - public string UserName { get; private set; } - - /// String that specifies either the share name of the server's shared resource or the computername of the client. The value of this member depends on which name was specified as the qualifier parameter to the NetConnectionEnum function. - public string NetName { get; private set; } - - #endregion // Properties - } - */ -} diff --git a/FolderMonitor/AlphaFS/Network/OpenResourceInfo.cs b/FolderMonitor/AlphaFS/Network/OpenResourceInfo.cs deleted file mode 100644 index 61628fe..0000000 --- a/FolderMonitor/AlphaFS/Network/OpenResourceInfo.cs +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; - -namespace Alphaleonis.Win32.Network -{ - /// Contains the identification number and other pertinent information about files, devices, and pipes. This class cannot be inherited. - [SerializableAttribute] - public sealed class OpenResourceInfo - { - #region Constructor - - /// Create a OpenResourceInfo instance. - internal OpenResourceInfo(string host, NativeMethods.FILE_INFO_3 fileInfo) - { - Host = host; - Id = fileInfo.fi3_id; - Permissions = fileInfo.fi3_permissions; - TotalLocks = fileInfo.fi3_num_locks; - PathName = fileInfo.fi3_pathname.Replace(@"\\", @"\"); - UserName = fileInfo.fi3_username; - } - - #endregion // Constructor - - #region Methods - - /// Forces the open resource to close. - /// You should this method with caution because it does not write data cached on the client system to the file before closing the file. - public void Close() - { - uint lastError = NativeMethods.NetFileClose(Host, (uint) Id); - if (lastError != Win32Errors.NERR_Success && lastError != Win32Errors.NERR_FileIdNotFound) - NativeError.ThrowException(lastError, Host, PathName); - } - - /// Returns the full path to the share. - /// A string that represents this instance. - public override string ToString() - { - return Id.ToString(CultureInfo.InvariantCulture); - } - - #endregion // Methods - - #region Properties - - /// The local or remote Host. - public string Host { get; private set; } - - /// The identification number assigned to the resource when it is opened. - public long Id { get; private set; } - - /// The path of the opened resource. - public string PathName { get; private set; } - - /// The access permissions associated with the opening application. This member can be one or more of the following values. - public AccessPermissions Permissions { get; private set; } - - /// The number of file locks on the file, device, or pipe. - public long TotalLocks { get; private set; } - - /// Specifies which user (on servers that have user-level security) or which computer (on servers that have share-level security) opened the resource. - public string UserName { get; private set; } - - #endregion // Properties - } -} diff --git a/FolderMonitor/AlphaFS/Network/ShareInfo.cs b/FolderMonitor/AlphaFS/Network/ShareInfo.cs deleted file mode 100644 index d1f80eb..0000000 --- a/FolderMonitor/AlphaFS/Network/ShareInfo.cs +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Globalization; - -namespace Alphaleonis.Win32.Network -{/* - /// Contains information about Server Message Block (SMB) shares. This class cannot be inherited. - [SerializableAttribute] - public sealed class ShareInfo - { - #region Constructor - - #region ShareInfo - - /// Creates a instance. - /// A host to retrieve shares from. - /// One of the options. - /// A or instance. - internal ShareInfo(string host, ShareInfoLevel shareLevel, object shareInfo) - { - switch (shareLevel) - { - case ShareInfoLevel.Info1005: - NativeMethods.SHARE_INFO_1005 s1005 = (NativeMethods.SHARE_INFO_1005) shareInfo; - ServerName = host ?? Environment.MachineName; - ResourceType = s1005.shi1005_flags; - break; - - case ShareInfoLevel.Info503: - NativeMethods.SHARE_INFO_503 s503 = (NativeMethods.SHARE_INFO_503) shareInfo; - CurrentUses = s503.shi503_current_uses; - MaxUses = s503.shi503_max_uses; - NetName = s503.shi503_netname; - Password = s503.shi503_passwd; - Path = Utils.IsNullOrWhiteSpace(s503.shi503_path) ? null : s503.shi503_path; - Permissions = s503.shi503_permissions; - Remark = s503.shi503_remark; - ServerName = s503.shi503_servername == "*" ? host ?? Environment.MachineName : s503.shi503_servername; - ShareType = s503.shi503_type; - SecurityDescriptor = s503.shi503_security_descriptor; - break; - - case ShareInfoLevel.Info2: - NativeMethods.SHARE_INFO_2 s2 = (NativeMethods.SHARE_INFO_2)shareInfo; - CurrentUses = s2.shi2_current_uses; - MaxUses = s2.shi2_max_uses; - NetName = s2.shi2_netname; - Password = s2.shi2_passwd; - Path = Utils.IsNullOrWhiteSpace(s2.shi2_path) ? null : s2.shi2_path; - Permissions = s2.shi2_permissions; - Remark = s2.shi2_remark; - ServerName = host ?? Environment.MachineName; - ShareType = s2.shi2_type; - break; - - case ShareInfoLevel.Info1: - NativeMethods.SHARE_INFO_1 s1 = (NativeMethods.SHARE_INFO_1)shareInfo; - CurrentUses = 0; - MaxUses = 0; - NetName = s1.shi1_netname; - Password = null; - Path = null; - Permissions = AccessPermissions.None; - Remark = s1.shi1_remark; - ServerName = host ?? Environment.MachineName; - ShareType = s1.shi1_type; - break; - } - - - NetFullPath = string.Format(CultureInfo.CurrentCulture, "{0}{1}{2}{3}", Filesystem.Path.UncPrefix, ServerName, Filesystem.Path.DirectorySeparatorChar, NetName); - - ShareLevel = shareLevel; - } - - #endregion // ShareInfo - - #endregion // Constructor - - #region Methods - - #region ToString - - /// Returns the full path to the share. - /// A string that represents this instance. - public override string ToString() - { - return NetFullPath; - } - - #endregion // ToString - - #endregion // Methods - - #region Properties - - #region CurrentUses - - /// The number of current connections to the resource. - public long CurrentUses { get; private set; } - - #endregion // CurrentUses - - #region DirectoryInfo - - private DirectoryInfo _directoryInfo; - - /// The instance associated with this share. - public DirectoryInfo DirectoryInfo - { - get - { - // Do not use ?? expression here. - if (_directoryInfo == null) - _directoryInfo = new DirectoryInfo(null, NetFullPath, PathFormat.FullPath); - - return _directoryInfo; - } - } - - #endregion // DirectoryInfo - - #region NetFullPath - - /// Returns the full UNC path to the share. - public string NetFullPath { get; internal set; } - - #endregion // NetFullPath - - #region MaxUses - - /// The maximum number of concurrent connections that the shared resource can accommodate. - /// The number of connections is unlimited if the value specified in this member is –1. - public long MaxUses { get; private set; } - - #endregion // MaxUses - - #region NetName - - /// The name of a shared resource. - public string NetName { get; private set; } - - #endregion // NetName - - #region Password - - /// The share's password (when the server is running with share-level security). - public string Password { get; private set; } - - #endregion // Password - - #region Path - - /// The local path for the shared resource. - /// For disks, this member is the path being shared. For print queues, this member is the name of the print queue being shared. - public string Path { get; private set; } - - #endregion // Path - - #region Permissions - - /// The shared resource's permissions for servers running with share-level security. - /// Note that Windows does not support share-level security. This member is ignored on a server running user-level security. - public AccessPermissions Permissions { get; private set; } - - #endregion // Permissions - - #region Remark - - /// An optional comment about the shared resource. - public string Remark { get; private set; } - - #endregion // Remark - - #region SecurityDescriptor - - /// Specifies the SECURITY_DESCRIPTOR associated with this share. - public IntPtr SecurityDescriptor { get; private set; } - - #endregion // SecurityDescriptor - - #region ServerName - - /// A pointer to a string that specifies the DNS or NetBIOS name of the remote server on which the shared resource resides. - /// A value of "*" indicates no configured server name. - public string ServerName { get; private set; } - - #endregion // ServerName - - #region ShareType - - /// The type of share. - public ShareType ShareType { get; private set; } - - #endregion // ShareType - - #region ResourceType - - private ShareResourceTypes _shareResourceType; - - /// The type of share resource. - public ShareResourceTypes ResourceType - { - get - { - if (_shareResourceType == ShareResourceTypes.None && !Utils.IsNullOrWhiteSpace(NetName)) - _shareResourceType = (Host.GetShareInfoCore(ShareInfoLevel.Info1005, ServerName, NetName, true)).ResourceType; - - return _shareResourceType; - } - - private set { _shareResourceType = value; } - } - - #endregion // ResourceType - - #region ShareLevel - - /// The structure level for the ShareInfo instance. - public ShareInfoLevel ShareLevel { get; private set; } - - #endregion // ShareLevel - - #endregion // Properties - } - */ -} diff --git a/FolderMonitor/AlphaFS/OperatingSystem.cs b/FolderMonitor/AlphaFS/OperatingSystem.cs deleted file mode 100644 index 145a92e..0000000 --- a/FolderMonitor/AlphaFS/OperatingSystem.cs +++ /dev/null @@ -1,507 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.ComponentModel; -using System.Diagnostics; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; - -namespace Alphaleonis.Win32 -{ - /// Static class providing access to information about the operating system under which the assembly is executing. - public static class OperatingSystem - { - #region OperatingSystem Name Enum - - /// A set of flags that describe the named Windows versions. - /// The values of the enumeration are ordered. A later released operating system version has a higher number, so comparisons between named versions are meaningful. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Os")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Os")] - public enum EnumOsName - { - /// A Windows version earlier than Windows 2000. - Earlier = -1, - - /// Windows 2000 (Server or Professional). - Windows2000 = 0, - - /// Windows XP. - WindowsXP = 1, - - /// Windows Server 2003. - WindowsServer2003 = 2, - - /// Windows Vista. - WindowsVista = 3, - - /// Windows Server 2008. - WindowsServer2008 = 4, - - /// Windows 7. - Windows7 = 5, - - /// Windows Server 2008 R2. - WindowsServer2008R2 = 6, - - /// Windows 8. - Windows8 = 7, - - /// Windows Server 2012. - WindowsServer2012 = 8, - - /// Windows 8.1. - Windows81 = 9, - - /// Windows Server 2012 R2 - WindowsServer2012R2 = 10, - - /// Windows 10 - Windows10 = 11, - - /// Windows Server - WindowsServer = 12, - - /// A later version of Windows than currently installed. - Later = 65535 - } - - #endregion // OperatingSystem Name Enum - - #region ProcessorArchitecture Name enum - - /// A set of flags to indicate the current processor architecture for which the operating system is targeted and running. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Pa")] - [SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum EnumProcessorArchitecture - { - /// PROCESSOR_ARCHITECTURE_INTEL - /// The system is running a 32-bit version of Windows. - /// - X86 = 0, - - /// PROCESSOR_ARCHITECTURE_IA64 - /// The system is running on a Itanium processor. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Ia")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "Ia")] - IA64 = 6, - - /// PROCESSOR_ARCHITECTURE_AMD64 - /// The system is running a 64-bit version of Windows. - /// - X64 = 9, - - /// PROCESSOR_ARCHITECTURE_UNKNOWN - /// Unknown architecture. - /// - Unknown = 65535 - } - - #endregion // ProcessorArchitecture Name enum - - - #region Properties - - #region IsServer - - private static bool _isServer; - - /// Gets a value indicating whether the operating system is a server operating system. - /// if the current operating system is a server operating system; otherwise, . - public static bool IsServer - { - get - { - if (_servicePackVersion == null) - UpdateData(); - return _isServer; - } - } - - #endregion // IsServer - - #region IsWow64Process - - private static bool? _isWow64Process; - - /// Gets a value indicating whether the current process is running under WOW64. - /// if the current process is running under WOW64; otherwise, . - public static bool IsWow64Process - { - get - { - if (_isWow64Process == null) - { - bool value; - IntPtr processHandle = Process.GetCurrentProcess().Handle; - - if (!NativeMethods.IsWow64Process(processHandle, out value)) - Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error()); - - // A pointer to a value that is set to TRUE if the process is running under WOW64. - // If the process is running under 32-bit Windows, the value is set to FALSE. - // If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE. - - _isWow64Process = value; - } - - return (bool) _isWow64Process; - } - } - - #endregion // IsWow64Process - - #region OSVersion - - private static Version _osVersion; - - /// Gets the numeric version of the operating system. - /// The numeric version of the operating system. - public static Version OSVersion - { - get - { - if (_osVersion == null) - UpdateData(); - - return _osVersion; - } - } - - #endregion // OSVersion - - #region VersionName - - private static EnumOsName _enumOsName = EnumOsName.Later; - - /// Gets the named version of the operating system. - /// The named version of the operating system. - public static EnumOsName VersionName - { - get - { - if (_servicePackVersion == null) - UpdateData(); - - return _enumOsName; - } - } - - #endregion // VersionName - - #region ProcessorArchitecture - - private static EnumProcessorArchitecture _processorArchitecture; - - /// Gets the processor architecture for which the operating system is targeted. - /// The processor architecture for which the operating system is targeted. - /// If running under WOW64 this will return a 32-bit processor. Use to determine if this is the case. - public static EnumProcessorArchitecture ProcessorArchitecture - { - get - { - if (_servicePackVersion == null) - UpdateData(); - - return _processorArchitecture; - } - } - - #endregion // ProcessorArchitecture - - #region ServicePackVersion - - private static Version _servicePackVersion; - - /// Gets the version of the service pack currently installed on the operating system. - /// The version of the service pack currently installed on the operating system. - /// Only the and fields are used. - public static Version ServicePackVersion - { - get - { - if (_servicePackVersion == null) - UpdateData(); - - return _servicePackVersion; - } - } - - #endregion // ServicePackVersion - - #endregion // Properties - - #region Methods - - #region IsAtLeast - - /// Determines whether the operating system is of the specified version or later. - /// if the operating system is of the specified or later; otherwise, . - /// The lowest version for which to return true. - public static bool IsAtLeast(EnumOsName version) - { - return VersionName >= version; - } - - /// Determines whether the operating system is of the specified version or later, allowing specification of a minimum service pack that must be installed on the lowest version. - /// if the operating system matches the specified with the specified service pack, or if the operating system is of a later version; otherwise, . - /// The minimum required version. - /// The major version of the service pack that must be installed on the minimum required version to return true. This can be 0 to indicate that no service pack is required. - public static bool IsAtLeast(EnumOsName version, int servicePackVersion) - { - return IsAtLeast(version) && ServicePackVersion.Major >= servicePackVersion; - } - - #endregion // IsAtLeast - - #endregion // Methods - - - #region Private - - [SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "RtlGetVersion")] - private static void UpdateData() - { - var verInfo = new NativeMethods.RTL_OSVERSIONINFOEXW(); - - // Needed to prevent: System.Runtime.InteropServices.COMException: - // The data area passed to a system call is too small. (Exception from HRESULT: 0x8007007A) - verInfo.dwOSVersionInfoSize = Marshal.SizeOf(verInfo); - - var sysInfo = new NativeMethods.SYSTEM_INFO(); - NativeMethods.GetNativeSystemInfo(ref sysInfo); - - - // RtlGetVersion returns STATUS_SUCCESS (0). - if (NativeMethods.RtlGetVersion(ref verInfo)) - throw new Win32Exception(Marshal.GetLastWin32Error(), "Function RtlGetVersion() failed to retrieve the operating system information."); - - - _osVersion = new Version(verInfo.dwMajorVersion, verInfo.dwMinorVersion, verInfo.dwBuildNumber); - - _processorArchitecture = (EnumProcessorArchitecture) sysInfo.wProcessorArchitecture; - _servicePackVersion = new Version(verInfo.wServicePackMajor, verInfo.wServicePackMinor); - _isServer = verInfo.wProductType == NativeMethods.VER_NT_DOMAIN_CONTROLLER || verInfo.wProductType == NativeMethods.VER_NT_SERVER; - - - // RtlGetVersion: https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910%28v=vs.85%29.aspx - - // The following table summarizes the most recent operating system version numbers. - // Operating system Version number Other - // ================================================================================ - // Windows 10 10.0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION - // Windows Server 10.0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION - // Windows 8.1 6.3 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION - // Windows Server 2012 R2 6.3 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION - // Windows 8 6.2 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION - // Windows Server 2012 6.2 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION - // Windows 7 6.1 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION - // Windows Server 2008 R2 6.1 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION - // Windows Server 2008 6.0 OSVERSIONINFOEX.wProductType != VER_NT_WORKSTATION - // Windows Vista 6.0 OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION - // Windows Server 2003 R2 5.2 GetSystemMetrics(SM_SERVERR2) != 0 - // Windows Server 2003 5.2 GetSystemMetrics(SM_SERVERR2) == 0 - // Windows XP 64-Bit Edition 5.2 (OSVERSIONINFOEX.wProductType == VER_NT_WORKSTATION) && (sysInfo.PaName == PaName.X64) - // Windows XP 5.1 Not applicable - // Windows 2000 5.0 Not applicable - - - // 10 == The lastest MajorVersion of Windows. - if (verInfo.dwMajorVersion > 10) - _enumOsName = EnumOsName.Later; - - else - switch (verInfo.dwMajorVersion) - { - #region Version 10 - - case 10: - switch (verInfo.dwMinorVersion) - { - // Windows 10 or Windows Server - case 0: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION) - ? EnumOsName.Windows10 - : EnumOsName.WindowsServer; - break; - } - break; - - #endregion // Version 10 - - #region Version 6 - - case 6: - switch (verInfo.dwMinorVersion) - { - // Windows Vista or Windows Server 2008 - case 0: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION) - ? EnumOsName.WindowsVista - : EnumOsName.WindowsServer2008; - break; - - // Windows 7 or Windows Server 2008 R2 - case 1: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION) - ? EnumOsName.Windows7 - : EnumOsName.WindowsServer2008R2; - break; - - // Windows 8 or Windows Server 2012 - case 2: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION) - ? EnumOsName.Windows8 - : EnumOsName.WindowsServer2012; - break; - - // Windows 8.1 or Windows Server 2012 R2 - case 3: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION) - ? EnumOsName.Windows81 - : EnumOsName.WindowsServer2012R2; - break; - - default: - _enumOsName = EnumOsName.Later; - break; - } - break; - - #endregion // Version 6 - - #region Version 5 - - case 5: - switch (verInfo.dwMinorVersion) - { - case 0: - _enumOsName = EnumOsName.Windows2000; - break; - - case 1: - _enumOsName = EnumOsName.WindowsXP; - break; - - case 2: - _enumOsName = (verInfo.wProductType == NativeMethods.VER_NT_WORKSTATION && _processorArchitecture == EnumProcessorArchitecture.X64) - ? EnumOsName.WindowsXP - : (verInfo.wProductType != NativeMethods.VER_NT_WORKSTATION) ? EnumOsName.WindowsServer2003 : EnumOsName.Later; - break; - - default: - _enumOsName = EnumOsName.Later; - break; - } - break; - - #endregion // Version 5 - - default: - _enumOsName = EnumOsName.Earlier; - break; - } - } - - #region P/Invoke members / NativeMethods - - private static class NativeMethods - { - internal const short VER_NT_WORKSTATION = 1; - internal const short VER_NT_DOMAIN_CONTROLLER = 2; - internal const short VER_NT_SERVER = 3; - - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct RTL_OSVERSIONINFOEXW - { - public int dwOSVersionInfoSize; - public readonly int dwMajorVersion; - public readonly int dwMinorVersion; - public readonly int dwBuildNumber; - public readonly int dwPlatformId; - [MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] - public readonly string szCSDVersion; - public readonly ushort wServicePackMajor; - public readonly ushort wServicePackMinor; - public readonly ushort wSuiteMask; - public readonly byte wProductType; - public readonly byte wReserved; - } - - - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct SYSTEM_INFO - { - public readonly ushort wProcessorArchitecture; - private readonly ushort wReserved; - public readonly uint dwPageSize; - public readonly IntPtr lpMinimumApplicationAddress; - public readonly IntPtr lpMaximumApplicationAddress; - public readonly IntPtr dwActiveProcessorMask; - public readonly uint dwNumberOfProcessors; - public readonly uint dwProcessorType; - public readonly uint dwAllocationGranularity; - public readonly ushort wProcessorLevel; - public readonly ushort wProcessorRevision; - } - - - /// The RtlGetVersion routine returns version information about the currently running operating system. - /// RtlGetVersion returns STATUS_SUCCESS. - /// Available starting with Windows 2000. - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule"), DllImport("ntdll.dll", SetLastError = true, CharSet = CharSet.Unicode)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool RtlGetVersion([MarshalAs(UnmanagedType.Struct)] ref RTL_OSVERSIONINFOEXW lpVersionInformation); - - - /// Retrieves information about the current system to an application running under WOW64. - /// If the function is called from a 64-bit application, it is equivalent to the GetSystemInfo function. - /// - /// This function does not return a value. - /// To determine whether a Win32-based application is running under WOW64, call the function. - /// Minimum supported client: Windows XP [desktop apps | Windows Store apps] - /// Minimum supported server: Windows Server 2003 [desktop apps | Windows Store apps] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern void GetNativeSystemInfo([MarshalAs(UnmanagedType.Struct)] ref SYSTEM_INFO lpSystemInfo); - - - /// Determines whether the specified process is running under WOW64. - /// - /// If the function succeeds, the return value is a nonzero value. - /// If the function fails, the return value is zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows Vista, Windows XP with SP2 [desktop apps only] - /// Minimum supported server: Windows Server 2008, Windows Server 2003 with SP1 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool IsWow64Process([In] IntPtr hProcess, [Out, MarshalAs(UnmanagedType.Bool)] out bool lpSystemInfo); - } - - #endregion // P/Invoke members / NativeMethods - - #endregion // Private - } -} diff --git a/FolderMonitor/AlphaFS/Security/Crc32.cs b/FolderMonitor/AlphaFS/Security/Crc32.cs deleted file mode 100644 index 64b8af5..0000000 --- a/FolderMonitor/AlphaFS/Security/Crc32.cs +++ /dev/null @@ -1,165 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * - * Copyright (c) Damien Guard. All rights reserved. - * AlphaFS has written permission from the author to include the CRC code. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Security.Cryptography; - -namespace Alphaleonis.Win32.Security -{ - /// Implements a 32-bit CRC hash algorithm compatible with Zip etc. - /// - /// Crc32 should only be used for backward compatibility with older file formats - /// and algorithms. It is not secure enough for new applications. - /// If you need to call multiple times for the same data either use the HashAlgorithm - /// interface or remember that the result of one Compute call needs to be ~ (XOR) before - /// being passed in as the seed for the next Compute call. - /// - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crc")] - internal sealed class Crc32 : HashAlgorithm - { - private const uint DefaultPolynomial = 0xedb88320u; - private const uint DefaultSeed = 0xffffffffu; - - private uint m_hash; - private static uint[] s_defaultTable; - private readonly uint m_seed; - private readonly uint[] m_table; - - /// - /// Initializes a new instance of Crc32. - /// - public Crc32() - : this(DefaultPolynomial, DefaultSeed) - { - } - - /// Initializes a new instance of Crc32. - /// The polynomial. - /// The seed. - private Crc32(uint polynomial, uint seed) - { - m_table = InitializeTable(polynomial); - m_seed = m_hash = seed; - } - - /// - /// Initializes an implementation of the - /// class. - /// - public override void Initialize() - { - m_hash = m_seed; - } - - /// When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash. - /// The input to compute the hash code for.. - /// The offset into the byte array from which to begin using data. - /// The number of bytes in the byte array to use as data. - protected override void HashCore(byte[] array, int ibStart, int cbSize) - { - m_hash = CalculateHash(m_table, m_hash, array, ibStart, cbSize); - } - - /// - /// Finalizes the hash computation after the last data is processed by the cryptographic stream - /// object. - /// - /// - /// This method finalizes any partial computation and returns the correct hash value for the data - /// stream. - /// - protected override byte[] HashFinal() - { - var hashBuffer = UInt32ToBigEndianBytes(~m_hash); - HashValue = hashBuffer; - return hashBuffer; - } - - /// Gets the size, in bits, of the computed hash code. - /// The size, in bits, of the computed hash code. - public override int HashSize - { - get { return 32; } - } - - /// Initializes the table. - /// The polynomial. - /// The table. - private static uint[] InitializeTable(uint polynomial) - { - if (polynomial == DefaultPolynomial && s_defaultTable != null) - return s_defaultTable; - - var createTable = new uint[256]; - for (var i = 0; i < 256; i++) - { - var entry = (uint) i; - for (var j = 0; j < 8; j++) - if ((entry & 1) == 1) - entry = (entry >> 1) ^ polynomial; - else - entry = entry >> 1; - createTable[i] = entry; - } - - if (polynomial == DefaultPolynomial) - s_defaultTable = createTable; - - return createTable; - } - - /// Calculates the hash. - /// The table. - /// The seed. - /// The buffer. - /// The start. - /// The size. - /// The calculated hash. - private static uint CalculateHash(uint[] table, uint seed, IList buffer, int start, int size) - { - var hash = seed; - - for (var i = start; i < start + size; i++) - hash = (hash >> 8) ^ table[buffer[i] ^ hash & 0xff]; - - return hash; - } - - /// Int 32 to big endian bytes. - /// The second uint 3. - /// A byte[]. - private static byte[] UInt32ToBigEndianBytes(uint uint32) - { - var result = BitConverter.GetBytes(uint32); - - if (BitConverter.IsLittleEndian) - Array.Reverse(result); - - return result; - } - } -} diff --git a/FolderMonitor/AlphaFS/Security/Crc64.cs b/FolderMonitor/AlphaFS/Security/Crc64.cs deleted file mode 100644 index 939eab7..0000000 --- a/FolderMonitor/AlphaFS/Security/Crc64.cs +++ /dev/null @@ -1,166 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * - * Copyright (c) Damien Guard. All rights reserved. - * AlphaFS has written permission from the author to include the CRC code. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Security.Cryptography; - -namespace Alphaleonis.Win32.Security -{ - /// Implements an ISO-3309 compliant 64-bit CRC hash algorithm. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Crc")] - internal class Crc64 : HashAlgorithm - { - private static ulong[] Table; - private const ulong Iso3309Polynomial = 0xD800000000000000; - private const ulong DefaultSeed = 0x0; - private readonly ulong[] m_table; - private readonly ulong m_seed; - private ulong m_hash; - - /// Initializes a new instance of - public Crc64() : this(Iso3309Polynomial, DefaultSeed) - { - } - - /// Initializes a new instance of - /// The polynomial. - /// The seed. - private Crc64(ulong polynomial, ulong seed) - { - m_table = InitializeTable(polynomial); - m_seed = m_hash = seed; - } - - /// - /// Initializes an implementation of the - /// class. - /// - public override void Initialize() - { - m_hash = m_seed; - } - - /// When overridden in a derived class, routes data written to the object into the hash algorithm for computing the hash. - /// The input to compute the hash code for.. - /// The offset into the byte array from which to begin using data. - /// The number of bytes in the byte array to use as data. - protected override void HashCore(byte[] array, int ibStart, int cbSize) - { - m_hash = CalculateHash(m_hash, m_table, array, ibStart, cbSize); - } - - /// - /// Finalizes the hash computation after the last data is processed by the cryptographic stream - /// object. - /// - /// - /// This method finalizes any partial computation and returns the correct hash value for the data - /// stream. - /// - protected override byte[] HashFinal() - { - var hashBuffer = UInt64ToBigEndianBytes(m_hash); - HashValue = hashBuffer; - return hashBuffer; - } - - /// Gets the size, in bits, of the computed hash code. - /// The size, in bits, of the computed hash code. - public override int HashSize - { - get { return 64; } - } - - /// Calculates the hash. - /// The seed. - /// The table. - /// The buffer. - /// The start. - /// The size. - /// The calculated hash. - private static ulong CalculateHash(ulong seed, ulong[] table, IList buffer, int start, int size) - { - var hash = seed; - - for (var i = start; i < start + size; i++) - unchecked - { - hash = (hash >> 8) ^ table[(buffer[i] ^ hash) & 0xff]; - } - - return hash; - } - - /// Int 64 to big endian bytes. - /// The value. - /// A byte[]. - private static byte[] UInt64ToBigEndianBytes(ulong value) - { - var result = BitConverter.GetBytes(value); - - if (BitConverter.IsLittleEndian) - Array.Reverse(result); - - return result; - } - - /// Initializes the table. - /// The polynomial. - /// An ulong[]. - private static ulong[] InitializeTable(ulong polynomial) - { - if (polynomial == Iso3309Polynomial && Table != null) - return Table; - - var createTable = CreateTable(polynomial); - - if (polynomial == Iso3309Polynomial) - Table = createTable; - - return createTable; - } - - /// Creates a table. - /// The polynomial. - /// A new array of ulong. - private static ulong[] CreateTable(ulong polynomial) - { - var createTable = new ulong[256]; - for (var i = 0; i < 256; ++i) - { - var entry = (ulong) i; - - for (var j = 0; j < 8; ++j) - entry = (entry & 1) == 1 ? (entry >> 1) ^ polynomial : entry >> 1; - - createTable[i] = entry; - } - - return createTable; - } - } -} diff --git a/FolderMonitor/AlphaFS/Security/Enumerations/HashType.cs b/FolderMonitor/AlphaFS/Security/Enumerations/HashType.cs deleted file mode 100644 index bd234c6..0000000 --- a/FolderMonitor/AlphaFS/Security/Enumerations/HashType.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Diagnostics.CodeAnalysis; - -namespace Alphaleonis.Win32.Security -{ - /// Enum containing the supported hash types. - public enum HashType - { - /// CRC-32 (Cyclic Redundancy Check) - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CRC")] - CRC32, - - /// CRC-64 ISO-3309 compliant. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "CRC")] - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "ISO")] - CRC64ISO3309, - - /// MD5 (Message digest) - MD5, - - /// RIPEMD-160 is a 160-bit cryptographic hash function. It is intended for use as a replacement for the 128-bit hash functions MD4, MD5, and RIPEMD. - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "RIPEMD")] - RIPEMD160, - - /// SHA-1 (Secure Hash Algorithm) - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SHA")] - SHA1, - - /// SHA-256 (Secure Hash Algorithm) - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SHA")] - SHA256, - - /// SHA-384 (Secure Hash Algorithm) - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SHA")] - SHA384, - - /// SHA-512 (Secure Hash Algorithm) - [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SHA")] - SHA512 - } -} diff --git a/FolderMonitor/AlphaFS/Security/Enumerations/ObjectType.cs b/FolderMonitor/AlphaFS/Security/Enumerations/ObjectType.cs deleted file mode 100644 index 1d13f2f..0000000 --- a/FolderMonitor/AlphaFS/Security/Enumerations/ObjectType.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -namespace Alphaleonis.Win32.Security -{ - /// The ObjectType (SE_OBJECT_TYPE) enumeration contains values that correspond to the types of Windows objects that support security. - /// The functions, such as GetSecurityInfo and SetSecurityInfo, that set and retrieve the security information of an object, use these values to indicate the type of object. - /// - internal enum ObjectType - { - /// Unknown object type. - UnknownObjectType = 0, - - /// Indicates a file or directory. The name string that identifies a file or directory object can be in one of the following formats: - /// A relative path, such as FileName.dat or ..\FileName - /// An absolute path, such as FileName.dat, C:\DirectoryName\FileName.dat, or G:\RemoteDirectoryName\FileName.dat. - /// A UNC name, such as \\ComputerName\ShareName\FileName.dat. - /// - FileObject, - - /// Indicates a Windows service. A service object can be a local service, such as ServiceName, or a remote service, such as \\ComputerName\ServiceName. - Service, - - /// Indicates a printer. A printer object can be a local printer, such as PrinterName, or a remote printer, such as \\ComputerName\PrinterName. - Printer, - - /// Indicates a registry key. A registry key object can be in the local registry, such as CLASSES_ROOT\SomePath or in a remote registry, such as \\ComputerName\CLASSES_ROOT\SomePath. - /// The names of registry keys must use the following literal strings to identify the predefined registry keys: "CLASSES_ROOT", "CURRENT_USER", "MACHINE", and "USERS". - /// - RegistryKey, - - /// Indicates a network share. A share object can be local, such as ShareName, or remote, such as \\ComputerName\ShareName. - LmShare, - - /// Indicates a local kernel object. The GetSecurityInfo and SetSecurityInfo functions support all types of kernel objects. - /// The GetNamedSecurityInfo and SetNamedSecurityInfo functions work only with the following kernel objects: semaphore, event, mutex, waitable timer, and file mapping. - KernelObject, - - /// Indicates a window station or desktop object on the local computer. You cannot use GetNamedSecurityInfo and SetNamedSecurityInfo with these objects because the names of window stations or desktops are not unique. - WindowObject, - - /// Indicates a directory service object or a property set or property of a directory service object. - /// The name string for a directory service object must be in X.500 form, for example: CN=SomeObject,OU=ou2,OU=ou1,DC=DomainName,DC=CompanyName,DC=com,O=internet - DsObject, - - /// Indicates a directory service object and all of its property sets and properties. - DsObjectAll, - - /// Indicates a provider-defined object. - ProviderDefinedObject, - - /// Indicates a WMI object. - WmiGuidObject, - - /// Indicates an object for a registry entry under WOW64. - RegistryWow6432Key - } -} diff --git a/FolderMonitor/AlphaFS/Security/Enumerations/SecurityDescriptorControl.cs b/FolderMonitor/AlphaFS/Security/Enumerations/SecurityDescriptorControl.cs deleted file mode 100644 index b18ed13..0000000 --- a/FolderMonitor/AlphaFS/Security/Enumerations/SecurityDescriptorControl.cs +++ /dev/null @@ -1,76 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Security -{ - /// The SECURITY_DESCRIPTOR_CONTROL data type is a set of bit flags that qualify the meaning of a security descriptor or its components. - /// Each security descriptor has a Control member that stores the SECURITY_DESCRIPTOR_CONTROL bits. - [Flags] - internal enum SecurityDescriptorControl - { - /// - None = 0, - - /// SE_OWNER_DEFAULTED (0x0001) - Indicates an SD with a default owner security identifier (SID). You can use this bit to find all of the objects that have default owner permissions set. - OwnerDefaulted = 1, - - /// SE_GROUP_DEFAULTED (0x0002) - Indicates an SD with a default group SID. You can use this bit to find all of the objects that have default group permissions set. - GroupDefaulted = 2, - - /// SE_DACL_PRESENT (0x0004) - Indicates an SD that has a discretionary access control list (DACL). If this flag is not set, or if this flag is set and the DACL is NULL, the SD allows full access to everyone. - DaclPresent = 4, - - /// SE_DACL_DEFAULTED (0x0008) - Indicates an SD with a default DACL. For example, if an object creator does not specify a DACL, the object receives the default DACL from the access token of the creator. This flag can affect how the system treats the DACL, with respect to access control entry (ACE) inheritance. The system ignores this flag if the SE_DACL_PRESENT flag is not set. - DaclDefaulted = 8, - - /// SE_SACL_PRESENT (0x0010) - Indicates an SD that has a system access control list (SACL). - SaclPresent = 16, - - /// SE_SACL_DEFAULTED (0x0020) - Indicates an SD with a default SACL. For example, if an object creator does not specify an SACL, the object receives the default SACL from the access token of the creator. This flag can affect how the system treats the SACL, with respect to ACE inheritance. The system ignores this flag if the SE_SACL_PRESENT flag is not set. - SaclDefaulted = 32, - - /// SE_DACL_AUTO_INHERIT_REQ (0x0100) - Requests that the provider for the object protected by the SD automatically propagate the DACL to existing child objects. If the provider supports automatic inheritance, it propagates the DACL to any existing child objects, and sets the SE_DACL_AUTO_INHERITED bit in the security descriptors of the object and its child objects. - DaclAutoInheritReq = 256, - - /// SE_SACL_AUTO_INHERIT_REQ (0x0200) - Requests that the provider for the object protected by the SD automatically propagate the SACL to existing child objects. If the provider supports automatic inheritance, it propagates the SACL to any existing child objects, and sets the SE_SACL_AUTO_INHERITED bit in the SDs of the object and its child objects. - SaclAutoInheritReq = 512, - - /// SE_DACL_AUTO_INHERITED (0x0400) - Windows 2000 only. Indicates an SD in which the DACL is set up to support automatic propagation of inheritable ACEs to existing child objects. The system sets this bit when it performs the automatic inheritance algorithm for the object and its existing child objects. This bit is not set in SDs for Windows NT versions 4.0 and earlier, which do not support automatic propagation of inheritable ACEs. - DaclAutoInherited = 1024, - - /// SE_SACL_AUTO_INHERITED (0x0800) - Windows 2000: Indicates an SD in which the SACL is set up to support automatic propagation of inheritable ACEs to existing child objects. The system sets this bit when it performs the automatic inheritance algorithm for the object and its existing child objects. This bit is not set in SDs for Windows NT versions 4.0 and earlier, which do not support automatic propagation of inheritable ACEs. - SaclAutoInherited = 2048, - - /// SE_DACL_PROTECTED (0x1000) - Windows 2000: Prevents the DACL of the SD from being modified by inheritable ACEs. - DaclProtected = 4096, - - /// SE_SACL_PROTECTED (0x2000) - Windows 2000: Prevents the SACL of the SD from being modified by inheritable ACEs. - SaclProtected = 8192, - - /// SE_RM_CONTROL_VALID (0x4000) - Indicates that the resource manager control is valid. - RmControlValid = 16384, - - /// SE_SELF_RELATIVE (0x8000) - Indicates an SD in self-relative format with all of the security information in a contiguous block of memory. If this flag is not set, the SD is in absolute format. For more information, see Absolute and Self-Relative Security Descriptors. - SelfRelative = 32768 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Security/Enumerations/SecurityInformation.cs b/FolderMonitor/AlphaFS/Security/Enumerations/SecurityInformation.cs deleted file mode 100644 index c4540d2..0000000 --- a/FolderMonitor/AlphaFS/Security/Enumerations/SecurityInformation.cs +++ /dev/null @@ -1,87 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; - -namespace Alphaleonis.Win32.Security -{ - /// The SECURITY_INFORMATION data type identifies the object-related security information being set or queried. - /// This security information includes: - /// The owner of an object; - /// The primary group of an object; - /// The discretionary access control list (DACL) of an object; - /// The system access control list (SACL) of an object; - /// - /// - /// An unsigned 32-bit integer specifies portions of a SECURITY_DESCRIPTOR by means of bit flags. - /// Individual bit values (combinable with the bitwise OR operation) are as shown in the following table. - /// - [Flags] - internal enum SecurityInformation : uint - { - /// - None = 0, - - /// OWNER_SECURITY_INFORMATION (0x00000001) - The owner identifier of the object is being referenced. - Owner = 1, - - /// GROUP_SECURITY_INFORMATION (0x00000002) - The primary group identifier of the object is being referenced. - Group = 2, - - /// DACL_SECURITY_INFORMATION (0x00000004) - The DACL of the object is being referenced. - Dacl = 4, - - /// SACL_SECURITY_INFORMATION (0x00000008) - The SACL of the object is being referenced. - Sacl = 8, - - /// LABEL_SECURITY_INFORMATION (0x00000010) - The mandatory integrity label is being referenced. The mandatory integrity label is an ACE in the SACL of the object. - /// Windows Server 2003 and Windows XP: This bit flag is not available. - Label = 16, - - /// ATTRIBUTE_SECURITY_INFORMATION (0x00000020) - The resource properties of the object being referenced. - /// The resource properties are stored in SYSTEM_RESOURCE_ATTRIBUTE_ACE types in the SACL of the security descriptor. - /// - /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This bit flag is not available. - Attribute = 32, - - /// SCOPE_SECURITY_INFORMATION (0x00000040) - The Central Access Policy (CAP) identifier applicable on the object that is being referenced. - /// Each CAP identifier is stored in a SYSTEM_SCOPED_POLICY_ID_ACE type in the SACL of the SD. - /// - /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This bit flag is not available. - Scope = 64, - - /// BACKUP_SECURITY_INFORMATION (0x00010000) - All parts of the security descriptor. This is useful for backup and restore software that needs to preserve the entire security descriptor. - /// Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: This bit flag is not available. - Backup = 65536, - - /// UNPROTECTED_SACL_SECURITY_INFORMATION (0x10000000) - The SACL inherits ACEs from the parent object. - UnprotectedSacl = 268435456, - - /// UNPROTECTED_DACL_SECURITY_INFORMATION (0x20000000) - The DACL inherits ACEs from the parent object. - UnprotectedDacl = 536870912, - - /// PROTECTED_SACL_SECURITY_INFORMATION (0x40000000) - The SACL cannot inherit ACEs. - ProtectedSacl = 1073741824, - - /// PROTECTED_DACL_SECURITY_INFORMATION (0x80000000) - The DACL cannot inherit access control entries (ACEs). - ProtectedDacl = 2147483648 - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Security/InternalPrivilegeEnabler.cs b/FolderMonitor/AlphaFS/Security/InternalPrivilegeEnabler.cs deleted file mode 100644 index 13bc15a..0000000 --- a/FolderMonitor/AlphaFS/Security/InternalPrivilegeEnabler.cs +++ /dev/null @@ -1,94 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Security.Principal; - -namespace Alphaleonis.Win32.Security -{/* - /// - /// This object is used to enable a specific privilege for the currently running process during its lifetime. - /// It should be disposed as soon as the elevated privilege is no longer needed. - /// For more information see the documentation on AdjustTokenPrivileges on MSDN. - /// - internal sealed class InternalPrivilegeEnabler : IDisposable - { - /// Initializes a new instance of the class and enabling the specified privilege for the currently running process. - /// The name of the privilege. - [SuppressMessage("Microsoft.Security", "CA2122:DoNotIndirectlyExposeMethodsWithLinkDemands")] - [SecurityCritical] - public InternalPrivilegeEnabler(Privilege privilegeName) - { - if (privilegeName == null) - throw new ArgumentNullException("privilegeName"); - - EnabledPrivilege = privilegeName; - AdjustPrivilege(true); - } - - /// - /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. - /// In this case the privilege previously enabled will be disabled. - /// - public void Dispose() - { - try - { - if (EnabledPrivilege != null) - AdjustPrivilege(false); - } - finally - { - EnabledPrivilege = null; - } - } - - /// Adjusts the privilege. - /// the privilege will be enabled, otherwise disabled. - [SecurityCritical] - private void AdjustPrivilege(bool enable) - { - using (WindowsIdentity currentIdentity = WindowsIdentity.GetCurrent(TokenAccessLevels.Query | TokenAccessLevels.AdjustPrivileges)) - { - IntPtr hToken = currentIdentity.Token; - TokenPrivileges newPrivilege = new TokenPrivileges(); - TokenPrivileges mOldPrivilege = new TokenPrivileges(); - newPrivilege.PrivilegeCount = 1; - newPrivilege.Luid = NativeMethods.LongToLuid(EnabledPrivilege.LookupLuid()); - newPrivilege.Attributes = (uint)(enable ? 2 : 0); // 2 = SePrivilegeEnabled; - - uint length; - if (!NativeMethods.AdjustTokenPrivileges(hToken, false, ref newPrivilege, (uint) Marshal.SizeOf(mOldPrivilege), out mOldPrivilege, out length)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - // If no privilege was changed, we don't want to reset it. - if (mOldPrivilege.PrivilegeCount == 0) - EnabledPrivilege = null; - } - } - - public Privilege EnabledPrivilege { get; private set; } - } - */ -} diff --git a/FolderMonitor/AlphaFS/Security/NativeMethods.cs b/FolderMonitor/AlphaFS/Security/NativeMethods.cs deleted file mode 100644 index 246ba9c..0000000 --- a/FolderMonitor/AlphaFS/Security/NativeMethods.cs +++ /dev/null @@ -1,275 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Security -{ - internal static partial class NativeMethods - { - #region AdjustTokenPrivileges - - /// The AdjustTokenPrivileges function enables or disables privileges in the specified access token. Enabling or disabling privileges in an access token requires TOKEN_ADJUST_PRIVILEGES access. - /// - /// If the function succeeds, the return value is nonzero. - /// To determine whether the function adjusted all of the specified privileges, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool AdjustTokenPrivileges(IntPtr tokenHandle, [MarshalAs(UnmanagedType.Bool)] bool disableAllPrivileges, ref TokenPrivileges newState, uint bufferLength, out TokenPrivileges previousState, out uint returnLength); - - #endregion // AdjustTokenPrivileges - - #region LookupPrivilegeDisplayName - - /// The LookupPrivilegeDisplayName function retrieves the display name that represents a specified privilege. - /// - /// If the function succeeds, the return value is nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "LookupPrivilegeDisplayNameW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool LookupPrivilegeDisplayName([MarshalAs(UnmanagedType.LPWStr)] string lpSystemName, [MarshalAs(UnmanagedType.LPWStr)] string lpName, ref StringBuilder lpDisplayName, ref uint cchDisplayName, out uint lpLanguageId); - - #endregion // LookupPrivilegeDisplayName - - #region LookupPrivilegeValue - - /// The LookupPrivilegeValue function retrieves the locally unique identifier (LUID) used on a specified system to locally represent the specified privilege name. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "LookupPrivilegeValueW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool LookupPrivilegeValue([MarshalAs(UnmanagedType.LPWStr)] string lpSystemName, [MarshalAs(UnmanagedType.LPWStr)] string lpName, out Luid lpLuid); - - #endregion // LookupPrivilegeValue - - - #region GetNamedSecurityInfo - - /// The GetNamedSecurityInfo function retrieves a copy of the security descriptor for an object specified by name. - ///   - /// - /// If the function succeeds, the return value is ERROR_SUCCESS. - /// If the function fails, the return value is a nonzero error code defined in WinError.h. - /// - ///   - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "GetNamedSecurityInfoW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetNamedSecurityInfo([MarshalAs(UnmanagedType.LPWStr)] string pObjectName, ObjectType objectType, SecurityInformation securityInfo, out IntPtr pSidOwner, out IntPtr pSidGroup, out IntPtr pDacl, out IntPtr pSacl, out SafeGlobalMemoryBufferHandle pSecurityDescriptor); - - #endregion // GetNamedSecurityInfo - - #region GetSecurityInfo - - /// The GetSecurityInfo function retrieves a copy of the security descriptor for an object specified by a handle. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetSecurityInfo(SafeHandle handle, ObjectType objectType, SecurityInformation securityInfo, out IntPtr pSidOwner, out IntPtr pSidGroup, out IntPtr pDacl, out IntPtr pSacl, out SafeGlobalMemoryBufferHandle pSecurityDescriptor); - - #endregion // GetSecurityInfo - - #region SetSecurityInfo - - /// The SetSecurityInfo function sets specified security information in the security descriptor of a specified object. - /// The caller identifies the object by a handle. - /// - /// If the function succeeds, the function returns ERROR_SUCCESS. - /// If the function fails, it returns a nonzero error code defined in WinError.h. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint SetSecurityInfo(SafeHandle handle, ObjectType objectType, SecurityInformation securityInfo, IntPtr psidOwner, IntPtr psidGroup, IntPtr pDacl, IntPtr pSacl); - - #endregion // SetSecurityInfo - - #region SetNamedSecurityInfo - - /// The SetNamedSecurityInfo function sets specified security information in the security descriptor of a specified object. The caller identifies the object by name. - ///   - /// - /// If the function succeeds, the function returns ERROR_SUCCESS. - /// If the function fails, it returns a nonzero error code defined in WinError.h. - /// - ///   - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - /// - /// - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode, EntryPoint = "SetNamedSecurityInfoW"), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint SetNamedSecurityInfo([MarshalAs(UnmanagedType.LPWStr)] string pObjectName, ObjectType objectType, SecurityInformation securityInfo, IntPtr pSidOwner, IntPtr pSidGroup, IntPtr pDacl, IntPtr pSacl); - - #endregion // SetNamedSecurityInfo - - - #region GetSecurityDescriptorDacl - - /// The GetSecurityDescriptorDacl function retrieves a pointer to the discretionary access control list (DACL) in a specified security descriptor. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetSecurityDescriptorDacl(SafeGlobalMemoryBufferHandle pSecurityDescriptor, [MarshalAs(UnmanagedType.Bool)] out bool lpbDaclPresent, out IntPtr pDacl, [MarshalAs(UnmanagedType.Bool)] out bool lpbDaclDefaulted); - - #endregion // GetSecurityDescriptorDacl - - #region GetSecurityDescriptorSacl - - /// The GetSecurityDescriptorSacl function retrieves a pointer to the system access control list (SACL) in a specified security descriptor. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetSecurityDescriptorSacl(SafeGlobalMemoryBufferHandle pSecurityDescriptor, [MarshalAs(UnmanagedType.Bool)] out bool lpbSaclPresent, out IntPtr pSacl, [MarshalAs(UnmanagedType.Bool)] out bool lpbSaclDefaulted); - - #endregion // GetSecurityDescriptorSacl - - #region GetSecurityDescriptorGroup - - /// The GetSecurityDescriptorGroup function retrieves the primary group information from a security descriptor. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetSecurityDescriptorGroup(SafeGlobalMemoryBufferHandle pSecurityDescriptor, out IntPtr pGroup, [MarshalAs(UnmanagedType.Bool)] out bool lpbGroupDefaulted); - - #endregion // GetSecurityDescriptorGroup - - #region GetSecurityDescriptorControl - - /// The GetSecurityDescriptorControl function retrieves a security descriptor control and revision information. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetSecurityDescriptorControl(SafeGlobalMemoryBufferHandle pSecurityDescriptor, out SecurityDescriptorControl pControl, out uint lpdwRevision); - - #endregion // GetSecurityDescriptorControl - - #region GetSecurityDescriptorOwner - - /// The GetSecurityDescriptorOwner function retrieves the owner information from a security descriptor. - /// - /// If the function succeeds, the function returns nonzero. - /// If the function fails, it returns zero. To get extended error information, call GetLastError. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern bool GetSecurityDescriptorOwner(SafeGlobalMemoryBufferHandle pSecurityDescriptor, out IntPtr pOwner, [MarshalAs(UnmanagedType.Bool)] out bool lpbOwnerDefaulted); - - #endregion // GetSecurityDescriptorOwner - - #region GetSecurityDescriptorLength - - /// The GetSecurityDescriptorLength function returns the length, in bytes, of a structurally valid security descriptor. The length includes the length of all associated structures. - /// - /// If the function succeeds, the function returns the length, in bytes, of the SECURITY_DESCRIPTOR structure. - /// If the SECURITY_DESCRIPTOR structure is not valid, the return value is undefined. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - [return: MarshalAs(UnmanagedType.U4)] - internal static extern uint GetSecurityDescriptorLength(SafeGlobalMemoryBufferHandle pSecurityDescriptor); - - #endregion // GetSecurityDescriptorLength - - - #region LocalFree - - /// Frees the specified local memory object and invalidates its handle. - /// - /// If the function succeeds, the return value is . - /// If the function fails, the return value is equal to a handle to the local memory object. To get extended error information, call GetLastError. - /// - /// SetLastError is set to . - /// - /// Note The local functions have greater overhead and provide fewer features than other memory management functions. - /// New applications should use the heap functions unless documentation states that a local function should be used. - /// For more information, see Global and Local Functions. - /// - /// Minimum supported client: Windows XP [desktop apps only] - /// Minimum supported server: Windows Server 2003 [desktop apps only] - [SuppressMessage("Microsoft.Security", "CA5122:PInvokesShouldNotBeSafeCriticalFxCopRule")] - [DllImport("kernel32.dll", SetLastError = false, CharSet = CharSet.Unicode), SuppressUnmanagedCodeSecurity] - internal static extern IntPtr LocalFree(IntPtr hMem); - - #endregion // LocalFree - } -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Security/Privilege.cs b/FolderMonitor/AlphaFS/Security/Privilege.cs deleted file mode 100644 index 58af63f..0000000 --- a/FolderMonitor/AlphaFS/Security/Privilege.cs +++ /dev/null @@ -1,495 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security; -using System.Text; - -namespace Alphaleonis.Win32.Security -{/* - /// Represents a privilege for an access token. The privileges available on the local machine are available as - /// static instances from this class. To create a representing a privilege on another system, - /// use the constructor specifying a system name together with one of these static instances. - /// - /// - [ImmutableObject(true)] - public class Privilege : IEquatable - { - #region System Privileges - - #region AssignPrimaryToken - - /// Required to assign the primary token of a process. User Right: Replace a process-level token. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege AssignPrimaryToken = new Privilege("SeAssignPrimaryTokenPrivilege"); - - #endregion // AssignPrimaryToken - - #region Audit - - /// Required to generate audit-log entries. Give this privilege to secure servers. User Right: Generate security audits. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Audit = new Privilege("SeAuditPrivilege"); - - #endregion // Audit - - #region Backup - - /// Required to perform backup operations. This privilege causes the system to grant all read access control to any file, regardless of the access control list (ACL) specified for the file. Any access request other than read is still evaluated with the ACL. User Right: Back up files and directories. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Backup = new Privilege("SeBackupPrivilege"); - - #endregion // Backup - - #region ChangeNotify - - /// Required to receive notifications of changes to files or directories. This privilege also causes the system to skip all traversal access checks. It is enabled by default for all users. User Right: Bypass traverse checking. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege ChangeNotify = new Privilege("SeChangeNotifyPrivilege"); - - #endregion // ChangeNotify - - #region CreateGlobal - - /// Required to create named file mapping objects in the global namespace during Terminal Services sessions. This privilege is enabled by default for administrators, services, and the local system account. User Right: Create global objects. - /// Windows XP/2000: This privilege is not supported. Note that this value is supported starting with Windows Server 2003, Windows XP SP2, and Windows 2000 SP4. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege CreateGlobal = new Privilege("SeCreateGlobalPrivilege"); - - #endregion // CreateGlobal - - #region CreatePagefile - - /// Required to create a paging file. User Right: Create a pagefile. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Pagefile")] - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege CreatePagefile = new Privilege("SeCreatePagefilePrivilege"); - - #endregion // CreatePagefile - - #region CreatePermanent - - /// Required to create a permanent object. User Right: Create permanent shared objects. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege CreatePermanent = new Privilege("SeCreatePermanentPrivilege"); - - #endregion // CreatePermanent - - #region CreateSymbolicLink - - /// Required to create a symbolic link. User Right: Create symbolic links. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege CreateSymbolicLink = new Privilege("SeCreateSymbolicLinkPrivilege"); - - #endregion // CreateSymbolicLink - - #region CreateToken - - /// Required to create a primary token. User Right: Create a token object. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege CreateToken = new Privilege("SeCreateTokenPrivilege"); - - #endregion // CreateToken - - #region Debug - - /// Required to debug and adjust the memory of a process owned by another account. User Right: Debug programs. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Debug = new Privilege("SeDebugPrivilege"); - - #endregion // Debug - - #region EnableDelegation - - /// Required to mark user and computer accounts as trusted for delegation. User Right: Enable computer and user accounts to be trusted for delegation. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege EnableDelegation = new Privilege("SeEnableDelegationPrivilege"); - - #endregion // EnableDelegation - - #region Impersonate - - /// Required to impersonate. User Right: Impersonate a client after authentication. - /// Windows XP/2000: This privilege is not supported. Note that this value is supported starting with Windows Server 2003, Windows XP SP2, and Windows 2000 SP4. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Impersonate = new Privilege("SeImpersonatePrivilege"); - - #endregion // Impersonate - - #region IncreaseBasePriority - - /// Required to increase the base priority of a process. User Right: Increase scheduling priority. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege IncreaseBasePriority = new Privilege("SeIncreaseBasePriorityPrivilege"); - - #endregion // IncreaseBasePriority - - #region IncreaseQuota - - /// Required to increase the quota assigned to a process. User Right: Adjust memory quotas for a process. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege IncreaseQuota = new Privilege("SeIncreaseQuotaPrivilege"); - - #endregion // IncreaseQuota - - #region IncreaseWorkingSet - - /// Required to allocate more memory for applications that run in the context of users. User Right: Increase a process working set. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege IncreaseWorkingSet = new Privilege("SeIncreaseWorkingSetPrivilege"); - - #endregion // IncreaseWorkingSet - - #region LoadDriver - - /// Required to load or unload a device driver. User Right: Load and unload device drivers. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege LoadDriver = new Privilege("SeLoadDriverPrivilege"); - - #endregion // LoadDriver - - #region LockMemory - - /// Required to lock physical pages in memory. User Right: Lock pages in memory. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege LockMemory = new Privilege("SeLockMemoryPrivilege"); - - #endregion // LockMemory - - #region MachineAccount - - /// Required to create a computer account. User Right: Add workstations to domain. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege MachineAccount = new Privilege("SeMachineAccountPrivilege"); - - #endregion // MachineAccount - - #region ManageVolume - - /// Required to enable volume management privileges. User Right: Manage the files on a volume. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege ManageVolume = new Privilege("SeManageVolumePrivilege"); - - #endregion // ManageVolume - - #region ProfileSingleProcess - - /// Required to gather profiling information for a single process. User Right: Profile single process. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege ProfileSingleProcess = new Privilege("SeProfileSingleProcessPrivilege"); - - #endregion // ProfileSingleProcess - - #region Relabel - - /// Required to modify the mandatory integrity level of an object. User Right: Modify an object label. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Relabel")] - public static readonly Privilege Relabel = new Privilege("SeRelabelPrivilege"); - - #endregion // Relabel - - #region RemoteShutdown - - /// Required to shut down a system using a network request. User Right: Force shutdown from a remote system. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege RemoteShutdown = new Privilege("SeRemoteShutdownPrivilege"); - - #endregion // RemoteShutdown - - #region Restore - - /// Required to perform restore operations. This privilege causes the system to grant all write access control to any file, regardless of the ACL specified for the file. Any access request other than write is still evaluated with the ACL. Additionally, this privilege enables you to set any valid user or group SID as the owner of a file. User Right: Restore files and directories. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Restore = new Privilege("SeRestorePrivilege"); - - #endregion // Restore - - #region Security - - /// Required to perform a number of security-related functions, such as controlling and viewing audit messages. This privilege identifies its holder as a security operator. User Right: Manage auditing and security log. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Security = new Privilege("SeSecurityPrivilege"); - - #endregion // Security - - #region Shutdown - - /// Required to shut down a local system. User Right: Shut down the system. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Shutdown = new Privilege("SeShutdownPrivilege"); - - #endregion // Shutdown - - #region SyncAgent - - /// Required for a domain controller to use the LDAP directory synchronization services. This privilege enables the holder to read all objects and properties in the directory, regardless of the protection on the objects and properties. By default, it is assigned to the Administrator and LocalSystem accounts on domain controllers. User Right: Synchronize directory service data. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege SyncAgent = new Privilege("SeSyncAgentPrivilege"); - - #endregion // SyncAgent - - #region SystemEnvironment - - /// Required to modify the nonvolatile RAM of systems that use this type of memory to store configuration information. User Right: Modify firmware environment values. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege SystemEnvironment = new Privilege("SeSystemEnvironmentPrivilege"); - - #endregion // SystemEnvironment - - #region SystemProfile - - /// Required to gather profiling information for the entire system. User Right: Profile system performance. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege SystemProfile = new Privilege("SeSystemProfilePrivilege"); - - #endregion // SystemProfile - - #region SystemTime - - /// Required to modify the system time. User Right: Change the system time. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege SystemTime = new Privilege("SeSystemtimePrivilege"); - - #endregion // SystemTime - - #region TakeOwnership - - /// Required to take ownership of an object without being granted discretionary access. This privilege allows the owner value to be set only to those values that the holder may legitimately assign as the owner of an object. User Right: Take ownership of files or other objects. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege TakeOwnership = new Privilege("SeTakeOwnershipPrivilege"); - - #endregion // TakeOwnership - - #region Tcb - - /// This privilege identifies its holder as part of the trusted computer base. Some trusted protected subsystems are granted this privilege. User Right: Act as part of the operating system. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Tcb")] - public static readonly Privilege Tcb = new Privilege("SeTcbPrivilege"); - - #endregion // Tcb - - #region TimeZone - - /// Required to adjust the time zone associated with the computer's internal clock. User Right: Change the time zone. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege TimeZone = new Privilege("SeTimeZonePrivilege"); - - #endregion // TimeZone - - #region TrustedCredManAccess - - /// Required to access Credential Manager as a trusted caller. User Right: Access Credential Manager as a trusted caller. - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cred")] - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege TrustedCredManAccess = new Privilege("SeTrustedCredManAccessPrivilege"); - - #endregion // TrustedCredManAccess - - #region Undock - - /// Required to undock a laptop. User Right: Remove computer from docking station. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege Undock = new Privilege("SeUndockPrivilege"); - - #endregion // Undock - - #region UnsolicitedInput - - /// Required to read unsolicited input from a terminal device. User Right: Not applicable. - [SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes")] - public static readonly Privilege UnsolicitedInput = new Privilege("SeUnsolicitedInputPrivilege"); - - #endregion // UnsolicitedInput - - #endregion // System Privileges - - #region Privilege - - private readonly string _systemName; - - /// Create a new representing the specified privilege on the specified system. - /// Name of the system. - /// The privilege to copy the privilege name from. - public Privilege(string systemName, Privilege privilege) - { - if (Utils.IsNullOrWhiteSpace(systemName)) - throw new ArgumentException(Resources.Privilege_Name_Cannot_Be_Empty, "systemName"); - - _systemName = systemName; - - if (privilege != null) - _name = privilege._name; - } - - #endregion // Privilege - - #region Name - - private readonly string _name; - - /// Gets the system name identifying this privilege. - /// The system name identifying this privilege. - public string Name - { - get { return _name; } - } - - #endregion // Name - - #region LookupDisplayName - - /// Retrieves the display name that represents this privilege. - /// The display name that represents this privilege. - [SecurityCritical] - public string LookupDisplayName() - { - const uint initialCapacity = 10; - uint displayNameCapacity = initialCapacity; - StringBuilder displayName = new StringBuilder((int) displayNameCapacity); - uint languageId; - - if (!NativeMethods.LookupPrivilegeDisplayName(_systemName, _name, ref displayName, ref displayNameCapacity, out languageId)) - { - int lastError = Marshal.GetLastWin32Error(); - if (lastError == Win32Errors.ERROR_INSUFFICIENT_BUFFER) - { - displayName = new StringBuilder((int) displayNameCapacity + 1); - if (!NativeMethods.LookupPrivilegeDisplayName(_systemName, _name, ref displayName, ref displayNameCapacity, out languageId)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - } - else - NativeError.ThrowException(lastError); - } - return displayName.ToString(); - } - - #endregion // LookupDisplayName - - #region LookupLuid - - /// Retrieves the locally unique identifier (LUID) used on to represent this privilege (on the system from which it originates). - /// the locally unique identifier (LUID) used on to represent this privilege (on the system from which it originates). - [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Luid")] - [SecurityCritical] - public long LookupLuid() - { - Luid luid; - - if (!NativeMethods.LookupPrivilegeValue(_systemName, _name, out luid)) - NativeError.ThrowException(Marshal.GetLastWin32Error()); - - return Filesystem.NativeMethods.LuidToLong(luid); - } - - #endregion // LookupLuid - - #region Equals - - /// Indicates whether the current object is equal to another object of the same type. - /// An object to compare with this object. - /// if the current object is equal to the parameter; otherwise, . - public bool Equals(Privilege other) - { - if (other == null) - return false; - - return _name.Equals(other._name, StringComparison.OrdinalIgnoreCase) && - ((_systemName == null && other._systemName == null) || - (_systemName != null && _systemName.Equals(other._systemName, StringComparison.OrdinalIgnoreCase))); - } - - /// Determines whether the specified is equal to the current . - /// The to compare with the current . - /// if the specified is equal to the current ; otherwise, . - /// - public override bool Equals(object obj) - { - Privilege other = obj as Privilege; - - if (other == null) - return false; - - return _name.Equals(other._name, StringComparison.OrdinalIgnoreCase) && - ((_systemName == null && other._systemName == null) || - (_systemName != null && _systemName.Equals(other._systemName, StringComparison.OrdinalIgnoreCase))); - } - - #endregion // Equals - - #region GetHashCode - - // A random prime number will be picked and added to the HashCode, each time an instance is created. - [NonSerialized] private readonly int _random = new Random().Next(0, 19); - [NonSerialized] private static readonly int[] Primes = { 17, 23, 29, 37, 47, 59, 71, 89, 107, 131, 163, 197, 239, 293, 353, 431, 521, 631, 761, 919 }; - - /// Serves as a hash function for a particular type. - /// A hash code for the current Object. - public override int GetHashCode() - { - unchecked - { - int hash = Primes[_random]; - - if (!Utils.IsNullOrWhiteSpace(_name)) - hash = hash * Primes[1] + _name.GetHashCode(); - - if (!Utils.IsNullOrWhiteSpace(_systemName)) - hash = hash * Primes[1] + _systemName.GetHashCode(); - - return hash; - } - } - - #endregion // GetHashCode - - #region ToString - - /// Returns the system name for this privilege. - /// This is equivalent to . - /// A that represents the current . - public override string ToString() - { - return _name; - } - - #endregion // ToString - - #region Privilege - - /// Initializes a new instance of the class, representing a privilege with the specified name on the local system. - /// The name. - private Privilege(string name) - { - if (Utils.IsNullOrWhiteSpace(name)) - throw new ArgumentException(Resources.Privilege_Name_Cannot_Be_Empty, "name"); - - _name = name; - } - - #endregion // Privilege - } - */ -} diff --git a/FolderMonitor/AlphaFS/Security/PrivilegeEnabler.cs b/FolderMonitor/AlphaFS/Security/PrivilegeEnabler.cs deleted file mode 100644 index ac7ccd6..0000000 --- a/FolderMonitor/AlphaFS/Security/PrivilegeEnabler.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; - -namespace Alphaleonis.Win32.Security -{/* - /// Used to enable one or more privileges. The privileges specified will be enabled during the lifetime of the instance. Users create an instance of this object in a using statement to ensure that it is properly disposed when the elevated privileges are no longer needed. - public sealed class PrivilegeEnabler : IDisposable - { - #region PrivilegeEnabler - - private readonly List _enabledPrivileges = new List(); - - /// Initializes a new instance of the class. - /// This will enable the privileges specified (unless already enabled), and ensure that they are disabled again when - /// the object is disposed. (Any privileges already enabled will not be disabled). - /// - /// The privilege to enable. - /// Additional privileges to enable. - public PrivilegeEnabler(Privilege privilege, params Privilege[] privileges) - { - _enabledPrivileges.Add(new InternalPrivilegeEnabler(privilege)); - - if (privileges != null) - foreach (Privilege priv in privileges) - _enabledPrivileges.Add(new InternalPrivilegeEnabler(priv)); - } - - #endregion // PrivilegeEnabler - - #region Dispose - - /// Makes sure any privileges enabled by this instance are disabled. - [SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes")] - public void Dispose() - { - foreach (InternalPrivilegeEnabler t in _enabledPrivileges) - { - try - { - t.Dispose(); - } - catch - { - // We ignore any exceptions here - } - } - } - - #endregion // Dispose - - #region EnabledPrivileges - - /// Gets the enabled privileges. Note that this might not contain all privileges specified to the constructor. Only the privileges actually enabled by this instance is returned. - /// The enabled privileges. - public IEnumerable EnabledPrivileges - { - get { return from priv in _enabledPrivileges where priv.EnabledPrivilege != null select priv.EnabledPrivilege; } - } - - #endregion // EnabledPrivileges - } - */ -} \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/Security/SecurityAttributes.cs b/FolderMonitor/AlphaFS/Security/SecurityAttributes.cs deleted file mode 100644 index 42cbd4e..0000000 --- a/FolderMonitor/AlphaFS/Security/SecurityAttributes.cs +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Diagnostics.CodeAnalysis; -using System.Runtime.InteropServices; -using System.Security.AccessControl; - -namespace Alphaleonis.Win32.Security -{ - internal static partial class NativeMethods - { - /// Class used to represent the SECURITY_ATTRIBUES native Win32 structure. It provides initialization function from an object. - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal sealed class SecurityAttributes : IDisposable - { - // Removing this member results in: "Invalid access to memory location: ..." - [MarshalAs(UnmanagedType.U4)] - private int _length; - - private readonly SafeGlobalMemoryBufferHandle _securityDescriptor; - - public SecurityAttributes(ObjectSecurity securityDescriptor) - { - SafeGlobalMemoryBufferHandle safeBuffer = ToUnmanagedSecurityAttributes(securityDescriptor); - _length = safeBuffer.Capacity; - _securityDescriptor = safeBuffer; - } - - /// Marshals an ObjectSecurity instance to unmanaged memory. - /// A safe handle containing the marshalled security descriptor. - /// The security descriptor. - [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic")] - private static SafeGlobalMemoryBufferHandle ToUnmanagedSecurityAttributes(ObjectSecurity securityDescriptor) - { - if (securityDescriptor == null) - return new SafeGlobalMemoryBufferHandle(); - - - byte[] src = securityDescriptor.GetSecurityDescriptorBinaryForm(); - var safeBuffer = new SafeGlobalMemoryBufferHandle(src.Length); - - try - { - safeBuffer.CopyFrom(src, 0, src.Length); - return safeBuffer; - } - catch - { - safeBuffer.Close(); - throw; - } - } - - public void Dispose() - { - if (_securityDescriptor != null) - _securityDescriptor.Close(); - } - } - } -} diff --git a/FolderMonitor/AlphaFS/Security/Structures/Luid.cs b/FolderMonitor/AlphaFS/Security/Structures/Luid.cs deleted file mode 100644 index 7ed91f9..0000000 --- a/FolderMonitor/AlphaFS/Security/Structures/Luid.cs +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Security -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct Luid - { - internal uint LowPart; - internal uint HighPart; - } -} diff --git a/FolderMonitor/AlphaFS/Security/Structures/TokenPrivileges.cs b/FolderMonitor/AlphaFS/Security/Structures/TokenPrivileges.cs deleted file mode 100644 index a8e690a..0000000 --- a/FolderMonitor/AlphaFS/Security/Structures/TokenPrivileges.cs +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System.Runtime.InteropServices; - -namespace Alphaleonis.Win32.Security -{ - [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] - internal struct TokenPrivileges - { - internal uint PrivilegeCount; - internal Luid Luid; - internal uint Attributes; - } -} diff --git a/FolderMonitor/AlphaFS/Utils.cs b/FolderMonitor/AlphaFS/Utils.cs deleted file mode 100644 index 7406576..0000000 --- a/FolderMonitor/AlphaFS/Utils.cs +++ /dev/null @@ -1,131 +0,0 @@ -/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -using System; -using System.Collections.Generic; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Reflection; - -namespace Alphaleonis -{ - internal static class Utils - { - #region EnumMemberToList - - public static IEnumerable EnumMemberToList() - { - Type enumType = typeof(T); - - // Can't use generic type constraints on value types, so have to do check like this. - if (enumType.BaseType != typeof(Enum)) - throw new ArgumentException("T must be of type System.Enum"); - - //Array enumValArray = Enum.GetValues(enumType); - //List enumValList = new List(enumValArray.Length); - IOrderedEnumerable enumValArray = Enum.GetValues(enumType).Cast().OrderBy(e => e.ToString()); - var enumValList = new List(enumValArray.Count()); - - enumValList.AddRange(enumValArray.Select(val => (T)Enum.Parse(enumType, val.ToString()))); - return enumValList; - } - - #endregion // EnumMemberToList - - #region GetEnumDescription - - /// Gets an attribute on an enum field value. - /// The description belonging to the enum option, as a string - /// One of the enum types. - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - public static string GetEnumDescription(Enum enumValue) - { - FieldInfo fi = enumValue.GetType().GetField(enumValue.ToString()); - var attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false); - return attributes.Length > 0 ? attributes[0].Description : enumValue.ToString(); - } - - #endregion // GetEnumDescription - - #region IsNullOrWhiteSpace - - /// Indicates whether a specified string is null, empty, or consists only of white-space characters. - /// if the parameter is null or , or if consists exclusively of white-space characters. - /// The string to test. - public static bool IsNullOrWhiteSpace(string value) - { -#if NET35 - if (value != null) - { - for (int index = 0; index < value.Length; ++index) - { - if (!char.IsWhiteSpace(value[index])) - return false; - } - } - - return true; -#else - return string.IsNullOrWhiteSpace(value); -#endif - } - - #endregion // IsNullOrWhiteSpace - - #region UnitSizeToText - - /// Converts a number of type T to string, suffixed with a unit size. - public static string UnitSizeToText(T numberOfBytes) - { - string[] sizeFormats = - { - "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" - }; - - - var i = 0; - var bytes = Convert.ToDouble(numberOfBytes, CultureInfo.InvariantCulture); - - while (i < sizeFormats.Length && bytes > 1024) - { - i++; - bytes /= 1024; - } - - - // Will return "512 B" instead of "512,00 B". - return string.Format(CultureInfo.CurrentCulture, i == 0 ? "{0:0} {1}" : "{0:0.##} {1}", bytes, sizeFormats[i]); - } - - /// Calculates a percentage value. - /// - /// - /// - public static double PercentCalculate(double currentValue, double minimumValue, double maximumValue) - { - return (currentValue < 0 || maximumValue <= 0) ? 0 : currentValue * 100 / (maximumValue - minimumValue); - } - - #endregion // UnitSizeToText - } -} diff --git a/FolderMonitor/FileOutputLogger.cs b/FolderMonitor/FileOutputLogger.cs index 213b5c0..ba3bad3 100644 --- a/FolderMonitor/FileOutputLogger.cs +++ b/FolderMonitor/FileOutputLogger.cs @@ -2,7 +2,7 @@ using System.IO; using System.Reflection; -namespace Ashrafnet.FileSync +namespace FolderMonitor { public class FileOutputLogger : ILogger @@ -41,7 +41,9 @@ void Log(string logMessage, TextWriter txtWriter, logType logtype) txtWriter.WriteLine("-------------------------------"); } } +#pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (Exception ex) +#pragma warning restore CS0168 // The variable 'ex' is declared but never used { } } diff --git a/FolderMonitor/FolderMonitor.csproj b/FolderMonitor/FolderMonitor.csproj index 25cee75..eb1891f 100644 --- a/FolderMonitor/FolderMonitor.csproj +++ b/FolderMonitor/FolderMonitor.csproj @@ -71,63 +71,29 @@ ServiceConfig.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + True + True + Resources.resx + + + + Component @@ -146,7 +112,10 @@ - + + ResXFileCodeGenerator + Resources.Designer.cs + ProjectInstaller.cs Designer @@ -176,6 +145,7 @@ + xcopy $(TargetPath) $(SolutionDir)FolderMonitor.UI\$(OutDir) /Y diff --git a/FolderMonitor/GlobalSuppressions.cs b/FolderMonitor/GlobalSuppressions.cs new file mode 100644 index 0000000..f60e8ec Binary files /dev/null and b/FolderMonitor/GlobalSuppressions.cs differ diff --git a/FolderMonitor/ILogger.cs b/FolderMonitor/ILogger.cs index 2284337..5b9e3ff 100644 --- a/FolderMonitor/ILogger.cs +++ b/FolderMonitor/ILogger.cs @@ -1,6 +1,6 @@ using System; -namespace Ashrafnet.FileSync +namespace FolderMonitor { /// /// the logger interface diff --git a/FolderMonitor/AlphaFS/Network/Host Class/Connect.cs b/FolderMonitor/Network/Connect.cs similarity index 98% rename from FolderMonitor/AlphaFS/Network/Host Class/Connect.cs rename to FolderMonitor/Network/Connect.cs index 9a326ce..ffd46c4 100644 --- a/FolderMonitor/AlphaFS/Network/Host Class/Connect.cs +++ b/FolderMonitor/Network/Connect.cs @@ -19,7 +19,8 @@ * THE SOFTWARE. */ -using Alphaleonis.Win32; +using FolderMonitor; +using FolderMonitor.Win32; using System; using System.Diagnostics.CodeAnalysis; using System.Globalization; @@ -340,8 +341,10 @@ internal struct ConnectDisconnectArguments /// When the operating system prompts for a credential, the credential should be saved by the credential manager when true. public bool SaveCredentials; +#pragma warning disable CS0649 // Field 'ConnectDisconnectArguments.IsDeviceMap' is never assigned to, and will always have its default value false /// indicates that the operation concerns a drive mapping. public bool IsDeviceMap; +#pragma warning restore CS0649 // Field 'ConnectDisconnectArguments.IsDeviceMap' is never assigned to, and will always have its default value false /// indicates that the operation needs to disconnect from the network resource, otherwise connect. public bool IsDisconnect; diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/Connect.cs b/FolderMonitor/Network/Enums/Connect.cs similarity index 100% rename from FolderMonitor/AlphaFS/Network/Enumerations/Connect.cs rename to FolderMonitor/Network/Enums/Connect.cs diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceDisplayType.cs b/FolderMonitor/Network/Enums/ResourceDisplayType.cs similarity index 98% rename from FolderMonitor/AlphaFS/Network/Enumerations/ResourceDisplayType.cs rename to FolderMonitor/Network/Enums/ResourceDisplayType.cs index ef8f047..7030bce 100644 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceDisplayType.cs +++ b/FolderMonitor/Network/Enums/ResourceDisplayType.cs @@ -19,7 +19,7 @@ * THE SOFTWARE. */ -namespace Alphaleonis.Win32.Network +namespace FolderMonitor.Network { internal static partial class NativeMethods { diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceScope.cs b/FolderMonitor/Network/Enums/ResourceScope.cs similarity index 98% rename from FolderMonitor/AlphaFS/Network/Enumerations/ResourceScope.cs rename to FolderMonitor/Network/Enums/ResourceScope.cs index eade41b..2b730f2 100644 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceScope.cs +++ b/FolderMonitor/Network/Enums/ResourceScope.cs @@ -19,7 +19,7 @@ * THE SOFTWARE. */ -namespace Alphaleonis.Win32.Network +namespace FolderMonitor.Network { internal static partial class NativeMethods { diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceType.cs b/FolderMonitor/Network/Enums/ResourceType.cs similarity index 100% rename from FolderMonitor/AlphaFS/Network/Enumerations/ResourceType.cs rename to FolderMonitor/Network/Enums/ResourceType.cs diff --git a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceUsage.cs b/FolderMonitor/Network/Enums/ResourceUsage.cs similarity index 98% rename from FolderMonitor/AlphaFS/Network/Enumerations/ResourceUsage.cs rename to FolderMonitor/Network/Enums/ResourceUsage.cs index a59fd14..050d244 100644 --- a/FolderMonitor/AlphaFS/Network/Enumerations/ResourceUsage.cs +++ b/FolderMonitor/Network/Enums/ResourceUsage.cs @@ -21,7 +21,7 @@ using System; -namespace Alphaleonis.Win32.Network +namespace FolderMonitor.Network { internal static partial class NativeMethods { diff --git a/FolderMonitor/AlphaFS/Network/Native Structures/NETRESOURCE.cs b/FolderMonitor/Network/Native Structures/NETRESOURCE.cs similarity index 83% rename from FolderMonitor/AlphaFS/Network/Native Structures/NETRESOURCE.cs rename to FolderMonitor/Network/Native Structures/NETRESOURCE.cs index 3325a4a..f71b535 100644 --- a/FolderMonitor/AlphaFS/Network/Native Structures/NETRESOURCE.cs +++ b/FolderMonitor/Network/Native Structures/NETRESOURCE.cs @@ -21,7 +21,7 @@ using System.Runtime.InteropServices; -namespace Alphaleonis.Win32.Network +namespace FolderMonitor.Network { internal static partial class NativeMethods { @@ -51,13 +51,12 @@ internal struct NETRESOURCE /// [MarshalAs(UnmanagedType.LPWStr)] public string lpLocalName; - /// If the entry is a network resource, this member is a that specifies the remote network name. - /// If the entry is a current or persistent connection, member points to - /// the network name associated with the name pointed to by the member. - /// The can be characters in length, - /// and it must follow the network provider's naming conventions. - /// - [MarshalAs(UnmanagedType.LPWStr)] public string lpRemoteName; + /// If the entry is a network resource, this member is a that specifies the remote network name. + /// If the entry is a current or persistent connection, member points to + /// the network name associated with the name pointed to by the member. + /// and it must follow the network provider's naming conventions. + /// + [MarshalAs(UnmanagedType.LPWStr)] public string lpRemoteName; /// A that contains a comment supplied by the network provider. [MarshalAs(UnmanagedType.LPWStr)] public readonly string lpComment; diff --git a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.WindowsNetworking.cs b/FolderMonitor/Network/NativeMethods.WindowsNetworking.cs similarity index 99% rename from FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.WindowsNetworking.cs rename to FolderMonitor/Network/NativeMethods.WindowsNetworking.cs index d9f3c7c..63a46d2 100644 --- a/FolderMonitor/AlphaFS/Network/Native Methods/NativeMethods.WindowsNetworking.cs +++ b/FolderMonitor/Network/NativeMethods.WindowsNetworking.cs @@ -19,6 +19,7 @@ * THE SOFTWARE. */ +using FolderMonitor.Win32; using System; using System.Diagnostics.CodeAnalysis; using System.Runtime.InteropServices; diff --git a/FolderMonitor/AlphaFS/Resources.Designer.cs b/FolderMonitor/Network/Resources.Designer.cs similarity index 98% rename from FolderMonitor/AlphaFS/Resources.Designer.cs rename to FolderMonitor/Network/Resources.Designer.cs index b7d8527..fb5c818 100644 --- a/FolderMonitor/AlphaFS/Resources.Designer.cs +++ b/FolderMonitor/Network/Resources.Designer.cs @@ -1,14 +1,14 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.34209 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. // //------------------------------------------------------------------------------ -namespace Alphaleonis.Win32 { +namespace FolderMonitor.UI.Network { using System; @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Alphaleonis.Win32.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FolderMonitor.UI.Network.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/FolderMonitor/AlphaFS/Resources.resx b/FolderMonitor/Network/Resources.resx similarity index 98% rename from FolderMonitor/AlphaFS/Resources.resx rename to FolderMonitor/Network/Resources.resx index 4674042..b1f1108 100644 --- a/FolderMonitor/AlphaFS/Resources.resx +++ b/FolderMonitor/Network/Resources.resx @@ -112,49 +112,38 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - Invalid transaction object. - - - Transaction already committed. - - - Transaction already aborted. - - - Transactional conflict. - - - Transaction not active. + + Buffer is not large enough for the requested operation. - - Transaction not requested. + + Cannot create directory. - - Invalid transaction request. + + Cannot determine Copy or Move action. - - Creating hard-links on non-NTFS partitions is not supported. + + Destination buffer not large enough for the requested operation. - - This stream does not support seeking. + + The device is not ready. - - Count cannot be negative. + + Incorrectly implemented function attempting to generate exception from successful operation. + - - Offset cannot be negative. + + The specified file is hidden: [{0}] - - Buffer is not large enough for the requested operation. + + The file or directory already exists. - - Invalid security descriptor returned from system. + + The handle is closed. The handle is invalid. @@ -162,14 +151,26 @@ The handle is invalid. Win32Error: [{0}] - - Network share path should match the format: \\server\share + + Creating hard-links on non-NTFS partitions is not supported. - - Backup FileStream Unlock Position must not be negative. + + Illegal characters: [{0}] in path. - - Lock length cannot be negative. + + An attempt to set an invalid file attribute failed. + + + Invalid stream name. + + + Invalid Subpath + + + Invalid transaction request. + + + Count cannot be negative. Destination offset cannot be negative. @@ -177,71 +178,70 @@ Length cannot be negative. - - Source offset and length outside the bounds of the array - - - Privilege name cannot be empty. + + Lock length cannot be negative. - - Cannot create directory. + + Offset cannot be negative. - - This method requires Windows Vista or higher. + + The file or directory is not a reparse point. - - The target directory is a file, not a directory: [{0}] + + Argument is not a valid Volume GUID. - - Illegal characters: [{0}] in path. + + This stream does not support seeking. Path is a zero-length string or contains only white space. - - The given path's format is not supported: [{0}] + + Privilege name cannot be empty. - - The target file is a directory, not a file: [{0}] + + Incomplete header read. - - The specified file is hidden: [{0}] + + This method requires Windows Vista or higher. - - Cannot determine Copy or Move action. + + Invalid security descriptor returned from system. - - An attempt to set an invalid file attribute failed. + + Source offset and length outside the bounds of the array - - Incomplete header read. + + The target directory is a file, not a directory: [{0}] - - Invalid stream name. + + The target file is a directory, not a file: [{0}] - - The file or directory is not a reparse point. + + Transactional conflict. - - The file or directory already exists. + + Transaction already aborted. - - Destination buffer not large enough for the requested operation. + + Transaction already committed. - - Incorrectly implemented function attempting to generate exception from successful operation. - + + Invalid transaction object. - - Argument is not a valid Volume GUID. + + Transaction not active. - - The device is not ready. + + Transaction not requested. - - Invalid Subpath + + Network share path should match the format: \\server\share - - The handle is closed. + + Backup FileStream Unlock Position must not be negative. + + + The given path's format is not supported: [{0}] \ No newline at end of file diff --git a/FolderMonitor/AlphaFS/SafeGlobalMemoryBufferHandle.cs b/FolderMonitor/Network/SafeGlobalMemoryBufferHandle.cs similarity index 99% rename from FolderMonitor/AlphaFS/SafeGlobalMemoryBufferHandle.cs rename to FolderMonitor/Network/SafeGlobalMemoryBufferHandle.cs index 59eea9f..bf2069f 100644 --- a/FolderMonitor/AlphaFS/SafeGlobalMemoryBufferHandle.cs +++ b/FolderMonitor/Network/SafeGlobalMemoryBufferHandle.cs @@ -23,7 +23,7 @@ using System.Runtime.InteropServices; using System.Text; -namespace Alphaleonis.Win32 +namespace FolderMonitor.Win32 { /// Represents a block of native memory of a specified size allocated using the LocalAlloc function from Kernel32.dll. internal sealed class SafeGlobalMemoryBufferHandle : SafeNativeMemoryBufferHandle diff --git a/FolderMonitor/AlphaFS/SafeNativeMemoryBufferHandle.cs b/FolderMonitor/Network/SafeNativeMemoryBufferHandle.cs similarity index 99% rename from FolderMonitor/AlphaFS/SafeNativeMemoryBufferHandle.cs rename to FolderMonitor/Network/SafeNativeMemoryBufferHandle.cs index 600b68e..63dc93c 100644 --- a/FolderMonitor/AlphaFS/SafeNativeMemoryBufferHandle.cs +++ b/FolderMonitor/Network/SafeNativeMemoryBufferHandle.cs @@ -19,11 +19,13 @@ * THE SOFTWARE. */ +using FolderMonitor.Network; +using FolderMonitor.UI.Network; using Microsoft.Win32.SafeHandles; using System; using System.Runtime.InteropServices; -namespace Alphaleonis.Win32 +namespace FolderMonitor.Win32 { /// Base class for classes representing a block of unmanaged memory. internal abstract class SafeNativeMemoryBufferHandle : SafeHandleZeroOrMinusOneIsInvalid diff --git a/FolderMonitor/AlphaFS/Win32Errors.cs b/FolderMonitor/Network/Win32Errors.cs similarity index 99% rename from FolderMonitor/AlphaFS/Win32Errors.cs rename to FolderMonitor/Network/Win32Errors.cs index 9fbb890..2098fb5 100644 --- a/FolderMonitor/AlphaFS/Win32Errors.cs +++ b/FolderMonitor/Network/Win32Errors.cs @@ -19,7 +19,7 @@ * THE SOFTWARE. */ -namespace Alphaleonis.Win32 +namespace FolderMonitor.Win32 { internal static class Win32Errors { diff --git a/FolderMonitor/PathCredentials.cs b/FolderMonitor/PathCredentials.cs index 65b27e5..dffbdbc 100644 --- a/FolderMonitor/PathCredentials.cs +++ b/FolderMonitor/PathCredentials.cs @@ -1,12 +1,11 @@ -using System; +using FolderMonitor.Network; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Runtime.InteropServices; using System.Runtime.Versioning; -using System.Security; -using System.Text; using System.Text.RegularExpressions; @@ -83,7 +82,7 @@ public void ConnectToUNC(bool throwException) if (!IsUNC) throw new Exception("You can't connect to local, it must be a UNC path such as \\\\fileserver\\sharename"); if (IsPathHasUserName) - Network.Host.ConnectTo(Path , new System.Net.NetworkCredential(UserName, Password, Domain), false, false, false); + Host.ConnectTo(Path , new System.Net.NetworkCredential(UserName, Password, Domain), false, false, false); } catch (Exception er) { @@ -96,7 +95,7 @@ public void DisconnectFromUNC() { try { - Network.Host.DisconnectFrom(Path , true, false); + Host.DisconnectFrom(Path , true, false); } catch @@ -115,9 +114,9 @@ public bool CheckAccessiblity() { bool exist = false; - Network.Host.ConnectTo(Path, new System.Net.NetworkCredential(UserName, Password, Domain), false, false, false); + Host.ConnectTo(Path, new System.Net.NetworkCredential(UserName, Password, Domain), false, false, false); exist= Directory.Exists(Path); - Network.Host.DisconnectFrom(Path, true, false); + Host.DisconnectFrom(Path, true, false); if(!exist) throw new Exception("Can't access to path:"+ Environment.NewLine + Path + Environment.NewLine + "*Note that, connect to above path using user '"+ UserName + "' was succeeded."); @@ -216,7 +215,9 @@ public bool PathExists(bool throwException=false ) return Directory.Exists(Path); } +#pragma warning disable CS0168 // The variable 'er' is declared but never used catch (Exception er) +#pragma warning restore CS0168 // The variable 'er' is declared but never used { if (throwException) throw; diff --git a/FolderMonitor/Program.cs b/FolderMonitor/Program.cs index c69333b..3837f14 100644 --- a/FolderMonitor/Program.cs +++ b/FolderMonitor/Program.cs @@ -1,5 +1,5 @@ using System; - +using System.ServiceProcess; namespace FolderMonitor { diff --git a/FolderMonitor/Service1.cs b/FolderMonitor/Service1.cs index 6174e88..8d22db8 100644 --- a/FolderMonitor/Service1.cs +++ b/FolderMonitor/Service1.cs @@ -4,12 +4,6 @@ using System.ServiceProcess; using System.IO; using System.Threading; -using System.Reflection; -using Tools; -using System.Linq; -using Ashrafnet.FileSync; -using System.Xml.Serialization; -using System.Text; namespace FolderMonitor { @@ -69,7 +63,6 @@ public void StartMonitor() continue; } - //var cc= Alphaleonis.Win32.Filesystem.Directory.Copy(copyOp.From.Path, copyOp.To.Path, Alphaleonis.Win32.Filesystem.CopyOptions.Restartable, copy_progress,null ); var sync = new RoboCopyAgent(copyOp ); sync.ErrorOccured += sync_ErrorOccured; @@ -136,6 +129,8 @@ protected override void OnStop() item.Stop(); } + _logger.LogWrite("Service Has been Stopped!"); + } diff --git a/FolderMonitor/clsEncrypt.cs b/FolderMonitor/clsEncrypt.cs index b73c0ae..cfb8600 100644 --- a/FolderMonitor/clsEncrypt.cs +++ b/FolderMonitor/clsEncrypt.cs @@ -3,10 +3,11 @@ using System.Reflection; using System.Security.Cryptography; - +namespace FolderMonitor +{ public class Encryption { - private static string _pass = "my_encr!@#123987"; + private static string _pass = "my_encr!@#123987"; /// /// Encrypt a string into a string using the default password /// @@ -102,7 +103,7 @@ public static string Encrypt(string clearText, string Password) // using a dictionary attack - // trying to guess a password by enumerating all possible words. PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); // Now get the key/IV and do the encryption using the @@ -143,7 +144,7 @@ public static byte[] Encrypt(byte[] clearData, string Password) // using a dictionary attack - // trying to guess a password by enumerating all possible words. PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); // Now get the key/IV and do the encryption using the function @@ -180,7 +181,7 @@ public static void Encrypt(string fileIn, string fileOut, string Password) // Then we are going to derive a Key and an IV from the // Password and create an algorithm PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); Rijndael alg = Rijndael.Create(); @@ -309,7 +310,7 @@ public static string Decrypt(string cipherText, string Password) // using a dictionary attack - // trying to guess a password by enumerating all possible words. PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); // Now get the key/IV and do the decryption using @@ -350,7 +351,7 @@ public static byte[] Decrypt(byte[] cipherData, string Password) // using a dictionary attack - // trying to guess a password by enumerating all possible words. PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); // Now get the key/IV and do the Decryption using the @@ -387,7 +388,7 @@ public static void Decrypt(string fileIn, string fileOut, string Password) // Then we are going to derive a Key and an IV from // the Password and create an algorithm PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, - new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, + new byte[] {0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76}); Rijndael alg = Rijndael.Create(); @@ -424,3 +425,4 @@ public static void Decrypt(string fileIn, string fileOut, string Password) } } +} \ No newline at end of file