1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
CErrorManager.h
class CErrorManager
{
private:
int m_nUnDecryptedFilesIndex;
int m_nUnverifiedFilesIndex;
int m_nUnvalidNistFilesIndex;
bool m_bInitialize;
CFile m_fLogFile;
public:
CErrorManager(void);
~CErrorManager(void);
void open_log_file(CString l_strErrorFile);
void add_undecrypted_file(CString l_strErrorFile, CString l_strUndecryptedFileName);
void add_unverified_file(CString l_strErrorFile, CString l_strUnverifiedFileName);
void add_unexploitable_file(CString l_strErrorFile, CString l_strUnexploitableFileName);
void close_log_file(CString l_strErrorFile);
};
CErrorManager.cpp
CErrorManager::CErrorManager()
{
m_nUnDecryptedFilesIndex = 0;
m_nUnverifiedFilesIndex = 0;
m_nUnvalidNistFilesIndex = 0;
m_bInitialize = false;
}
CErrorManager::~CErrorManager(void)
{
}
void CErrorManager::open_log_file(CString l_strErrorFile)
{
CFileException fileException;
char l_szBuffer[256];
if ( !m_fLogFile.Open( l_strErrorFile, CFile::modeCreate |
CFile::modeNoTruncate, &fileException ) )
{
TRACE( "Can't open file %s, error = %u\n",
l_strErrorFile, fileException.m_cause );
}
strcpy(l_szBuffer,"Fichiers non déchiffrés :\n");
m_fLogFile.Write(l_szBuffer, strlen(l_szBuffer));
m_nUnDecryptedFilesIndex = m_nUnDecryptedFilesIndex + strlen(l_szBuffer);
strcpy(l_szBuffer,"\nFichiers refusés :\n");
m_fLogFile.Write(l_szBuffer, strlen(l_szBuffer));
m_nUnverifiedFilesIndex = m_nUnDecryptedFilesIndex + strlen(l_szBuffer);
strcpy(l_szBuffer,"\nFichiers inexploitables :\n");
m_fLogFile.Write(l_szBuffer, strlen(l_szBuffer));
m_nUnvalidNistFilesIndex = m_nUnverifiedFilesIndex + strlen(l_szBuffer);
}
void CErrorManager::add_undecrypted_file(CString l_strErrorFile, CString l_strUndecryptedFileName)
{
if ( m_bInitialize == false)
{
open_log_file (l_strErrorFile);
m_bInitialize = true;
}
m_fLogFile.Seek(m_nUnverifiedFilesIndex,CFile::begin);
m_fLogFile.Write(l_strUndecryptedFileName + "\n", l_strUndecryptedFileName.GetLength()+1);
m_nUnDecryptedFilesIndex += l_strUndecryptedFileName.GetLength()+1;
m_nUnverifiedFilesIndex += l_strUndecryptedFileName.GetLength()+1;
m_nUnvalidNistFilesIndex += l_strUndecryptedFileName.GetLength()+1;
}
void CErrorManager::add_unverified_file(CString l_strErrorFile, CString l_strUnverifiedFileName)
{
int x = 0;
x = l_strUnverifiedFileName.GetLength();
if ( m_bInitialize == false)
{
open_log_file (l_strErrorFile);
m_bInitialize = true;
}
m_fLogFile.Seek(m_nUnverifiedFilesIndex,CFile::begin);
m_fLogFile.Write(l_strUnverifiedFileName + "\n", l_strUnverifiedFileName.GetLength()+1);
m_nUnverifiedFilesIndex += l_strUnverifiedFileName.GetLength()+1;
m_nUnvalidNistFilesIndex += l_strUnverifiedFileName.GetLength()+1;
}
void CErrorManager::add_unexploitable_file(CString l_strErrorFile, CString l_strUnexploitableFileName)
{
if ( m_bInitialize == false)
{
open_log_file (l_strErrorFile);
m_bInitialize = true;
}
m_fLogFile.Seek(m_nUnvalidNistFilesIndex,CFile::begin);
m_fLogFile.Write(l_strUnexploitableFileName + "\n", l_strUnexploitableFileName.GetLength()+1);
m_nUnvalidNistFilesIndex += l_strUnexploitableFileName.GetLength()+1;
}
void CErrorManager::close_log_file(CString l_strErrorFile)
{
if (m_fLogFile.Open( l_strErrorFile, CFile::modeCreate |
CFile::modeReadWrite, NULL ) )
m_fLogFile.Close();
} |
Partager