/// <summary> /// Write page from buffer: n - page number; nbuf - buffer number /// !!! NOT APPLICABLE TO IMO /// </summary> /// <param name="n"></param> /// <param name="nbuf"></param> private void page_write(long n, int nbuf) { for (int i = 0; i < pd.Length; i++) { if ((n >= pd[i].start_page) & (n <= pd[i].end_page)) { long addr = (long)((n - pd[i].start_page) * (DESCRIPTOR.PageSize + DEFS.SYSTEM_USED_PAGE_SPACE)); uint crc32 = VSCRC32.CountCrc(segment_table[0].cache[nbuf].buf); pd[i].fs.Write(addr + 4, crc32); // CRC32 if (DESCRIPTOR.CATALOG.ENCRYPT) { pd[i].fs.Write(addr, DEFS.DATA_ENCRYPTED); // Encryption VSCrypto.Encrypt(ref segment_table[0].cache[nbuf].buf, ref e_buf, e_key, 0); pd[i].fs.Write(addr + DEFS.SYSTEM_USED_PAGE_SPACE, ref e_buf); } else { pd[i].fs.Write(addr, DEFS.DATA_NOT_ENCRYPTED); // Encryption pd[i].fs.Write(addr + DEFS.SYSTEM_USED_PAGE_SPACE, ref segment_table[0].cache[nbuf].buf); } PGWrite++; } } }
//////////////////////////////////////////////////////////////////// //////////////// WRITE METHODS ///////////////////////////////////// //////////////////////////////////////////////////////////////////// /// <summary> /// Write bytes /// </summary> /// <param name="offset"></param> /// <param name="data"></param> public void Write(long offset, ref byte[] data) { if (offset >= 0) { fs.Seek(offset, SeekOrigin.Begin); } if (_encrypt) { byte[] e_data = new byte[data.Length]; VSCrypto.Encrypt(ref data, ref e_data, xkey_b, fs.Position); fs.Write(e_data, 0, data.Length); } else { fs.Write(data, 0, data.Length); } }