/// <summary> /// Creates a <see cref="DiskMedium"/> from a <see cref="stream"/>. /// This will initialize the <see cref="stream"/> as an empty file structure. /// </summary> /// <param name="stream">An open <see cref="FileStream"/> to use. The <see cref="DiskMedium"/> /// will assume ownership of this <see cref="FileStream"/>.</param> /// <param name="pool">the <see cref="MemoryPool"/> to allocate data from</param> /// <param name="fileStructureBlockSize">the block size of the file structure. Usually 4kb.</param> /// <param name="flags">Flags to write to the file</param> /// <returns></returns> /// <remarks> /// This will not check if the file is truely a new file. If calling this with an existing /// archive file, it will overwrite the table of contents, corrupting the file. /// </remarks> public static DiskMedium CreateFile(CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize, params Guid[] flags) { FileHeaderBlock header = FileHeaderBlock.CreateNew(fileStructureBlockSize, flags); BufferedFile disk = new BufferedFile(stream, pool, header, isNewFile: true); return(new DiskMedium(disk, header)); }
/// <summary> /// Creates a <see cref="DiskMedium"/> from a <see cref="stream"/>. /// This will read the existing header from the <see cref="stream"/>. /// </summary> /// <param name="stream">An open <see cref="FileStream"/> to use. The <see cref="DiskMedium"/> /// will assume ownership of this <see cref="FileStream"/>.</param> /// <param name="pool">The <see cref="MemoryPool"/> to allocate data from.</param> /// <param name="fileStructureBlockSize">the block size of the file structure. Usually 4kb.</param> /// <returns></returns> public static DiskMedium OpenFile(CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize) { byte[] buffer = new byte[fileStructureBlockSize]; stream.ReadRaw(0, buffer, fileStructureBlockSize); FileHeaderBlock header = FileHeaderBlock.Open(buffer); BufferedFile disk = new BufferedFile(stream, pool, header, isNewFile: false); return(new DiskMedium(disk, header)); }
/// <summary> /// Creates a <see cref="DiskMedium"/> from a <see cref="stream"/>. /// This will read the existing header from the <see cref="stream"/>. /// </summary> /// <param name="stream">An open <see cref="FileStream"/> to use. The <see cref="DiskMedium"/> /// will assume ownership of this <see cref="FileStream"/>.</param> /// <param name="pool">The <see cref="MemoryPool"/> to allocate data from.</param> /// <param name="fileStructureBlockSize">the block size of the file structure. Usually 4kb.</param> /// <returns></returns> public static DiskMedium OpenFile(CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize) { byte[] buffer = new byte[fileStructureBlockSize]; stream.ReadRaw(0, buffer, fileStructureBlockSize); FileHeaderBlock header = FileHeaderBlock.Open(buffer); BufferedFile disk = new BufferedFile(stream, pool, header, isNewFile: false); return new DiskMedium(disk, header); }
/// <summary> /// Creates a <see cref="DiskMedium"/> from a <see cref="stream"/>. /// This will initialize the <see cref="stream"/> as an empty file structure. /// </summary> /// <param name="stream">An open <see cref="FileStream"/> to use. The <see cref="DiskMedium"/> /// will assume ownership of this <see cref="FileStream"/>.</param> /// <param name="pool">the <see cref="MemoryPool"/> to allocate data from</param> /// <param name="fileStructureBlockSize">the block size of the file structure. Usually 4kb.</param> /// <param name="flags">Flags to write to the file</param> /// <returns></returns> /// <remarks> /// This will not check if the file is truely a new file. If calling this with an existing /// archive file, it will overwrite the table of contents, corrupting the file. /// </remarks> public static DiskMedium CreateFile(CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize, params Guid[] flags) { FileHeaderBlock header = FileHeaderBlock.CreateNew(fileStructureBlockSize, flags); BufferedFile disk = new BufferedFile(stream, pool, header, isNewFile: true); return new DiskMedium(disk, header); }
/// <summary> /// Creates a new <see cref="IoSession"/> /// </summary> /// <param name="stream">the base class</param> /// <param name="pageReplacement">The page Replacement Algorithm</param> internal IoSession(BufferedFile stream, PageReplacementAlgorithm pageReplacement) : base(pageReplacement) { m_stream = stream; }
/// <summary> /// Creates a new <see cref="IoSession"/> /// </summary> /// <param name="stream">the base class</param> /// <param name="pageReplacement">The page Replacement Algorithm</param> internal IoSession(BufferedFile stream, PageReplacementAlgorithm pageReplacement) : base(pageReplacement) { m_stream = stream; }