public StBlockDscription GetBlockInfo(BLOCKTYPE type) { int posToSet = -1; switch (type) { case BLOCKTYPE.TEST: posToSet = 8; break; case BLOCKTYPE.CONFIG: posToSet = 16; break; case BLOCKTYPE.RESOURCE: posToSet = 24; break; } mFs.Position = posToSet; StBlockDscription retval = new StBlockDscription(); retval.Begin = ReadInt(); retval.Length = ReadInt(); return(retval); }
override public void Begin2() { mBlockDscp = GetBlockInfo(BLOCKTYPE.RESOURCE); mFs.Position = mBlockDscp.Begin; mResCount = ReadInt(); }
public void ExtractFile(string path, BLOCKTYPE type) { FileStream fso = new FileStream(path, FileMode.Create, FileAccess.Write); StBlockDscription dscp = GetBlockInfo(type); mFs.Position = dscp.Begin; int red = 0; int thisRed = 0; int buflen = 1024; int readingPlan = 0; int left = 0; readingPlan = buflen < dscp.Length ? buflen : dscp.Length; byte[] buf = new byte[1024]; bool doRead = true; while (doRead) { //counting thisRed = mFs.Read(buf, 0, readingPlan); fso.Write(buf, 0, thisRed); red += thisRed; //make plan left = dscp.Length - red; if (left >= buflen) { readingPlan = buflen; } else { readingPlan = left; } //if stop if (red == dscp.Length) { doRead = false; } } fso.Close(); }