-
Notifications
You must be signed in to change notification settings - Fork 0
/
GetPFM_DLG_FileIO.cpp
77 lines (77 loc) · 2.02 KB
/
GetPFM_DLG_FileIO.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
#include "GetPFM_DLG.h"
void GetPFM_DLG::dLoadPFM( void )
{
isModified = false;
xStrT st;
PFM* pfm;
xStr key, text, path, file;
gGetPFMFile( path, file );
wxFileConfig pfm_TF( gGetTitle(), gGetVendor(), file );
long i = 0;
bool atKey = false;
s8 index = dPFMName_LB->GetCount();
for ( --index; index >= 0; --index )
{
pfm = dGetPFM( index );
if ( !pfm->isDefault ) dPFMName_LB->Delete( index );
}
pfm = new PFM;
pfm->isDefault = false;
for
(
atKey = pfm_TF.GetFirstEntry( key, i );
atKey;
atKey = pfm_TF.GetNextEntry( key, i )
)
{
if ( key.IsEmpty() ) continue;
pfm->nowName = key;
pfm->oldName = key;
pfm_TF.Read( key, &text );
if ( text.IsEmpty() )
{
dNewPFM( pfm );
continue;
}
st.SetString( text, wxT( ";" ) );
pfm->nowFile = st.GetNextToken();
pfm->oldFile = pfm->nowFile;
text = st.GetNextToken();
if ( text.CmpNoCase( wxT( "BIG" ) ) == 0 ||
text == wxT( "1" ) ) pfm->endian = ENDIAN_BIG;
else if ( text.CmpNoCase( wxT( "LB" ) ) == 0 ||
text == wxT( "2" ) ) pfm->endian = ENDIAN_LB;
else pfm->endian = ENDIAN_LITTLE;
dNewPFM( pfm );
}
dPFMName_LB->Select( 0 );
dShowPFM();
}
void GetPFM_DLG::dSavePFM( void )
{
isModified = false;
PFM* pfm;
xStr text, path, file;
s8 count = dPFMName_LB->GetCount();
gGetPFMFile( path, file );
wxFileConfig pfm_TF( gGetTitle(), gGetVendor(), file );
gGetBinFile( path, file );
for ( s8 index = 0; index < count; ++index )
{
pfm = dGetPFM( index );
if ( pfm->isDefault ) continue;
switch ( pfm->endian )
{
case ENDIAN_BIG: text = wxT( ";1" ); break;
case ENDIAN_LB: text = wxT( ";2" ); break;
default: text = wxT( ";0" ); break;
}
pfm_TF.Write( pfm->nowName, pfm->nowFile + text );
// Change old data
file = path + pfm->oldFile + wxT( ".hexb" );
if ( wxFileExists( file ) )
wxRenameFile( file, path + pfm->nowFile + wxT( ".hexb" ) );
pfm->oldName = pfm->nowName;
pfm->oldFile = pfm->nowFile;
}
}