VERSION 1.0 CLASS
BEGIN
MultiUse = -1
'True
Persistable = 0
'NotPersistable
 
ataBindingBehavior = 0
'vbNone
 
ataSourceBehavior = 0
'vbNone
MTSTransactionMode = 0
'NotAnMTSObject
END
Attribute VB_Name = "clsFileSystem"
Attribute VB_GlobalNameSpace =
False
Attribute VB_Creatable =
True
Attribute VB_PredeclaredId =
False
Attribute VB_Exposed =
False
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Private m_hFile
As Long
Private m_Err
As ErrObject
Property Get IsEof()
As Boolean
If m_hFile > 0
Then
IsEof = (
Seek(m_hFile) > LOF(m_hFile))
Else
Set m_Err =
New ErrObject
m_Err.Raise 0, "clsFileSystem", "No open file"
End If
End Property
Function FOpen(sFile
As String)
As Boolean
Set m_Err =
Nothing
On Error GoTo ERR_FOpen
m_hFile = FreeFile()
Open sFile
For Binary As #m_hFile
FOpen =
True
Exit Function
ERR_FOpen:
m_hFile = -1
Set m_Err = Err
End Function
Function FCreate(sFile
As String)
As Boolean
Set m_Err =
Nothing
On Error GoTo ERR_FCreate
m_hFile = FreeFile()
Open sFile
For Binary As #m_hFile
FCreate =
True
Exit Function
ERR_FCreate:
m_hFile = -1
Set m_Err = Err
End Function
Sub FClose()
If m_hFile > 0
Then
Close #m_hFile
m_hFile = -1
End If
End Sub
Function FRead(
ByRef sBuffer
As String, nBytes
As Long)
As Long
Dim nBytesRead
As Long
Set m_Err =
Nothing
On Error GoTo ERR_FRead
nBytesRead = LOF(m_hFile) -
Seek(m_hFile) + 1
'We add 1 to adjust for 0-based counting system
If nBytes > nBytesRead
Then nBytes = nBytesRead
sBuffer = Space(nBytes)
Get #m_hFile, , sBuffer
FRead = nBytes
Exit Function
ERR_FRead:
Set m_Err = Err
End Function
Function FReadLine(
ByRef sBuffer
As String, nMaxChars
As Long)
As Long
Dim nBytesRead
As Long
Set m_Err =
Nothing
On Error GoTo ERR_FReadLine
nBytesRead = LOF(m_hFile) -
Seek(m_hFile) + 1
'We add 1 to adjust for 0-based counting system
nMaxChars = nMaxChars +
Len(vbCrLf)
If nMaxChars > nBytesRead
Then nMaxChars = nBytesRead
sBuffer = Space(nMaxChars)
Get #m_hFile, , sBuffer
If InStr(sBuffer, vbCrLf) > 0
Then
nMaxChars = InStr(sBuffer, vbCrLf) - 1
FSeek -(
Len(sBuffer) - nMaxChars -
Len(vbCrLf) + 1), 1
sBuffer = Left(sBuffer, nMaxChars)
End If
FReadLine = nMaxChars
Exit Function
ERR_FReadLine:
Set m_Err = Err
End Function
Function FWrite(sBuffer
As String)
As Long
Set m_Err =
Nothing
On Error GoTo ERR_FWrite
Put #m_hFile, , sBuffer
FWrite =
Len(sBuffer)
ERR_FWrite:
Set m_Err = Err
End Function
Function FPos()
As Long
FPos =
Seek(m_hFile)
End Function
Function FSeek(
ByVal nMove
As Long, nMoveFrom
As Integer)
As Long
Dim nOffset
As Long
If m_hFile <= 0
Then Exit Function
Select Case nMoveFrom
Case 0
'FS_FILE_BEGIN
nOffset = 0
Case 1
'FS_FILE_CURRENT
nOffset =
Seek(m_hFile)
Case 2
'FS_FILE_END
nOffset = LOF(m_hFile)
End Select
Seek m_hFile, nOffset + nMove + 1
FSeek = Seek(m_hFile)
End Function
Function FSize()
As Long
If m_hFile > 0
Then FSize = LOF(m_hFile)
End Function
Function FError()
As ErrObject
Set FError = m_Err
End Function
Function FExists(
ByVal sFile)
As Boolean
On Error Resume Next
sFile = Dir(sFile)
FExists = (Err.Number = 0
And sFile <> ""
On Error GoTo 0
End Function