Changeset 2558 for trunk/eraser


Ignore:
Timestamp:
3/21/2012 1:01:01 AM (2 years ago)
Author:
lowjoel
Message:

When we are setting file times for reparse points, we should fall back to setting the file times for the reparse point itself if we cannot set it on the target of the reparse point (such as if the reparse point points to an invalid object.)

Fixes the first bug in https://eraser.heidi.ie/forum/viewtopic.php?f=2&t=8684&p=25969#p25966 when erasing a folder containing reparse points.

Location:
trunk/eraser/Eraser.Util
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.Util/ExtensionMethods/IO.cs

    r2516 r2558  
    8686                NativeMethods.OPEN_EXISTING, 0, IntPtr.Zero)) 
    8787            { 
     88                if (!handle.IsInvalid) 
     89                { 
     90                    SetTimes(handle, updateTime, createdTime, lastModifiedTime, lastAccessedTime); 
     91                    return; 
     92                } 
     93            } 
     94 
     95            //If we fall through here, it is a reparse point (most likely) and 
     96            //the target of the reparse point does not exist. We would then have to 
     97            //set the time of the reparse point. 
     98            using (SafeFileHandle handle = NativeMethods.CreateFile(info.FullName, 
     99                NativeMethods.FILE_WRITE_ATTRIBUTES, (uint)FileShare.ReadWrite, IntPtr.Zero, 
     100                NativeMethods.OPEN_EXISTING, NativeMethods.FILE_FLAG_BACKUP_SEMANTICS | 
     101                NativeMethods.FILE_FLAG_OPEN_REPARSE_POINT, IntPtr.Zero)) 
     102            { 
     103                if (handle.IsInvalid) 
     104                    throw new IOException(S._("The folder {0} cannot be opened for writing.", 
     105                        info.FullName)); 
     106 
    88107                SetTimes(handle, updateTime, createdTime, lastModifiedTime, lastAccessedTime); 
    89108            } 
     
    105124                NativeMethods.OPEN_EXISTING, NativeMethods.FILE_FLAG_BACKUP_SEMANTICS, IntPtr.Zero)) 
    106125            { 
     126                if (!handle.IsInvalid) 
     127                { 
     128                    SetTimes(handle, updateTime, createdTime, lastModifiedTime, lastAccessedTime); 
     129                    return; 
     130                } 
     131            } 
     132 
     133            //If we fall through here, it is a reparse point (most likely) and 
     134            //the target of the reparse point does not exist. We would then have to 
     135            //set the time of the reparse point. 
     136            using (SafeFileHandle handle = NativeMethods.CreateFile(info.FullName, 
     137                NativeMethods.FILE_WRITE_ATTRIBUTES, (uint)FileShare.ReadWrite, IntPtr.Zero, 
     138                NativeMethods.OPEN_EXISTING, NativeMethods.FILE_FLAG_BACKUP_SEMANTICS | 
     139                NativeMethods.FILE_FLAG_OPEN_REPARSE_POINT, IntPtr.Zero)) 
     140            { 
     141                if (handle.IsInvalid) 
     142                    throw new IOException(S._("The folder {0} cannot be opened for writing.", 
     143                        info.FullName)); 
     144                 
    107145                SetTimes(handle, updateTime, createdTime, lastModifiedTime, lastAccessedTime); 
    108146            } 
  • trunk/eraser/Eraser.Util/Strings.en.resx

    r2555 r2558  
    148148    <value>The path provided includes a reparse point which references another volume.</value> 
    149149  </data> 
     150  <data name="The folder {0} cannot be opened for writing." xml:space="preserve"> 
     151    <value>(Untranslated)</value> 
     152  </data> 
    150153</root> 
  • trunk/eraser/Eraser.Util/Strings.it.resx

    r2555 r2558  
    148148    <value>(Untranslated)</value> 
    149149  </data> 
     150  <data name="The folder {0} cannot be opened for writing." xml:space="preserve"> 
     151    <value>(Untranslated)</value> 
     152  </data> 
    150153</root> 
  • trunk/eraser/Eraser.Util/Strings.nl.resx

    r2555 r2558  
    148148    <value>(Untranslated)</value> 
    149149  </data> 
     150  <data name="The folder {0} cannot be opened for writing." xml:space="preserve"> 
     151    <value>(Untranslated)</value> 
     152  </data> 
    150153</root> 
  • trunk/eraser/Eraser.Util/Strings.pl.resx

    r2555 r2558  
    148148    <value>(Untranslated)</value> 
    149149  </data> 
     150  <data name="The folder {0} cannot be opened for writing." xml:space="preserve"> 
     151    <value>(Untranslated)</value> 
     152  </data> 
    150153</root> 
  • trunk/eraser/Eraser.Util/Strings.resx

    r2555 r2558  
    148148    <value>The path provided includes a reparse point which references another volume.</value> 
    149149  </data> 
     150  <data name="The folder {0} cannot be opened for writing." xml:space="preserve"> 
     151    <value>The folder {0} cannot be opened for writing.</value> 
     152  </data> 
    150153</root> 
Note: See TracChangeset for help on using the changeset viewer.