Changeset 35


Ignore:
Timestamp:
10/11/2007 1:03:53 PM (7 years ago)
Author:
lowjoel
Message:

Make the File Lock resolver message a little more friendly.

Location:
trunk/EraserDll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/EraserDll/FileLockResolver.cpp

    r32 r35  
    11// FileLockResolver.cpp 
     2// $Id$ 
    23// 
    34// Eraser. Secure data removal. For Windows. 
    45// Copyright © 1997-2001  Sami Tolvanen (sami@tolvanen.com). 
    56// Copyright © 2001-2006  Garrett Trant (support@heidi.ie). 
     7// Copyright © 2007 The Eraser Project. 
    68// 
    79// This program is free software; you can redistribute it and/or 
     
    3537 
    3638} 
     39 
    3740CFileLockResolver::CFileLockResolver(ERASER_HANDLE h, BOOL askUser) 
    3841: m_bAskUser(askUser) 
     
    4144} 
    4245 
    43 void  
    44 CFileLockResolver::SetHandle(ERASER_HANDLE h) 
     46void CFileLockResolver::SetHandle(ERASER_HANDLE h) 
    4547{ 
    4648    m_hHandle = h; 
     
    5254    Close(); 
    5355} 
     56 
    5457struct PathHelper 
    5558{ 
     
    5861        :m_strLockFile(lockFile) 
    5962    { 
    60      
    6163        char fullname[MAX_PATH]; 
    6264        char filename[MAX_PATH]; 
     
    6567        char drive[10]; 
    6668 
    67  
    68  
    6969        GetModuleFileName(AfxGetInstanceHandle(),fullname,sizeof (fullname)); 
    7070        _splitpath(fullname,drive, pathname, filename, extension);  
    71          
     71 
    7272        m_strLockFile = drive; 
    7373        m_strLockFile += pathname; 
     
    7575            return; 
    7676        m_strLockFile.Format("%s%s%d.%s", drive, pathname, time(0), LOCKED_FILE_LIST_NAME); 
    77  
    78  
    7977    } 
    8078}; 
     79 
    8180struct FileData 
    8281{ 
     
    8887    { 
    8988    } 
     89 
    9090    FileData(const std::string& fname, int m, unsigned int pass) 
    9191        :name(fname), method(m), passes(pass) 
     
    9595    void read(std::istream& is) 
    9696    { 
    97      
    9897        is >> std::noskipws; 
    9998        std::getline(is, name); 
    100          
    10199    } 
    102100 
    103101    void write(std::ostream& os) const 
    104102    { 
    105          
    106103        os << std::noskipws; 
    107104        os << name << std::endl; 
    108          
    109105    } 
    110106}; 
    111 std::ostream& operator << (std::ostream& os, const FileData& data) 
     107 
     108std::ostream& operator<< (std::ostream& os, const FileData& data) 
    112109{ 
    113110    data.write(os); 
    114111    return os; 
    115112} 
    116 std::istream& operator >> (std::istream& is, FileData& data) 
     113std::istream& operator>> (std::istream& is, FileData& data) 
    117114{ 
    118115    data.read(is); 
    119116    return is; 
    120117} 
    121 void  
    122 CFileLockResolver::HandleError(LPCTSTR szFileName, DWORD dwErrorCode, int em, unsigned int passes) 
     118 
     119void CFileLockResolver::HandleError(LPCTSTR szFileName, DWORD dwErrorCode, int em, unsigned int passes) 
    123120{ 
    124121    if (ERROR_LOCK_VIOLATION == dwErrorCode  
     
    130127        if (TRUE == m_bAskUser ) 
    131128        { 
    132              needResolve = (IDYES == AfxGetMainWnd()->MessageBox("File locked by another process."  
    133             "Do you want to Erase after restart?", "Error", MB_YESNO | MB_ICONQUESTION));            
     129             needResolve = (IDYES == AfxGetMainWnd()->MessageBox(CString("The file ") + 
     130                 szFileName + "is locked by another process. Do you want to Erase the file after " + 
     131                 "you restart your computer?", "File Access Denied", MB_YESNO | MB_ICONQUESTION));           
    134132        } 
    135133 
     
    139137            std::ofstream os(m_strLockFileList, std::ios_base::out | std::ios_base::app);        
    140138            os << FileData(szFileName, em, passes); 
    141  
    142139        } 
    143          
    144  
    145         /*if (TRUE == m_bAskUser  
    146         && IDYES == AfxGetMainWnd()->MessageBox("File locked by another process."  
    147         "Do you want to Erase after restart?", "Error", MB_YESNO | MB_ICONQUESTION)) 
    148         { 
    149         static PathHelper   path(m_strLockFileList); 
    150         std::ofstream os(m_strLockFileList, std::ios_base::out | std::ios_base::app);        
    151         os << FileData(szFileName, em, passes); 
    152         }*/ 
    153          
    154140    } 
    155      
    156141} 
    157142 
    158 void  
    159 CFileLockResolver::Resolve(LPCTSTR /*szFileName*/) 
    160 { 
    161      
    162 } 
    163  
    164 void  
    165 CFileLockResolver::Resolve(LPCTSTR szFileName, CStringArray& ar) 
     143void CFileLockResolver::Resolve(LPCTSTR szFileName, CStringArray& ar) 
    166144{ 
    167145    std::ifstream is(szFileName); 
     
    179157    DeleteFile(szFileName); 
    180158} 
    181 DWORD  
    182 CFileLockResolver::ErrorHandler(LPCTSTR szFileName, DWORD dwErrorCode, void* ctx, void* param) 
     159 
     160DWORD CFileLockResolver::ErrorHandler(LPCTSTR szFileName, DWORD dwErrorCode, void* ctx, void* param) 
    183161{ 
    184162    CFileLockResolver* self(static_cast<CFileLockResolver*>(param)); 
     
    188166} 
    189167 
    190 void 
    191 CFileLockResolver::Close() 
     168void CFileLockResolver::Close() 
    192169{ 
    193170    eraserSetErrorHandler(m_hHandle, NULL, NULL); 
  • trunk/EraserDll/FileLockResolver.h

    r4 r35  
     1// FileLockResolver.h 
     2// $Id$ 
     3// 
     4// Eraser. Secure data removal. For Windows. 
     5// Copyright © 1997-2001  Sami Tolvanen (sami@tolvanen.com). 
     6// Copyright © 2002-2006  Garrett Trant (gtrant@heidi.ie). 
     7// Copyright © 2007 The Eraser Project 
     8// 
     9// This program is free software; you can redistribute it and/or 
     10// modify it under the terms of the GNU General Public License 
     11// as published by the Free Software Foundation; either version 2 
     12// of the License, or (at your option) any later version. 
     13// 
     14// This program is distributed in the hope that it will be useful, 
     15// but WITHOUT ANY WARRANTY; without even the implied warranty of 
     16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     17// GNU General Public License for more details. 
     18// 
     19// You should have received a copy of the GNU General Public License 
     20// along with this program; if not, write to the Free Software 
     21// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
     22// 02111-1307, USA. 
    123#pragma once 
    224#include "EraserDll.h" 
     
    1941    void SetHandle(ERASER_HANDLE); 
    2042    static void Resolve(LPCTSTR szFileName, CStringArray&); 
    21     static void Resolve(LPCTSTR szFileName); 
    2243private: 
    2344    BOOL m_bAskUser;     
Note: See TracChangeset for help on using the changeset viewer.