Ignore:
Timestamp:
6/13/2010 12:29:44 AM (2 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/StreamInfo.cs

    r2134 r2155  
    310310            } 
    311311 
     312            return OpenHandle(mode, iAccess, share, options); 
     313        } 
     314 
     315        internal SafeFileHandle OpenHandle(FileMode mode, uint access, FileShare share, 
     316            FileOptions options) 
     317        { 
    312318            //Sharing mode 
    313319            if ((share & FileShare.Inheritable) != 0) 
     
    319325 
    320326            //Create the handle 
    321             SafeFileHandle result = NativeMethods.CreateFile(FullName, iAccess, 
     327            SafeFileHandle result = NativeMethods.CreateFile(FullName, access, 
    322328                (uint)share, IntPtr.Zero, (uint)mode, (uint)options, IntPtr.Zero); 
    323329            if (result.IsInvalid) 
     
    331337        } 
    332338 
     339        public void SetTimes(DateTime updateTime, DateTime createdTime, DateTime lastModifiedTime, 
     340            DateTime lastAccessedTime) 
     341        { 
     342            using (SafeFileHandle streamHandle = OpenHandle(FileMode.Open, 
     343                    NativeMethods.FILE_WRITE_ATTRIBUTES, FileShare.ReadWrite, 
     344                    FileOptions.None)) 
     345            { 
     346                ExtensionMethods.IO.SetTimes(streamHandle, updateTime, createdTime, 
     347                    lastModifiedTime, lastAccessedTime); 
     348            } 
     349        } 
     350 
    333351        /// <summary> 
    334352        /// Returns the path as a string. 
Note: See TracChangeset for help on using the changeset viewer.