Ignore:
Timestamp:
1/2/2009 7:19:32 AM (6 years ago)
Author:
lowjoel
Message:

Implemented a "remember this decision for the rest of the erase" option for the file lock resolver. Fixes #125.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EraserDll/FileLockResolver.cpp

    r70 r840  
    3636CFileLockResolver::CFileLockResolver(BOOL askUser) 
    3737: m_bAskUser(askUser), m_hHandle(ERASER_INVALID_CONTEXT), 
    38   m_iMethod(0), m_iPasses(0) 
     38  m_iMethod(0), m_defaultAction(-1), m_iPasses(0) 
    3939{ 
    4040 
     
    127127        || ERROR_SHARING_VIOLATION == dwErrorCode) 
    128128    { 
    129         if (TRUE == m_bAskUser) 
     129        int eraseOnRestart = !m_bAskUser || m_defaultAction == 1; 
     130        if (m_bAskUser && m_defaultAction == -1) 
    130131        { 
    131             if (IDYES == AfxMessageBox(CString("The file ") + 
    132                 szFileName + "\nis locked by another process. Do you want to Erase the file after " + 
    133                 "you restart your computer?", MB_YESNO | MB_ICONQUESTION)) 
     132            int dlgCode = AfxMessageBox(CString("The file ") + szFileName + 
     133                "\nis locked by another process. Do you want to Erase the file " 
     134                "after you restart your computer?", MB_YESNO | MB_ICONQUESTION); 
     135 
     136            eraseOnRestart = dlgCode == IDYES; 
     137            if (AfxMessageBox("Remember this decision for the rest of this erase?", 
     138                MB_YESNO | MB_ICONQUESTION) == IDYES) 
    134139            { 
    135                 if (m_strLockFileList.IsEmpty()) 
    136                     m_strLockFileList = GetLockFilePath(); 
    137                 std::ofstream os(m_strLockFileList, std::ios_base::out | std::ios_base::app);        
    138                 os << FileData(szFileName, method, passes); 
    139  
    140                 ASSERT(m_iMethod == 0 || m_iMethod == method); 
    141                 ASSERT(m_iPasses == 0 || m_iPasses == passes); 
    142                 m_iMethod = method; 
    143                 m_iPasses = passes; 
     140                m_defaultAction = eraseOnRestart; 
    144141            } 
     142        } 
     143 
     144        if (eraseOnRestart) 
     145        { 
     146            if (m_strLockFileList.IsEmpty()) 
     147                m_strLockFileList = GetLockFilePath(); 
     148            std::ofstream os(m_strLockFileList, std::ios_base::out | std::ios_base::app);        
     149            os << FileData(szFileName, method, passes); 
     150 
     151            ASSERT(m_iMethod == 0 || m_iMethod == method); 
     152            ASSERT(m_iPasses == 0 || m_iPasses == passes); 
     153            m_iMethod = method; 
     154            m_iPasses = passes; 
    145155        } 
    146156    } 
Note: See TracChangeset for help on using the changeset viewer.