Changeset 840


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.

Location:
trunk/EraserDll
Files:
2 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    } 
  • trunk/EraserDll/FileLockResolver.h

    r55 r840  
    2727{ 
    2828public: 
    29      
    3029    CFileLockResolver(BOOL = FALSE); 
    3130    ~CFileLockResolver(void); 
    3231    void Close(); 
     32 
    3333private: 
    34      
    3534    CFileLockResolver(ERASER_HANDLE, BOOL); 
    3635    inline void AskUser(BOOL val) 
     
    3837        m_bAskUser = val; 
    3938    } 
     39 
    4040public: 
    4141    void SetHandle(ERASER_HANDLE); 
    4242    static void Resolve(LPCTSTR szFileName, CStringArray&); 
     43 
    4344private: 
    4445    BOOL m_bAskUser;     
    4546    CString m_strLockFileList; 
    4647    ERASER_HANDLE m_hHandle; 
     48 
    4749    int m_iMethod; 
     50    int m_defaultAction; 
    4851    unsigned m_iPasses; 
     52 
    4953private: 
    5054    static CString GetLockFilePath(bool path_only = false); 
Note: See TracChangeset for help on using the changeset viewer.