@@ -37,6 +37,7 @@ Private P_BUFFERSIZE As Single '-------------------Buffer's size x10 MB (0.5 by
37
37
Private P_ENDSTREAMONLINEBREAK As Boolean '--------If true, each stream ends on a line break.
38
38
Private P_ISOPENSTREAM As Boolean '----------------Indicates if the object is linked to a file
39
39
Private P_LINEBREAK As String '--------------------Holds the char used to end a Stream.
40
+ Private P_LINEBREAKMATCHINGBEHAVIOR As EndLineMatchingBehavior 'How to find the next line break.
40
41
Private P_UNIFIEDLFOUTPUT As Boolean '-------------If true, the buffer string will be returned
41
42
' with the LF char as Line Break.
42
43
Private P_STREAMLENGTH As Long '-------------------File len.
@@ -71,6 +72,10 @@ Public Enum EndLineChar
71
72
CR = 1
72
73
LF = 2
73
74
End Enum
75
+ Public Enum EndLineMatchingBehavior
76
+ OnlyBackwardSense = 0 'From the end to the beginning of the buffer.
77
+ Bidirectional = 1 'Find the line break in both directions.
78
+ End Enum
74
79
'////////////////////////////////////////////////////////////////////////////////////////////
75
80
'#
76
81
' PROPERTIES:
@@ -112,6 +117,12 @@ Public Property Get lineBreak() As String
112
117
Attribute lineBreak.VB_Description = "Returns the character used to end the last received stream. The value is vbNullString when the last stream is not forced to end on line break."
113
118
lineBreak = P_LINEBREAK
114
119
End Property
120
+ Public Property Get linebreakMatchingBehavior() As EndLineMatchingBehavior
121
+ linebreakMatchingBehavior = P_LINEBREAKMATCHINGBEHAVIOR
122
+ End Property
123
+ Public Property Let linebreakMatchingBehavior(value As EndLineMatchingBehavior )
124
+ P_LINEBREAKMATCHINGBEHAVIOR = value
125
+ End Property
115
126
Public Property Get pointerPosition() As Long
116
127
Attribute pointerPosition.VB_Description = "Gets the overall pointer position over the current text file."
117
128
If P_ISOPENSTREAM Then
@@ -160,21 +171,23 @@ Private Sub FindEOLcharacter()
160
171
Dim EOLchr As EndLineChar
161
172
Dim missingEOLchar As Boolean
162
173
Dim EOStream As Boolean
163
-
164
- Do
165
- CrCharInStream = InStrB(1 , Buffer, vbCr)
166
- LfCharInStream = InStrB(1 , Buffer, vbLf)
167
- missingEOLchar = (Not CrCharInStream) And (Not LfCharInStream)
168
- If missingEOLchar Then
169
- DoubleBufferSize
170
- SeekPointer TmpInitialPos
171
- Get #FileHandled, , Buffer
172
- InitialPos = Seek (FileHandled)
173
- BufferMark = LenB(Buffer)
174
- EOStream = (P_STREAMLENGTH <= InitialPos)
175
- End If
176
- Loop While missingEOLchar And Not EOStream
177
- P_ATENDOFSTREAM = EOStream
174
+
175
+ If P_LINEBREAKMATCHINGBEHAVIOR = EndLineMatchingBehavior.Bidirectional Then
176
+ Do
177
+ CrCharInStream = InStrB(1 , Buffer, vbCr)
178
+ LfCharInStream = InStrB(1 , Buffer, vbLf)
179
+ missingEOLchar = (Not CrCharInStream) And (Not LfCharInStream)
180
+ If missingEOLchar Then
181
+ DoubleBufferSize
182
+ SeekPointer TmpInitialPos
183
+ Get #FileHandled, , Buffer
184
+ InitialPos = Seek (FileHandled)
185
+ BufferMark = LenB(Buffer)
186
+ EOStream = (P_STREAMLENGTH <= InitialPos)
187
+ End If
188
+ Loop While missingEOLchar And Not EOStream
189
+ P_ATENDOFSTREAM = EOStream
190
+ End If
178
191
If Not EOStream Then
179
192
If Not missingEOLchar Then
180
193
Last2Chrs = MidB$(Buffer, BufferMark - 3 , 4 )
@@ -343,6 +356,7 @@ Private Sub Class_Initialize()
343
356
P_BUFFERSIZE = 0.5
344
357
P_BUFFERLENGTH = CLng(P_BUFFERSIZE * SizeFactor)
345
358
P_ENDSTREAMONLINEBREAK = False
359
+ P_LINEBREAKMATCHINGBEHAVIOR = EndLineMatchingBehavior.Bidirectional
346
360
P_UNIFIEDLFOUTPUT = False
347
361
Buffer = SPACE$(P_BUFFERLENGTH)
348
362
NullChar = ChrW(0 )
0 commit comments