FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
DelphiCodeCoverage/Source/EmmaDataFile.pas at 1.0.15 · DelphiCodeCoverage/DelphiCodeCoverage · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
DelphiCodeCoverage
/
DelphiCodeCoverage
Public
Notifications
You must be signed in to change notification settings
Fork
39
Star
94
Code
Issues
12
Pull requests
4
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
DelphiCodeCoverage
/
Source
/
EmmaDataFile.pas
Copy path
More file actions
More file actions
Latest commit
History
History
History
142 lines (122 loc) · 3.72 KB
Breadcrumbs
DelphiCodeCoverage
/
Source
/
EmmaDataFile.pas
Copy path
File metadata and controls
142 lines (122 loc) · 3.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
(*
*********************************************************************
*)
(*
Delphi Code Coverage
*)
(*
*)
(*
A quick hack of a Code Coverage Tool for Delphi
*)
(*
by Christer Fahlgren and Nick Ring
*)
(*
*)
(*
This Source Code Form is subject to the terms of the Mozilla Public
*)
(*
License, v. 2.0. If a copy of the MPL was not distributed with this
*)
(*
file, You can obtain one at http://mozilla.org/MPL/2.0/.
*)
unit
EmmaDataFile;
interface
uses
System.Classes,
System.Generics.Collections,
EmmaMergable;
type
TEmmaFile =
class
strict
private
FMergables: TList<TMergable>;
public
constructor
Create;
destructor
Destroy; override;
procedure
Add
(
const
AMergable: TMergable);
procedure
Read
(
const
AFile: TStream);
procedure
Write
(AFile: TStream;
const
AVersion: Int64);
end
;
implementation
uses
EmmaFileHelper,
EmmaMetaData,
System.SysUtils,
uConsoleOutput,
EmmaCoverageData;
const
SKIP_LENGTH =
3
*
4
;
TYPE_METADATA =
0
;
constructor
TEmmaFile.Create;
begin
inherited
Create;
FMergables := TList<TMergable>.create;
end
;
destructor
TEmmaFile.Destroy;
begin
FMergables.Free;
inherited
Destroy;
end
;
procedure
TEmmaFile.Add
(
const
AMergable: TMergable);
begin
FMergables.Add(AMergable);
end
;
procedure
TEmmaFile.Read
(
const
AFile: TStream);
var
MagicValue:
array
[
0
..
3
]
of
Byte;
FileHeaderBuffer:
array
[
0
.. SKIP_LENGTH -
1
]
of
Byte;
Version: Int64;
BytesRead: Integer;
EntryLength: Int64;
EntryType: Byte;
Mergable: TMergable;
DataInput: IEmmaDataInput;
begin
DataInput := TEmmaDataInput.Create(AFile);
AFile.Read(MagicValue[
0
],
4
);
Version := DataInput.ReadInt64;
if
(Version = EmmaVersion20)
or
(Version = EmmaVersion21)
then
begin
VerboseOutput(
'
Yes, version 2.0 or version 2.1
'
);
BytesRead := AFile.Read(FileHeaderBuffer, SKIP_LENGTH);
if
(BytesRead <> SKIP_LENGTH)
then
begin
raise EEmmaException.Create(
'
Consuming file header, but file ended unexpectedly
'
);
end
;
while
AFile.Position < AFile.Size
do
begin
EntryLength := DataInput.ReadInt64;
EntryType := DataInput.ReadByte;
VerboseOutput(
'
EntryLength:
'
+ IntToStr(EntryLength));
VerboseOutput(
'
EntryType:
'
+ IntToStr(EntryType));
if
(EntryType = TYPE_METADATA)
then
begin
Mergable := TEmmaMetaData.Create(Version);
Mergable.LoadFromFile(DataInput);
FMergables.Add(Mergable);
end
else
begin
Mergable := TEmmaCoverageData.Create;
Mergable.LoadFromFile(DataInput);
FMergables.Add(Mergable);
end
;
end
;
end
else
begin
ConsoleOutput(
'
ERROR: Not version 2.0 or 2.1)
'
);
end
;
end
;
procedure
TEmmaFile.Write
(AFile: TStream;
const
AVersion: Int64);
var
Buffer:
array
[
0
..
3
]
of
Byte;
Mergable: TMergable;
DataOutput: IEmmaDataOutput;
begin
DataOutput := TEmmaDataOutput.Create(AFile);
Buffer[
0
] := Byte(
'
E
'
);
Buffer[
1
] := Byte(
'
M
'
);
Buffer[
2
] := Byte(
'
M
'
);
Buffer[
3
] := Byte(
'
A
'
);
AFile.Write(Buffer[
0
],
4
);
DataOutput.WriteInt64(AVersion);
//
Write file header with application version info
DataOutput.WriteInteger($
2
);
DataOutput.WriteInteger(
0
);
DataOutput.WriteInteger($14C0);
for
Mergable
in
FMergables
do
begin
DataOutput.WriteInt64(Mergable.EntryLength);
DataOutput.WriteByte(Mergable.EntryType);
Mergable.WriteToFile(DataOutput);
end
;
end
;
end
.
Back
|
FazBrowse Home
|
New Git URL