diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-06 16:27:44 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-06 16:27:44 +0000 |
commit | f6d53c90114069402b549aa7c0bc79044aace51d (patch) | |
tree | e6cd03b492df84a43c231b76dec0771fc9eba60a /plugins/Db3x_mmap/src/dbtool/disk.cpp | |
parent | 4f39e22aface0cb33d36532151b54a5e3950f629 (diff) |
huh, finally: total database encryption, including histories
git-svn-id: http://svn.miranda-ng.org/main/trunk@7522 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Db3x_mmap/src/dbtool/disk.cpp')
-rw-r--r-- | plugins/Db3x_mmap/src/dbtool/disk.cpp | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/plugins/Db3x_mmap/src/dbtool/disk.cpp b/plugins/Db3x_mmap/src/dbtool/disk.cpp index a5178c8ea2..d22afb70d9 100644 --- a/plugins/Db3x_mmap/src/dbtool/disk.cpp +++ b/plugins/Db3x_mmap/src/dbtool/disk.cpp @@ -21,28 +21,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int CDb3Base::SignatureValid(DWORD ofs, DWORD signature)
{
- DWORD sig;
-
- if (ofs+sizeof(sig) >= sourceFileSize) {
+ if (ofs + sizeof(DWORD) >= sourceFileSize) {
cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found (database truncated?)"));
return 0;
}
- sig = *(DWORD*)(m_pDbCache+ofs);
-
+ DWORD sig = *(DWORD*)(m_pDbCache + ofs);
return sig == signature;
}
int CDb3Base::PeekSegment(DWORD ofs, PVOID buf, int cbBytes)
{
- DWORD bytesRead;
-
if (ofs >= sourceFileSize) {
cb->pfnAddLogMessage(STATUS_ERROR, TranslateT("Invalid offset found"));
return ERROR_SEEK;
}
- if (ofs+cbBytes > sourceFileSize)
+ DWORD bytesRead;
+ if (ofs + cbBytes > sourceFileSize)
bytesRead = sourceFileSize - ofs;
else
bytesRead = cbBytes;
@@ -52,7 +48,7 @@ int CDb3Base::PeekSegment(DWORD ofs, PVOID buf, int cbBytes) return ERROR_READ_FAULT;
}
- CopyMemory(buf, m_pDbCache+ofs, bytesRead);
+ CopyMemory(buf, m_pDbCache + ofs, bytesRead);
if ((int)bytesRead<cbBytes) return ERROR_HANDLE_EOF;
return ERROR_SUCCESS;
@@ -64,12 +60,11 @@ int CDb3Base::ReadSegment(DWORD ofs, PVOID buf, int cbBytes) if (ret != ERROR_SUCCESS && ret != ERROR_HANDLE_EOF) return ret;
if (cb->bAggressive) {
- if (ofs+cbBytes > sourceFileSize) {
+ if (ofs + cbBytes > sourceFileSize) {
cb->pfnAddLogMessage(STATUS_WARNING, TranslateT("Can't write to working file, aggressive mode may be too aggressive now"));
- ZeroMemory(m_pDbCache+ofs, sourceFileSize-ofs);
+ ZeroMemory(m_pDbCache + ofs, sourceFileSize - ofs);
}
- else
- ZeroMemory(m_pDbCache+ofs, cbBytes);
+ else ZeroMemory(m_pDbCache + ofs, cbBytes);
}
cb->spaceProcessed += cbBytes;
return ERROR_SUCCESS;
@@ -85,7 +80,7 @@ DWORD CDb3Base::WriteSegment(DWORD ofs, PVOID buf, int cbBytes) }
SetFilePointer(cb->hOutFile, ofs, NULL, FILE_BEGIN);
WriteFile(cb->hOutFile, buf, cbBytes, &bytesWritten, NULL);
- if ((int)bytesWritten<cbBytes) {
+ if ((int)bytesWritten < cbBytes) {
cb->pfnAddLogMessage(STATUS_FATAL, TranslateT("Can't write to output file - disk full? (%u)"), GetLastError());
return WS_ERROR;
}
@@ -101,7 +96,7 @@ int CDb3Base::ReadWrittenSegment(DWORD ofs, PVOID buf, int cbBytes) SetFilePointer(cb->hOutFile, ofs, NULL, FILE_BEGIN);
ReadFile(cb->hOutFile, buf, cbBytes, &bytesRead, NULL);
- if ((int)bytesRead<cbBytes)
+ if ((int)bytesRead < cbBytes)
return ERROR_READ_FAULT;
return ERROR_SUCCESS;
|