Skip to content

Commit 1f0e2ff

Browse files
committed
Changed Debug folder to DebugLog to avoid ignoring files
1 parent 1a14aaf commit 1f0e2ff

File tree

4 files changed

+440
-0
lines changed

4 files changed

+440
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
Imports System.IO
2+
3+
Public Class AccessedBytesDebugFile
4+
5+
#Region "Creation and Destruction"
6+
7+
Public Sub New(ByVal outputFileStream As StreamWriter)
8+
Me.theOutputFileStreamWriter = outputFileStream
9+
End Sub
10+
11+
#End Region
12+
13+
#Region "Methods"
14+
15+
Public Sub WriteHeaderComment()
16+
Dim line As String = ""
17+
18+
line = "// "
19+
line += TheApp.GetHeaderComment()
20+
Me.theOutputFileStreamWriter.WriteLine(line)
21+
End Sub
22+
23+
Public Sub WriteFileSeekLog(ByVal aFileSeekLog As FileSeekLog)
24+
Dim line As String
25+
26+
line = "====== File Size ======"
27+
Me.WriteLogLine(0, line)
28+
29+
line = aFileSeekLog.theFileSize.ToString("N0")
30+
Me.WriteLogLine(1, line)
31+
32+
line = "====== File Seek Log ======"
33+
Me.WriteLogLine(0, line)
34+
35+
line = "--- Summary ---"
36+
Me.WriteLogLine(0, line)
37+
38+
Dim offsetStart As Long
39+
Dim offsetEnd As Long
40+
offsetStart = -1
41+
offsetEnd = -1
42+
For i As Integer = 0 To aFileSeekLog.theFileSeekList.Count - 1
43+
If offsetStart = -1 Then
44+
offsetStart = aFileSeekLog.theFileSeekList.Keys(i)
45+
End If
46+
offsetEnd = aFileSeekLog.theFileSeekList.Values(i)
47+
48+
If aFileSeekLog.theFileSeekDescriptionList.Values(i).StartsWith("[ERROR] Unread bytes") Then
49+
If i > 0 Then
50+
line = offsetStart.ToString("N0") + " - " + (aFileSeekLog.theFileSeekList.Keys(i) - 1).ToString("N0")
51+
Me.WriteLogLine(1, line)
52+
End If
53+
If aFileSeekLog.theFileSeekDescriptionList.Values(i).StartsWith("[ERROR] Unread bytes (all zeroes)") Then
54+
line = aFileSeekLog.theFileSeekList.Keys(i).ToString("N0") + " - " + offsetEnd.ToString("N0") + " [ERROR] Unread bytes (all zeroes)"
55+
Else
56+
line = aFileSeekLog.theFileSeekList.Keys(i).ToString("N0") + " - " + offsetEnd.ToString("N0") + " [ERROR] Unread bytes (non-zero)"
57+
End If
58+
Me.WriteLogLine(1, line)
59+
offsetStart = -1
60+
ElseIf (i = aFileSeekLog.theFileSeekList.Count - 1) OrElse (offsetEnd + 1 <> aFileSeekLog.theFileSeekList.Keys(i + 1)) Then
61+
line = offsetStart.ToString("N0") + " - " + offsetEnd.ToString("N0")
62+
Me.WriteLogLine(1, line)
63+
offsetStart = -1
64+
End If
65+
Next
66+
67+
line = "------------------------"
68+
Me.WriteLogLine(0, line)
69+
line = "--- Each Section or Loop ---"
70+
Me.WriteLogLine(0, line)
71+
72+
offsetEnd = -1
73+
For i As Integer = 0 To aFileSeekLog.theFileSeekList.Count - 1
74+
offsetStart = aFileSeekLog.theFileSeekList.Keys(i)
75+
offsetEnd = aFileSeekLog.theFileSeekList.Values(i)
76+
77+
line = offsetStart.ToString("N0") + " - " + offsetEnd.ToString("N0") + " " + aFileSeekLog.theFileSeekDescriptionList.Values(i)
78+
Me.WriteLogLine(1, line)
79+
Next
80+
81+
line = "========================"
82+
Me.WriteLogLine(0, line)
83+
End Sub
84+
85+
#End Region
86+
87+
#Region "Private Methods"
88+
89+
Private Sub WriteFileSeparatorLines()
90+
Dim line As String
91+
92+
Me.WriteLogLine(0, "")
93+
Me.WriteLogLine(0, "")
94+
line = "################################################################################"
95+
Me.WriteLogLine(0, line)
96+
Me.WriteLogLine(0, "")
97+
Me.WriteLogLine(0, "")
98+
End Sub
99+
100+
Private Sub WriteLogLine(ByVal indentLevel As Integer, ByVal line As String)
101+
Dim indentedLine As String = ""
102+
For i As Integer = 1 To indentLevel
103+
indentedLine += vbTab
104+
Next
105+
indentedLine += line
106+
Me.theOutputFileStreamWriter.WriteLine(indentedLine)
107+
Me.theOutputFileStreamWriter.Flush()
108+
End Sub
109+
110+
#End Region
111+
112+
#Region "Data"
113+
114+
Private theOutputFileStreamWriter As StreamWriter
115+
116+
#End Region
117+
118+
End Class
+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
Module DebugFormatModule
2+
3+
Public Function FormatByteWithHexLine(ByVal name As String, ByVal value As Byte) As String
4+
Dim line As String
5+
line = name
6+
line += ": "
7+
line += value.ToString("N0")
8+
line += " (0x"
9+
line += value.ToString("X2")
10+
line += ")"
11+
Return line
12+
End Function
13+
14+
Public Function FormatIntegerLine(ByVal name As String, ByVal value As Integer) As String
15+
Dim line As String
16+
line = name
17+
line += ": "
18+
line += value.ToString("N0")
19+
Return line
20+
End Function
21+
22+
Public Function FormatIntegerAsHexLine(ByVal name As String, ByVal value As Integer) As String
23+
Dim line As String
24+
line = name
25+
line += ": "
26+
line += "0x"
27+
line += value.ToString("X8")
28+
Return line
29+
End Function
30+
31+
Public Function FormatIntegerWithHexLine(ByVal name As String, ByVal value As Integer) As String
32+
Dim line As String
33+
line = name
34+
line += ": "
35+
line += value.ToString("N0")
36+
line += " (0x"
37+
line += value.ToString("X8")
38+
line += ")"
39+
Return line
40+
End Function
41+
42+
Public Function FormatLongWithHexLine(ByVal name As String, ByVal value As Long) As String
43+
Dim line As String
44+
line = name
45+
line += ": "
46+
line += value.ToString("N0", TheApp.InternalNumberFormat)
47+
line += " (0x"
48+
line += value.ToString("X16")
49+
line += ")"
50+
Return line
51+
End Function
52+
53+
Public Function FormatSingleFloatLine(ByVal name As String, ByVal value As Single) As String
54+
Dim line As String
55+
line = name
56+
line += ": "
57+
line += value.ToString("N6", TheApp.InternalNumberFormat)
58+
Return line
59+
End Function
60+
61+
Public Function FormatDoubleFloatLine(ByVal name As String, ByVal value As Double) As String
62+
Dim line As String
63+
line = name
64+
line += ": "
65+
line += value.ToString("N6", TheApp.InternalNumberFormat)
66+
Return line
67+
End Function
68+
69+
Public Function FormatStringLine(ByVal name As String, ByVal value As String) As String
70+
Dim line As String
71+
line = name
72+
line += ": "
73+
line += CStr(value).TrimEnd(Chr(0))
74+
Return line
75+
End Function
76+
77+
Public Function FormatIndexLine(ByVal name As String, ByVal value As Integer) As String
78+
Dim line As String
79+
line = "["
80+
line += name
81+
line += " index: "
82+
line += value.ToString("N0")
83+
line += "]"
84+
Return line
85+
End Function
86+
87+
Public Function FormatVectorLine(ByVal name As String, ByVal x As Double, ByVal y As Double, ByVal z As Double) As String
88+
Dim line As String
89+
line = name
90+
line += "[x,y,z]: ("
91+
line += x.ToString("N6", TheApp.InternalNumberFormat)
92+
line += ", "
93+
line += y.ToString("N6", TheApp.InternalNumberFormat)
94+
line += ", "
95+
line += z.ToString("N6", TheApp.InternalNumberFormat)
96+
line += ")"
97+
Return line
98+
End Function
99+
100+
Public Function FormatVectorLine(ByVal name As String, ByVal value As SourceVector) As String
101+
Dim line As String
102+
line = name
103+
line += "[x,y,z]: ("
104+
line += value.x.ToString("N6", TheApp.InternalNumberFormat)
105+
line += ", "
106+
line += value.y.ToString("N6", TheApp.InternalNumberFormat)
107+
line += ", "
108+
line += value.z.ToString("N6", TheApp.InternalNumberFormat)
109+
line += ")"
110+
Return line
111+
End Function
112+
113+
Public Function FormatQuaternionLine(ByVal name As String, ByVal value As SourceQuaternion) As String
114+
Dim line As String
115+
line = name
116+
line += "[x,y,z,w]: ("
117+
line += value.x.ToString("N6", TheApp.InternalNumberFormat)
118+
line += ", "
119+
line += value.y.ToString("N6", TheApp.InternalNumberFormat)
120+
line += ", "
121+
line += value.z.ToString("N6", TheApp.InternalNumberFormat)
122+
line += ", "
123+
line += value.w.ToString("N6", TheApp.InternalNumberFormat)
124+
line += ")"
125+
Return line
126+
End Function
127+
128+
End Module

0 commit comments

Comments
 (0)