public AstrotiteV2Entry GetNextAstrotiteEntry() { if (dataStream != null) { while (this.Read (tmpBuffer) > 0) { } } dataStream = null; if (entryCursor >= entryList.Count) { if (!finished) { finished = true; byte[] finalbuffer = new byte[3]; int leidos = this.inputStream.Read (finalbuffer, 0, 3); this.Count (leidos); StringBuilder tmp = new StringBuilder (); for (int i = 0; i < "EOF".Length; i++) { tmp.Append (Convert.ToChar (finalbuffer[i])); } if (!"EOF".Equals (tmp.ToString ())) { throw new IOException ("Unexpected EOF:[" + tmp.ToString () +"]"); } } return null; } this.currentEntry = (AstrotiteV2Entry)entryList[entryCursor++]; return this.currentEntry; }
private void Init() { byte[] initbuffer = new byte[255]; int leidos = 0; leidos = this.inputStream.Read (initbuffer, 0, 22); if (leidos != 22) throw new IOException (); this.Count (leidos); // Comprobar magic StringBuilder tmp = new StringBuilder (); for (int i = 0; i < "AST2www.astroteam.tk".Length; i++) { tmp.Append (Convert.ToChar (initbuffer[i])); } if (!"AST2www.astroteam.tk".Equals (tmp.ToString ())) { throw new IOException ("Unexpected magic:" + tmp.ToString()); } nArchivos = (int)UtArrays.LeerInt16 (initbuffer, 20); for (int i = 0; i < nArchivos; i++) { leidos = inputStream.Read (initbuffer, 0, 9); this.Count (leidos); int length = UtArrays.LeerInt32 (initbuffer, 0); // Astrotite genera siempre un bloque por archivo. Si el archivo está vacio, tambien // Pero graba un 0 en el numero de bloques. int blocks = UtArrays.LeerInt32 (initbuffer, 4); if (blocks == 0) { blocks = 1; } int namelength = initbuffer[8]; leidos = inputStream.Read (initbuffer, 0, namelength); this.Count (leidos); string name = UtArrays.LeerTexto (initbuffer, 0, namelength); name = name.Replace ('\\', Path.DirectorySeparatorChar); AstrotiteV2Entry e = new AstrotiteV2Entry (name, length, blocks); entryList.Add (e); } }