Ignore:
Timestamp:
4/27/2009 12:46:42 PM (6 years ago)
Author:
lowjoel
Message:

-Handle files which are currently locked by another process - currently the behaviour is to log the file as unerased and flag the task as an error having occurred
-Handle sparse/compressed/encrypted files without throwing an exception because that will cause the rest of the files to remain unerased

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eraser6/Manager/DirectExecutor.cs

    r893 r894  
    10261026                task.OnProgressChanged(progress.Event); 
    10271027 
    1028                 //Make sure the file does not have any attributes which may affect 
    1029                 //the erasure process 
     1028                 
     1029                //Remove the read-only flag, if it is set. 
     1030                StreamInfo info = new StreamInfo(paths[i]); 
    10301031                bool isReadOnly = false; 
    1031                 StreamInfo info = new StreamInfo(paths[i]); 
    1032                 if ((info.Attributes & FileAttributes.Compressed) != 0 || 
    1033                     (info.Attributes & FileAttributes.Encrypted) != 0 || 
    1034                     (info.Attributes & FileAttributes.SparseFile) != 0) 
    1035                 { 
    1036                     //Log the error 
    1037                     //TODO: This would leave files after the list unerased. Log this as an error instead 
    1038                     throw new ArgumentException(S._("Compressed, encrypted, or sparse" + 
    1039                         "files cannot be erased with Eraser.")); 
    1040                 } 
    1041  
    1042                 //Remove the read-only flag, if it is set. 
    10431032                if (isReadOnly = info.IsReadOnly) 
    10441033                    info.IsReadOnly = false; 
     
    10461035                try 
    10471036                { 
     1037                    //Make sure the file does not have any attributes which may affect 
     1038                    //the erasure process 
     1039                    if ((info.Attributes & FileAttributes.Compressed) != 0 ||  
     1040                        (info.Attributes & FileAttributes.Encrypted) != 0 || 
     1041                        (info.Attributes & FileAttributes.SparseFile) != 0) 
     1042                    { 
     1043                        //Log the error 
     1044                        task.Log.Add(new LogEntry(S._("The file {0} could not be erased " + 
     1045                            "because the file was either compressed, encrypted or a sparse file.", 
     1046                            info.FullName), LogLevel.ERROR)); 
     1047                    } 
     1048 
    10481049                    //Create the file stream, and call the erasure method to write to 
    10491050                    //the stream. 
     
    10991100                        LogLevel.ERROR)); 
    11001101                } 
     1102                catch (FileLoadException) 
     1103                { 
     1104                    task.Log.Add(new LogEntry(S._("The file {0} could not be erased because the " + 
     1105                        "file is currently in use.", info.FullName), LogLevel.ERROR)); 
     1106                } 
    11011107                finally 
    11021108                { 
Note: See TracChangeset for help on using the changeset viewer.