Ignore:
Timestamp:
6/13/2010 12:29:44 AM (4 years ago)
Author:
lowjoel
Message:

Implements #273: Use NtSetInformationFile? to deeply set file times.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util/NativeMethods/NtDll.cs

    r1802 r2155  
    5858            FILE_INFORMATION_CLASS FileInformationClass); 
    5959 
     60        /// <summary> 
     61        /// The ZwSetInformationFile routine changes various kinds of information 
     62        /// about a file object. 
     63        /// </summary> 
     64        /// <param name="FileHandle">Handle to the file object. This handle is 
     65        /// created by a successful call to ZwCreateFile or ZwOpenFile.</param> 
     66        /// <param name="IoStatusBlock">Pointer to an IO_STATUS_BLOCK structure 
     67        /// that receives the final completion status and information about the 
     68        /// requested operation. The Information member receives the number of 
     69        /// bytes set on the file.</param> 
     70        /// <param name="FileInformation">Pointer to a buffer that contains the 
     71        /// information to set for the file. The particular structure in this 
     72        /// buffer is determined by the FileInformationClass parameter. Setting 
     73        /// any member of the structure to zero tells ZwSetInformationFile to 
     74        /// leave the current information about the file for that member 
     75        /// unchanged.</param> 
     76        /// <param name="Length">The size, in bytes, of the FileInformation 
     77        /// buffer.</param> 
     78        /// <param name="FileInformationClass">The type of information, supplied in 
     79        /// the buffer pointed to by FileInformation, to set for the file. Device 
     80        /// and intermediate drivers can specify any of the 
     81        /// <see cref="FILE_INFORMATION_CLASS"/> values.</param> 
     82        /// <returns>ZwSetInformationFile returns STATUS_SUCCESS or an appropriate 
     83        /// error status.</returns> 
     84        /// <remarks>ZwSetInformationFile changes information about a file. It 
     85        /// ignores any member of a FILE_XXX_INFORMATION structure that is not 
     86        /// supported by a particular device or file system. 
     87        ///  
     88        /// If you set FileInformationClass to FileDispositionInformation, you 
     89        /// can subsequently pass FileHandle to ZwClose but not to any other 
     90        /// ZwXxxFile routine. Because FileDispositionInformation causes the file 
     91        /// to be marked for deletion, it is a programming error to attempt any 
     92        /// subsequent operation on the handle other than closing it. 
     93        ///  
     94        /// If you set FileInformationClass to FilePositionInformation, and the 
     95        /// preceding call to ZwCreateFile included the FILE_NO_INTERMEDIATE_BUFFERING 
     96        /// flag in the CreateOptions parameter, certain restrictions on the 
     97        /// CurrentByteOffset member of the FILE_POSITION_INFORMATION structure 
     98        /// are enforced. For more information, see ZwCreateFile. 
     99        ///  
     100        /// If you set FileInformationClass to FileEndOfFileInformation, and the 
     101        /// EndOfFile member of FILE_END_OF_FILE_INFORMATION specifies an offset 
     102        /// beyond the current end-of-file mark, ZwSetInformationFile extends 
     103        /// the file and pads the extension with zeros.</remarks> 
     104        [DllImport("NtDll.dll")] 
     105        public static extern uint NtSetInformationFile(SafeFileHandle FileHandle, 
     106            out IO_STATUS_BLOCK IoStatusBlock, IntPtr FileInformation, uint Length, 
     107            FILE_INFORMATION_CLASS FileInformationClass); 
     108 
    60109        public struct IO_STATUS_BLOCK 
    61110        { 
     
    94143            public string StreamName; 
    95144        } 
     145 
     146        #pragma warning disable 0649 
     147        /// <summary> 
     148        /// The FILE_BASIC_INFORMATION structure is used as an argument to routines 
     149        /// that query or set file information. 
     150        /// </summary> 
     151        public struct FILE_BASIC_INFORMATION 
     152        { 
     153            /// <summary> 
     154            /// Specifies the time that the file was created. 
     155            /// </summary> 
     156            public long CreationTime; 
     157 
     158            /// <summary> 
     159            /// Specifies the time that the file was last accessed. 
     160            /// </summary> 
     161            public long LastAccessTime; 
     162             
     163            /// <summary> 
     164            /// Specifies the time that the file was last written to. 
     165            /// </summary> 
     166            public long LastWriteTime; 
     167 
     168            /// <summary> 
     169            /// Specifies the last time the file was changed. 
     170            /// </summary> 
     171            public long ChangeTime; 
     172 
     173            /// <summary> 
     174            /// Specifies one or more FILE_ATTRIBUTE_XXX flags. 
     175            /// </summary> 
     176            public uint FileAttributes; 
     177        } 
     178        #pragma warning restore 0649 
    96179 
    97180        public enum FILE_INFORMATION_CLASS 
Note: See TracChangeset for help on using the changeset viewer.