diff --git a/AlphaFS/AlphaFS.csproj b/AlphaFS/AlphaFS.csproj
deleted file mode 100644
index 8268e49..0000000
--- a/AlphaFS/AlphaFS.csproj
+++ /dev/null
@@ -1,393 +0,0 @@
-
-
-
- Debug
- AnyCPU
- 2.0
- {F0F9AF1E-D5B5-4D72-804A-5380622FBDEA}
- Library
- Properties
- Alphaleonis.Win32
- AlphaFS
- 512
- false
- ..\AlphaFS.snk
- AlphaFS.ruleset
- false
- Client
-
-
- true
- full
- false
- ..\Bin\Debug\Net35
- DEBUG;TRACE;NET35
- prompt
- 4
- true
- ..\Bin\Debug\Net35\AlphaFS.XML
- false
- false
- true
- AnyCPU
- false
- false
- AlphaFS.ruleset
- v3.5
-
-
- pdbonly
- true
- ..\Bin\Release\Net35
- TRACE;NET35
- prompt
- 4
- ..\Bin\Release\Net35\AlphaFS.XML
- false
- false
- v3.5
- true
- AlphaFS.ruleset
- false
-
-
-
-
-
-
-
- True
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
- Code
-
-
-
-
-
-
-
-
-
-
-
-
- Code
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AlphaFS/AlphaFS.ruleset b/AlphaFS/AlphaFS.ruleset
deleted file mode 100644
index 37302d4..0000000
--- a/AlphaFS/AlphaFS.ruleset
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/AlphaFS/AssemblyVersionInfo.cs b/AlphaFS/AssemblyVersionInfo.cs
deleted file mode 100644
index 3881818..0000000
--- a/AlphaFS/AssemblyVersionInfo.cs
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF 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.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Resources;
-
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("AlphaFS")]
-[assembly: AssemblyCopyright("© 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov")]
-[assembly: AssemblyTrademark("")]
-
-[assembly: AssemblyVersion("2.1.0.0")]
-[assembly: AssemblyFileVersion("2.1.0.0")]
-[assembly: AssemblyInformationalVersion("2.0")]
-[assembly: NeutralResourcesLanguageAttribute("en-US")]
-
diff --git a/AlphaFS/Filesystem/AlternateDataStreamInfo.cs b/AlphaFS/Filesystem/AlternateDataStreamInfo.cs
deleted file mode 100644
index d4416c5..0000000
--- a/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/AlphaFS/Filesystem/BackupFileStream.cs b/AlphaFS/Filesystem/BackupFileStream.cs
deleted file mode 100644
index 3a03001..0000000
--- a/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/AlphaFS/Filesystem/BackupStreamInfo.cs b/AlphaFS/Filesystem/BackupStreamInfo.cs
deleted file mode 100644
index 2bc85a5..0000000
--- a/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/AlphaFS/Filesystem/ByHandleFileInfo.cs b/AlphaFS/Filesystem/ByHandleFileInfo.cs
deleted file mode 100644
index e46dbcd..0000000
--- a/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/AlphaFS/Filesystem/ChangeErrorMode.cs b/AlphaFS/Filesystem/ChangeErrorMode.cs
deleted file mode 100644
index 035d52b..0000000
--- a/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/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs b/AlphaFS/Filesystem/CopyMoveProgressRoutine.cs
deleted file mode 100644
index 648bd9d..0000000
--- a/AlphaFS/Filesystem/CopyMoveProgressRoutine.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.
- */
-
-using System;
-
-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/AlphaFS/Filesystem/CopyMoveResult.cs b/AlphaFS/Filesystem/CopyMoveResult.cs
deleted file mode 100644
index 4e8cfe9..0000000
--- a/AlphaFS/Filesystem/CopyMoveResult.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF 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
-{
- /// 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; }
-
-
- /// The error message from the that was encountered during the Copy or Move action.
- /// A message describing the error.
- [SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
- public string ErrorMessage
- {
- get { return new Win32Exception(ErrorCode).Message; }
- }
-
-
- /// 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/AlphaFS/Filesystem/Device.cs b/AlphaFS/Filesystem/Device.cs
deleted file mode 100644
index 0d3318b..0000000
--- a/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/AlphaFS/Filesystem/DeviceInfo.cs b/AlphaFS/Filesystem/DeviceInfo.cs
deleted file mode 100644
index 82e0946..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs b/AlphaFS/Filesystem/Directory Class/Directory.Compression.cs
deleted file mode 100644
index 13fb15f..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs b/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs
deleted file mode 100644
index 946ceec..0000000
--- a/AlphaFS/Filesystem/Directory Class/Directory.CopyMove.cs
+++ /dev/null
@@ -1,969 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF 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
-{
- 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 skipPathChecks = pathFormat == PathFormat.LongFullPath;
-
-
- if (!skipPathChecks)
- {
- 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);
- }
-
-
- var emulateMove = false;
-
- // Determine Copy or Move action.
- var isCopy = File.DetermineIsCopy(copyOptions, moveOptions);
- var isMove = !isCopy;
-
- var cmr = copyMoveResult ?? new CopyMoveResult(sourcePathLp, destinationPathLp, false, (int) Win32Errors.ERROR_SUCCESS);
-
-
- // Execute once only.
- if (!skipPathChecks && 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);
-
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, sourcePathLp, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath))
- {
- var newDestinationPathLp = Path.CombineCore(false, destinationPathLp, fsei.FileName);
-
- cmr = fsei.IsDirectory
- ? CopyMoveCore(transaction, fsei.LongFullPath, newDestinationPathLp, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath)
- : File.CopyMoveCore(false, transaction, fsei.LongFullPath, newDestinationPathLp, false, copyOptions, moveOptions, progressHandler, userProgressData, cmr, PathFormat.LongFullPath);
-
-
- if (cmr.ErrorCode == Win32Errors.ERROR_SUCCESS)
- {
- if (fsei.IsDirectory)
- cmr.TotalFolders++;
- else
- {
- 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, false, 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, false, 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, false, 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 cmr;
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs b/AlphaFS/Filesystem/Directory Class/Directory.CountFileSystemObjects.cs
deleted file mode 100644
index 9bbb8af..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs b/AlphaFS/Filesystem/Directory Class/Directory.CreateDirectory.cs
deleted file mode 100644
index 4637e2c..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs b/AlphaFS/Filesystem/Directory Class/Directory.CurrentDirectory.cs
deleted file mode 100644
index df427f3..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs b/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
deleted file mode 100644
index 8581e27..0000000
--- a/AlphaFS/Filesystem/Directory Class/Directory.Delete.cs
+++ /dev/null
@@ -1,417 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF 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
-{
- 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, true, 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, !recursive, 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, true, 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, !recursive, 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, !recursive, 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, !recursive, 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, true, 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, true, 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, !recursive, 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, !recursive, 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, !recursive, 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, !recursive, 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.
- /// requires the directory must be empty.
- /// does not throw an Exception when the file system object does not exist.
- /// Indicates the format of the path parameter(s).
- [SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
- [SecurityCritical]
- internal static void DeleteDirectoryCore(FileSystemEntryInfo fileSystemEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool requireEmpty, bool continueOnNotExist, PathFormat pathFormat)
- {
- #region Setup
-
- if (pathFormat == PathFormat.RelativePath)
- Path.CheckSupportedPathFormat(path, true, true);
-
- if (fileSystemEntryInfo == 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).
-
- fileSystemEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator), continueOnNotExist, pathFormat);
- }
-
- if (fileSystemEntryInfo == null)
- return;
-
- string pathLp = fileSystemEntryInfo.LongFullPath;
-
- #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 && fileSystemEntryInfo.IsReparsePoint)
- recursive = false;
-
-
- // Check to see if this is a mount point, and unmount it.
- if (fileSystemEntryInfo.IsMountPoint)
- {
- int lastError = Volume.DeleteVolumeMountPointCore(pathLp, true);
-
- if (lastError != Win32Errors.ERROR_SUCCESS && lastError != Win32Errors.ERROR_PATH_NOT_FOUND)
- NativeError.ThrowException(lastError, pathLp);
-
- // Now it is safe to delete the actual directory.
- }
-
-
- if (recursive)
- {
- // Enumerate all file system objects.
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, pathLp, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath))
- {
- if (fsei.IsDirectory)
- DeleteDirectoryCore(fsei, transaction, null, true, ignoreReadOnly, requireEmpty, true, PathFormat.LongFullPath);
- else
- File.DeleteFileCore(transaction, fsei.LongFullPath, ignoreReadOnly, PathFormat.LongFullPath);
- }
- }
-
- #region Remove
-
- startRemoveDirectory:
-
- if (!(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)))
- {
- int lastError = Marshal.GetLastWin32Error();
- switch ((uint) lastError)
- {
- case Win32Errors.ERROR_DIR_NOT_EMPTY:
- if (requireEmpty)
- // MSDN: .NET 3.5+: IOException: The directory specified by path is not an empty directory.
- throw new DirectoryNotEmptyException(pathLp);
-
- goto startRemoveDirectory;
-
-
- 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 (continueOnNotExist)
- 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();
- int 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, true, PathFormat.LongFullPath);
- goto startRemoveDirectory;
- }
-
- // MSDN: .NET 3.5+: IOException: The directory is read-only.
- throw new DirectoryReadOnlyException(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:
- // 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 // Remove
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs b/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs
deleted file mode 100644
index 7740354..0000000
--- a/AlphaFS/Filesystem/Directory Class/Directory.DeleteEmptySubdirectories.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF 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.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.
- /// deletes empty subdirectories from this directory and its subdirectories.
- [SecurityCritical]
- public static void DeleteEmptySubdirectories(string path, bool recursive)
- {
- DeleteEmptySubdirectoriesCore(null, null, path, recursive, false, true, 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, true, 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, true, 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, true, pathFormat);
- }
-
- #region Transactional
-
- /// [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, true, 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, true, 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, true, 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, true, pathFormat);
- }
-
- #endregion // Transactional
-
- #region Internal Methods
-
- /// 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 DeleteEmptySubdirectoriesCore(FileSystemEntryInfo fileSystemEntryInfo, KernelTransaction transaction, string path, bool recursive, bool ignoreReadOnly, bool initialize, PathFormat pathFormat)
- {
- #region Setup
-
- if (pathFormat == PathFormat.RelativePath)
- Path.CheckSupportedPathFormat(path, true, true);
-
- if (fileSystemEntryInfo == null)
- {
- if (!File.ExistsCore(true, transaction, path, pathFormat))
- NativeError.ThrowException(Win32Errors.ERROR_PATH_NOT_FOUND, path);
-
- fileSystemEntryInfo = File.GetFileSystemEntryInfoCore(true, transaction, Path.GetExtendedLengthPathCore(transaction, path, pathFormat, GetFullPathOptions.TrimEnd | GetFullPathOptions.RemoveTrailingDirectorySeparator | GetFullPathOptions.FullCheck) , false, pathFormat);
- }
-
- if (fileSystemEntryInfo == null)
- throw new ArgumentNullException("path");
-
- string pathLp = fileSystemEntryInfo.LongFullPath;
-
- #endregion // Setup
-
- // Ensure path is a directory.
- if (!fileSystemEntryInfo.IsDirectory)
- throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.Target_Directory_Is_A_File, pathLp));
-
-
- var dirEnumOptions = DirectoryEnumerationOptions.Folders;
-
- if (recursive)
- dirEnumOptions |= DirectoryEnumerationOptions.Recursive;
-
- foreach (var fsei in EnumerateFileSystemEntryInfosCore(transaction, pathLp, Path.WildcardStarMatchAll, dirEnumOptions, PathFormat.LongFullPath))
- DeleteEmptySubdirectoriesCore(fsei, transaction, null, recursive, ignoreReadOnly, false, PathFormat.LongFullPath);
-
-
- if (!EnumerateFileSystemEntryInfosCore(transaction, pathLp, Path.WildcardStarMatchAll, DirectoryEnumerationOptions.FilesAndFolders, PathFormat.LongFullPath).Any())
- {
- // Prevent deleting path itself.
- if (!initialize)
- DeleteDirectoryCore(fileSystemEntryInfo, transaction, null, false, ignoreReadOnly, true, true, PathFormat.LongFullPath);
- }
- }
-
- #endregion // Internal Methods
- }
-}
diff --git a/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs b/AlphaFS/Filesystem/Directory Class/Directory.EncryptedDirectoryRaw.cs
deleted file mode 100644
index ee0698e..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs b/AlphaFS/Filesystem/Directory Class/Directory.Encryption.cs
deleted file mode 100644
index 5b1c780..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateAlternateDataStreams.cs
deleted file mode 100644
index 8ddcf9d..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateDirectories.cs
deleted file mode 100644
index d666b10..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileIdBothDirectoryInfo.cs
deleted file mode 100644
index 68f63aa..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntries.cs
deleted file mode 100644
index f346b00..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFileSystemEntryInfos.cs
deleted file mode 100644
index 890d394..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs b/AlphaFS/Filesystem/Directory Class/Directory.EnumerateFiles.cs
deleted file mode 100644
index f4ee086..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs b/AlphaFS/Filesystem/Directory Class/Directory.Exists.cs
deleted file mode 100644
index c0639b0..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetAccessControl.cs
deleted file mode 100644
index 9d90e02..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetChangeTime.cs
deleted file mode 100644
index d70676c..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetCreationTime.cs
deleted file mode 100644
index 8b6b3aa..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetDirectories.cs
deleted file mode 100644
index ccac010..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetDirectoryRoot.cs
deleted file mode 100644
index 91b62f6..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetFileSystemEntries.cs
deleted file mode 100644
index e4974a0..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetFiles.cs
deleted file mode 100644
index 4d1d46f..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetLastAccessTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetLastAccessTime.cs
deleted file mode 100644
index 9808b72..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetLastWriteTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetLastWriteTime.cs
deleted file mode 100644
index c34a959..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetLogicalDrives.cs
deleted file mode 100644
index a6a3620..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetParent.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetParent.cs
deleted file mode 100644
index c2945a4..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs b/AlphaFS/Filesystem/Directory Class/Directory.GetProperties.cs
deleted file mode 100644
index 92dfe70..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.HasInheritedPermissions.cs b/AlphaFS/Filesystem/Directory Class/Directory.HasInheritedPermissions.cs
deleted file mode 100644
index 71e4033..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.SetAccessControl.cs b/AlphaFS/Filesystem/Directory Class/Directory.SetAccessControl.cs
deleted file mode 100644
index fc0559b..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.SetCreationTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.SetCreationTime.cs
deleted file mode 100644
index f2698a1..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.SetLastAccessTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.SetLastAccessTime.cs
deleted file mode 100644
index 998ef00..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.SetLastWriteTime.cs b/AlphaFS/Filesystem/Directory Class/Directory.SetLastWriteTime.cs
deleted file mode 100644
index 2211921..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.SetTimestamps.cs b/AlphaFS/Filesystem/Directory Class/Directory.SetTimestamps.cs
deleted file mode 100644
index a3711ca..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.TransferTimestamps.cs b/AlphaFS/Filesystem/Directory Class/Directory.TransferTimestamps.cs
deleted file mode 100644
index 069f9c9..0000000
--- a/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/AlphaFS/Filesystem/Directory Class/Directory.cs b/AlphaFS/Filesystem/Directory Class/Directory.cs
deleted file mode 100644
index 70e6604..0000000
--- a/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/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Compression.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.Compression.cs
deleted file mode 100644
index 0070b8d..0000000
--- a/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/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CopyToMoveTo.cs b/AlphaFS/Filesystem/DirectoryInfo Class/DirectoryInfo.CopyToMoveTo.cs
deleted file mode 100644
index f58feda..0000000
--- a/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