-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathJCDFile.cpp
89 lines (62 loc) · 1.22 KB
/
JCDFile.cpp
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
#include "stdafx.h"
#include "JCDFile.h"
#include "TreeItem.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
BOOL CJCDFile::prv_LoadFile()
{
if (m_strFileName.IsEmpty())
{
return FALSE;
}
CFile fileIn;
if (fileIn.Open(m_strFileName, CFile::modeRead) == 0)
{
return FALSE;
}
// m_pTreeCtrl->DeleteAllItems();
int iFileSize = fileIn.GetLength();
if (m_pbFileBuf)
{
delete m_pbFileBuf;
m_pbFileBuf = NULL;
}
m_pbFileBuf = new BYTE[iFileSize];
memset(m_pbFileBuf, 0, iFileSize);
fileIn.Read((void *)m_pbFileBuf, iFileSize);
fileIn.Close();
CJCDFile *pJCDFile = this;
m_pbPos = m_pbFileBuf;
JCD_LOAD_BYTE(m_bVer);
JCD_LOAD_INT(m_dwItemCount);
return TRUE;
}
BOOL CJCDFile::ReadFile(void *pData, DWORD dwCount)
{
memcpy(pData, m_pbPos, dwCount);
m_pbPos += dwCount;
return TRUE;
}
BOOL CJCDFile::SaveFile(void *pData, DWORD dwCount)
{
m_fileWrite.Write(pData, dwCount);
return TRUE;
}
DWORD CJCDFile::GetItemCount()
{
return m_dwItemCount;
}
int CJCDFile::GetNextItemClass()
{
return *(int *)m_pbPos;
}
BOOL CJCDFile::prv_FillFileHeader()
{
CJCDFile *pJCDFile = this;
JCD_SAVE_BYTE(m_bVer);
JCD_SAVE_INT(m_dwItemCount);
return TRUE;
}