MCPcopy Create free account
hub / github.com/MaxBelkov/visualsyslog / TMYIniFile

Method TMYIniFile

sourcecommon/inif.cpp:13–79  ·  view source on GitHub ↗

--------------------------------------------------------------------------- --------------------------------------------------------------------------- ---------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

11//---------------------------------------------------------------------------
12//---------------------------------------------------------------------------
13TMYIniFile::TMYIniFile(char * File, bool enableExceptions, bool bCreateNewFile) :
14 TFile(enableExceptions),
15 FileName(File)
16{
17 list = NULL;
18 BYTE * p = NULL;
19 try
20 {
21 IniError = 0;
22 bAnyError = false;
23 bChange = false;
24 CurSectionIndex = -1;
25 CurParamIndex = -1;
26 list = new TStringList();
27
28 if( ! bCreateNewFile )
29 {
30 // ������� ���� ��� ������
31 if( ! Open(FileName.c_str(), GENERIC_READ, FILE_SHARE_READ,
32 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN) )
33 {
34 // ����� ��� - ������ �� ����, ����� �� ����� ��� ����� ����������...
35 //IniError = 1;
36 bAnyError = true;
37 return;
38 }
39
40 // ������� ���������� �����
41 DWORD l = GetSize();
42 if( l > 0 )
43 {
44 p = new BYTE[l];
45 AnsiString s;
46 if( ! Read(p, l) )
47 {
48 IniError = 1;
49 bAnyError = true;
50 }
51 else
52 for(DWORD i=0; i<l; i++)
53 {
54 if( p[i]=='\r' || p[i]=='\n' || !p[i] )
55 {
56 s = s.TrimLeft();
57 if( s.Length()>0 )
58 {
59 list->Add(s);
60 s = "";
61 }
62 }
63 else
64 s += (char)p[i];
65 }
66 delete [] p;
67 p = NULL;
68 }
69 }
70 }

Callers

nothing calls this directly

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected