Changeset 2522


Ignore:
Timestamp:
3/14/2012 8:35:27 AM (2 years ago)
Author:
lowjoel
Message:

Improve recycle bin support: on drives not using NTFS, Windows stores recycle bin files directly within the $Recycle.Bin folder. On those drives, we would have to erase the global recycle bin for that drive.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser/Eraser.DefaultPlugins/ErasureTargets/RecycleBinErasureTarget.cs

    r2516 r2522  
    7878            string[] rootDirectory = new string[] { 
    7979                    "$RECYCLE.BIN", 
    80                     "RECYCLER" 
     80                    "RECYCLER", 
     81                    "RECYCLED" 
    8182                }; 
    8283            string userSid = System.Security.Principal.WindowsIdentity.GetCurrent(). 
     
    8788                foreach (string rootDir in rootDirectory) 
    8889                { 
    89                     DirectoryInfo dir = new DirectoryInfo( 
    90                         System.IO.Path.Combine( 
    91                             System.IO.Path.Combine(drive.Name, rootDir), 
    92                             userSid)); 
    93                     if (!dir.Exists) 
     90                    //First get the global recycle bin for the current drive 
     91                    string recycleBinPath = System.IO.Path.Combine(drive.Name, rootDir); 
     92                    if (!Directory.Exists(recycleBinPath)) 
    9493                        continue; 
    9594 
    96                     foreach (FileInfo file in GetFiles(dir)) 
     95                    //Try to see if we can get the user's own recycle bin 
     96                    if (Directory.Exists(System.IO.Path.Combine(recycleBinPath, userSid))) 
     97                        recycleBinPath = System.IO.Path.Combine(recycleBinPath, userSid); 
     98 
     99                    foreach (FileInfo file in GetFiles(new DirectoryInfo(recycleBinPath))) 
    97100                    { 
    98101                        //Add the ADSes 
Note: See TracChangeset for help on using the changeset viewer.