CSharpTest.Net
FragmentedFile Class
Members  Example  See Also  Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace : FragmentedFile Class

Glossary Item Box

Provides a means of storing multitudes of small files inside one big one. I doubt this is a good name for it, but it works. Anyway, the file is broken into fixed size blocks and each block can be chained to another to allow the sub-allocation to grow larger than the block size. This is the primary storage vehicle for the BPlusTree implementation.

Syntax

Visual Basic (Declaration) 
Public Class FragmentedFile 
C# 
public class FragmentedFile 

Example

Library/Library.Test/TestFragmentedFile.cs

C#Copy Code
SharedMemoryStream shared = new SharedMemoryStream();
FragmentedFile.CreateNew(shared, 512, 100, 2).Dispose();

using (FragmentedFile ff = new FragmentedFile(shared, 512, 100, 2))
{
    long id;
    byte[] bytes = MakeBytes(255);
    using (Stream write = ff.Create(out id))
    using (ITransactable trans = (ITransactable)write)
    {
        write.Write(bytes, 0, bytes.Length);
        trans.Commit();
        Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)));
        trans.Rollback();
    }

    AssertThrows<InvalidDataException>(delegate() { ff.Open(id, FileAccess.Read); });
}
VB.NETCopy Code
Dim [shared] As New SharedMemoryStream()
FragmentedFile.CreateNew([shared], 512, 100, 2).Dispose()

Using ff As New FragmentedFile([shared], 512, 100, 2)
    Dim id As Long
    Dim bytes As Byte() = MakeBytes(255)
    Using write As Stream = ff.Create(id)
        Using trans As ITransactable = DirectCast(write, ITransactable)
            write.Write(bytes, 0, bytes.Length)
            trans.Commit()
            Assert.AreEqual(bytes, IOStream.ReadAllBytes(ff.Open(id, FileAccess.Read)))
            trans.Rollback()
        End Using
    End Using

    AssertThrows(Of InvalidDataException)(Function() Do
        ff.Open(id, FileAccess.Read)
    End Function)
End Using

Inheritance Hierarchy

System.Object
   CSharpTest.Net.IO.FragmentedFile

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys