public static void AddBlock() { if (NumBlocks < ArrayNumBlocks) { Memblocks[NumBlocks++] = null; } else { V8MemBlock[] mb = new V8MemBlock[ArrayNumBlocks + Delta]; for (uint i = 0; i < ArrayNumBlocks; i++) { mb[i] = Memblocks[i]; } for (uint i = ArrayNumBlocks; i < ArrayNumBlocks + Delta; i++) { mb[i] = null; } ArrayNumBlocks += Delta; Memblocks = null; Memblocks = mb; } }
public static void CreateMemblocks(UInt32 _numblocks) { NumBlocks = _numblocks; ArrayNumBlocks = (NumBlocks / Delta + 1) * Delta; Memblocks = new V8MemBlock[ArrayNumBlocks]; //memset(memblocks, 0, array_numblocks * sizeof(MemBlock*)); }
public bool Getblock(ref byte[] buf, UInt32 block_number, Int32 blocklen = -1) // буфер принадлежит вызывающей процедуре { if (Data1CD == null) { return(false); } if (blocklen < 0) { blocklen = (Int32)Pagesize; } if (block_number >= length) { Console.WriteLine($"Попытка чтения блока за пределами файла. Индекс блока {block_number}, всего блоков {length}"); return(false); } //memcpy(buf, MemBlock::getblock(fs, block_number), blocklen); V8MemBlock tmp_mem_block = new V8MemBlock((FileStream)Data1CD, block_number, false, true); byte[] tmp_buf = V8MemBlock.GetBlock((FileStream)Data1CD, block_number); Array.Copy(tmp_buf, buf, blocklen); return(true); }
public static byte[] GetBlock(FileStream fs, UInt32 _numblock) { if (_numblock >= NumBlocks) { return(null); } if (Memblocks[_numblock] != null) { V8MemBlock tmpV8Mem = new V8MemBlock(fs, _numblock, false, true); } return (Memblocks[_numblock].GetBlock(false)); }
public byte[] Getblock(UInt32 block_number) { if (Data1CD == null) { return(null); } if (block_number >= length) { Console.WriteLine($"Попытка чтения блока за пределами файла. Индекс блока {block_number}. Всего блоков {length}"); return(null); } V8MemBlock tmpV8MemBlock = new V8MemBlock((FileStream)Data1CD, block_number, false, true); return(V8MemBlock.GetBlock((FileStream)Data1CD, block_number)); }
public static byte[] GetBlockForWrite(FileStream fs, UInt32 _numblock, bool read) { if (_numblock > NumBlocks) { return(null); } if (_numblock == NumBlocks) { AddBlock(); } if (Memblocks[_numblock] != null) { V8MemBlock tmpV8Mem = new V8MemBlock(fs, _numblock, true, read); } else { Memblocks[_numblock].IsChanged = true; } return (Memblocks[_numblock].GetBlock(true)); }
/* * public bool get_readonly() * { * return readonly_; * } * * public void set_readonly(bool ro) * { * readonly_ = ro; * } */ public void Flush() { V8MemBlock.Flush(); }