//Copyright(C) 2009 にょろ. All rights reserved. #region usingディレクトリ using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; #endregion namespace FileUnite { class DivStream { #region 変数,プロパティ #region private 変数,プロパティ #endregion #region protected 変数,プロパティ #endregion #region public 変数,プロパティ #endregion #endregion #region コンストラクタ public DivStream() { } #endregion #region メンバ #region private メンバ #endregion #region public メンバ public FileStream[] DivFile(string s) { FileStream[] fss; FileStream input = new FileStream(s, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(input); long seed = br.ReadInt64(); int num = br.ReadInt32();//ファイル数 MRandom rnd = new MRandom(seed); fss = new FileStream[num]; long[] size = new long[num]; for (int i = 0; i < num; i++) { string name = br.ReadString(); size[i] = br.ReadInt64(); fss[i] = new FileStream(name+".bak", FileMode.OpenOrCreate, FileAccess.Write); Console.Write(name+".bak"); } //サイズ取得 for (int i = 0; i < num; i++) { for (long j = 0; j < size[i]; j++) { fss[i].WriteByte((byte)(br.ReadSByte() ^ rnd.BNext())); } } input.Close(); return fss; } public Dictionary DivisionStream(Stream input) { MemoryStream[] mss; BinaryReader br = new BinaryReader(input); long seed = br.ReadInt64(); int num = br.ReadInt32();//ファイル数 MRandom rnd = new MRandom(seed); mss = new MemoryStream[num]; long[] size = new long[num]; string[] Name = new string[num]; for (int i = 0; i < num; i++) { Name[i] = br.ReadString(); size[i] = br.ReadInt64(); mss[i] = new MemoryStream(); } //サイズ取得 for (int i = 0; i < num; i++) { for (long j = 0; j < size[i]; j++) { mss[i].WriteByte((byte)(br.ReadSByte() ^ rnd.BNext())); } } Dictionary dic = new Dictionary(); for (int i = 0; i < num; i++) { dic.Add(Name[i], mss[i]); } return dic; } #endregion #region protected メンバ #endregion #endregion #region オーバーラド メンバ #endregion } }