read/write index

master
この中二病に爆焔を! 3 years ago
parent 81c4243988
commit fc2ee4cd26

@ -0,0 +1,6 @@
Module resourceTest
Sub Main()
End Sub
End Module

@ -44,7 +44,7 @@
<OptionInfer>On</OptionInfer>
</PropertyGroup>
<PropertyGroup>
<StartupObject>test.Program</StartupObject>
<StartupObject>test.resourceTest</StartupObject>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
@ -89,6 +89,7 @@
<Import Include="System.Threading.Tasks" />
</ItemGroup>
<ItemGroup>
<Compile Include="resourceTest.vb" />
<Compile Include="Program.vb" />
<Compile Include="My Project\AssemblyInfo.vb" />
<Compile Include="My Project\Application.Designer.vb">

@ -15,6 +15,7 @@ Public Class Resource : Implements IDisposable
Sub New(res As StreamPack)
buf = res
index = New IndexReader(res.OpenFile("/index.dat", FileMode.OpenOrCreate, FileAccess.Read)).Read
End Sub
Public Function Add(key As String, data As Byte()) As Boolean
@ -63,6 +64,18 @@ Public Class Resource : Implements IDisposable
Protected Overridable Sub Dispose(disposing As Boolean)
If Not disposedValue Then
If disposing Then
Using ms As New MemoryStream
Call New IndexWriter(ms).Write(index)
Call ms.Flush()
Call ms.Seek(Scan0, SeekOrigin.Begin)
Dim file As Stream = buf.OpenFile("/index.dat", FileMode.OpenOrCreate, FileAccess.Write)
Call file.Write(ms.ToArray, Scan0, ms.Length)
Call file.Flush()
Call file.Dispose()
End Using
' TODO: ()
Call buf.Dispose()
End If

Loading…
Cancel
Save