Changeset 35 for trunk/EraserDll/FileLockResolver.cpp
- Timestamp:
- 10/11/2007 1:03:53 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/EraserDll/FileLockResolver.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/EraserDll/FileLockResolver.cpp
r32 r35 1 1 // FileLockResolver.cpp 2 // $Id$ 2 3 // 3 4 // Eraser. Secure data removal. For Windows. 4 5 // Copyright © 1997-2001 Sami Tolvanen (sami@tolvanen.com). 5 6 // Copyright © 2001-2006 Garrett Trant (support@heidi.ie). 7 // Copyright © 2007 The Eraser Project. 6 8 // 7 9 // This program is free software; you can redistribute it and/or … … 35 37 36 38 } 39 37 40 CFileLockResolver::CFileLockResolver(ERASER_HANDLE h, BOOL askUser) 38 41 : m_bAskUser(askUser) … … 41 44 } 42 45 43 void 44 CFileLockResolver::SetHandle(ERASER_HANDLE h) 46 void CFileLockResolver::SetHandle(ERASER_HANDLE h) 45 47 { 46 48 m_hHandle = h; … … 52 54 Close(); 53 55 } 56 54 57 struct PathHelper 55 58 { … … 58 61 :m_strLockFile(lockFile) 59 62 { 60 61 63 char fullname[MAX_PATH]; 62 64 char filename[MAX_PATH]; … … 65 67 char drive[10]; 66 68 67 68 69 69 GetModuleFileName(AfxGetInstanceHandle(),fullname,sizeof (fullname)); 70 70 _splitpath(fullname,drive, pathname, filename, extension); 71 71 72 72 m_strLockFile = drive; 73 73 m_strLockFile += pathname; … … 75 75 return; 76 76 m_strLockFile.Format("%s%s%d.%s", drive, pathname, time(0), LOCKED_FILE_LIST_NAME); 77 78 79 77 } 80 78 }; 79 81 80 struct FileData 82 81 { … … 88 87 { 89 88 } 89 90 90 FileData(const std::string& fname, int m, unsigned int pass) 91 91 :name(fname), method(m), passes(pass) … … 95 95 void read(std::istream& is) 96 96 { 97 98 97 is >> std::noskipws; 99 98 std::getline(is, name); 100 101 99 } 102 100 103 101 void write(std::ostream& os) const 104 102 { 105 106 103 os << std::noskipws; 107 104 os << name << std::endl; 108 109 105 } 110 106 }; 111 std::ostream& operator << (std::ostream& os, const FileData& data) 107 108 std::ostream& operator<< (std::ostream& os, const FileData& data) 112 109 { 113 110 data.write(os); 114 111 return os; 115 112 } 116 std::istream& operator >> (std::istream& is, FileData& data)113 std::istream& operator>> (std::istream& is, FileData& data) 117 114 { 118 115 data.read(is); 119 116 return is; 120 117 } 121 void 122 CFileLockResolver::HandleError(LPCTSTR szFileName, DWORD dwErrorCode, int em, unsigned int passes)118 119 void CFileLockResolver::HandleError(LPCTSTR szFileName, DWORD dwErrorCode, int em, unsigned int passes) 123 120 { 124 121 if (ERROR_LOCK_VIOLATION == dwErrorCode … … 130 127 if (TRUE == m_bAskUser ) 131 128 { 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)); 134 132 } 135 133 … … 139 137 std::ofstream os(m_strLockFileList, std::ios_base::out | std::ios_base::app); 140 138 os << FileData(szFileName, em, passes); 141 142 139 } 143 144 145 /*if (TRUE == m_bAskUser146 && 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 154 140 } 155 156 141 } 157 142 158 void 159 CFileLockResolver::Resolve(LPCTSTR /*szFileName*/) 160 { 161 162 } 163 164 void 165 CFileLockResolver::Resolve(LPCTSTR szFileName, CStringArray& ar) 143 void CFileLockResolver::Resolve(LPCTSTR szFileName, CStringArray& ar) 166 144 { 167 145 std::ifstream is(szFileName); … … 179 157 DeleteFile(szFileName); 180 158 } 181 DWORD 182 CFileLockResolver::ErrorHandler(LPCTSTR szFileName, DWORD dwErrorCode, void* ctx, void* param)159 160 DWORD CFileLockResolver::ErrorHandler(LPCTSTR szFileName, DWORD dwErrorCode, void* ctx, void* param) 183 161 { 184 162 CFileLockResolver* self(static_cast<CFileLockResolver*>(param)); … … 188 166 } 189 167 190 void 191 CFileLockResolver::Close() 168 void CFileLockResolver::Close() 192 169 { 193 170 eraserSetErrorHandler(m_hHandle, NULL, NULL);
Note: See TracChangeset
for help on using the changeset viewer.
