GSF.IO.FileStructure.Media.DiskMedium.CreateFile C# (CSharp) Method

CreateFile() public static method

Creates a DiskMedium from a stream. This will initialize the stream as an empty file structure.
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.
public static CreateFile ( CustomFileStream stream, MemoryPool pool, int fileStructureBlockSize ) : DiskMedium
stream CustomFileStream An open to use. The /// will assume ownership of this .
pool GSF.IO.Unmanaged.MemoryPool the to allocate data from
fileStructureBlockSize int the block size of the file structure. Usually 4kb.
return DiskMedium
        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);
        }

Usage Example

Ejemplo n.º 1
0
        public static DiskIo CreateFile(string fileName, MemoryPool pool, int fileStructureBlockSize, params Guid[] flags)
        {
            //Exclusive opening to prevent duplicate opening.
            CustomFileStream fileStream = CustomFileStream.CreateFile(fileName, pool.PageSize, fileStructureBlockSize);
            DiskMedium       disk       = DiskMedium.CreateFile(fileStream, pool, fileStructureBlockSize, flags);

            return(new DiskIo(disk, false));
        }