/* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace Alphaleonis.Win32.Filesystem
{
internal static partial class NativeMethods
{
/// Contains information about files in the specified directory. Used for directory handles. Use only when calling GetFileInformationByHandleEx.
///
/// The number of files that are returned for each call to GetFileInformationByHandleEx depends on the size of the buffer that is passed to the function.
/// Any subsequent calls to GetFileInformationByHandleEx on the same handle will resume the enumeration operation after the last file is returned.
///
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
internal struct FILE_ID_BOTH_DIR_INFO
{
/// The offset for the next FILE_ID_BOTH_DIR_INFO structure that is returned. Contains zero (0) if no other entries follow this one.
[MarshalAs(UnmanagedType.U4)]
public readonly int NextEntryOffset;
/// The byte offset of the file within the parent directory. This member is undefined for file systems, such as NTFS,
/// in which the position of a file within the parent directory is not fixed and can be changed at any time to maintain sort order.
///
[MarshalAs(UnmanagedType.U4)]
public readonly uint FileIndex;
/// The time that the file was created.
public FILETIME CreationTime;
/// The time that the file was last accessed.
public FILETIME LastAccessTime;
/// The time that the file was last written to.
public FILETIME LastWriteTime;
/// The time that the file was last changed.
public FILETIME ChangeTime;
/// The absolute new end-of-file position as a byte offset from the start of the file to the end of the file.
/// Because this value is zero-based, it actually refers to the first free byte in the file.
/// In other words, EndOfFile is the offset to the byte that immediately follows the last valid byte in the file.
///
public readonly long EndOfFile;
/// The number of bytes that are allocated for the file. This value is usually a multiple of the sector or cluster size of the underlying physical device.
public readonly long AllocationSize;
/// The file attributes.
public readonly FileAttributes FileAttributes;
/// The length of the file name.
[MarshalAs(UnmanagedType.U4)]
public readonly uint FileNameLength;
/// The size of the extended attributes for the file.
[MarshalAs(UnmanagedType.U4)]
public readonly int EaSize;
/// The length of ShortName.
[MarshalAs(UnmanagedType.U1)]
public readonly byte ShortNameLength;
/// The short 8.3 file naming convention (for example, "FILENAME.TXT") name of the file.
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 12, ArraySubType = UnmanagedType.U2)]
public readonly char[] ShortName;
/// The file ID.
public readonly long FileId;
/// The first character of the file name string. This is followed in memory by the remainder of the string.
public IntPtr FileName;
}
}
}