You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
4.7 KiB

  1. /* Copyright (C) 2008-2016 Peter Palotas, Jeffrey Jangli, Alexandr Normuradov
  2. *
  3. * Permission is hereby granted, free of charge, to any person obtaining a copy
  4. * of this software and associated documentation files (the "Software"), to deal
  5. * in the Software without restriction, including without limitation the rights
  6. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. * copies of the Software, and to permit persons to whom the Software is
  8. * furnished to do so, subject to the following conditions:
  9. *
  10. * The above copyright notice and this permission notice shall be included in
  11. * all copies or substantial portions of the Software.
  12. *
  13. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. * THE SOFTWARE.
  20. */
  21. using System.IO;
  22. using System.Runtime.InteropServices;
  23. namespace Alphaleonis.Win32.Filesystem
  24. {
  25. internal static partial class NativeMethods
  26. {
  27. /// <summary>WIN32_FILE_ATTRIBUTE_DATA structure contains attribute information for a file or directory. The GetFileAttributesEx function uses this structure.</summary>
  28. /// <remarks>
  29. /// Not all file systems can record creation and last access time, and not all file systems record them in the same manner.
  30. /// For example, on the FAT file system, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds,
  31. /// and access time has a resolution of 1 day. On the NTFS file system, access time has a resolution of 1 hour.
  32. /// For more information, see File Times.
  33. /// </remarks>
  34. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  35. internal struct WIN32_FILE_ATTRIBUTE_DATA
  36. {
  37. public WIN32_FILE_ATTRIBUTE_DATA(WIN32_FIND_DATA findData)
  38. {
  39. dwFileAttributes = findData.dwFileAttributes;
  40. ftCreationTime = findData.ftCreationTime;
  41. ftLastAccessTime = findData.ftLastAccessTime;
  42. ftLastWriteTime = findData.ftLastWriteTime;
  43. nFileSizeHigh = findData.nFileSizeHigh;
  44. nFileSizeLow = findData.nFileSizeLow;
  45. }
  46. /// <summary>The file attributes of a file.</summary>
  47. [MarshalAs(UnmanagedType.I4)] public FileAttributes dwFileAttributes;
  48. /// <summary>A <see cref="FILETIME"/> structure that specifies when a file or directory was created.
  49. /// If the underlying file system does not support creation time, this member is zero.</summary>
  50. public readonly FILETIME ftCreationTime;
  51. /// <summary>A <see cref="FILETIME"/> structure.
  52. /// For a file, the structure specifies when the file was last read from, written to, or for executable files, run.
  53. /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last access time, this member is zero.
  54. /// On the FAT file system, the specified date for both files and directories is correct, but the time of day is always set to midnight.
  55. /// </summary>
  56. public readonly FILETIME ftLastAccessTime;
  57. /// <summary>A <see cref="FILETIME"/> structure.
  58. /// For a file, the structure specifies when the file was last written to, truncated, or overwritten, for example, when WriteFile or SetEndOfFile are used.
  59. /// The date and time are not updated when file attributes or security descriptors are changed.
  60. /// For a directory, the structure specifies when the directory is created. If the underlying file system does not support last write time, this member is zero.
  61. /// </summary>
  62. public readonly FILETIME ftLastWriteTime;
  63. /// <summary>The high-order DWORD of the file size. This member does not have a meaning for directories.
  64. /// This value is zero unless the file size is greater than MAXDWORD.
  65. /// The size of the file is equal to (nFileSizeHigh * (MAXDWORD+1)) + nFileSizeLow.
  66. /// </summary>
  67. public readonly uint nFileSizeHigh;
  68. /// <summary>The low-order DWORD of the file size. This member does not have a meaning for directories.</summary>
  69. public readonly uint nFileSizeLow;
  70. /// <summary>The file size.</summary>
  71. public long FileSize
  72. {
  73. get { return ToLong(nFileSizeHigh, nFileSizeLow); }
  74. }
  75. }
  76. }
  77. }