internal Extract( string file ) { var offset = 0; using( var fs = new FileStream( file, FileMode.Open, FileAccess.Read ) ) { var fileData = new byte[fs.Length]; fs.Read( fileData, 0, (int)fs.Length ); var header = new NpkHeader(); header.flag = Encoding.UTF8.GetString( fileData, offset, 16 ); offset += 16; header.count = BitConverter.ToUInt32( fileData, offset ); offset += 4; this.npkIndexList = new List<NpkIndex>(); for( var i = 0; i < header.count; ++i ) { var index = new NpkIndex(); index.startOffset = (int)( BitConverter.ToUInt32( fileData, offset ) ); offset += 4; index.size = BitConverter.ToUInt32( fileData, offset ); offset += 4; var indexName = new char[256]; for( var j = 0; j < 256; j++ ) { indexName[j] = (char)( fileData[offset++] ^ _decordFlag[j] ); } index.name = new string( indexName ); index.name = index.name.Replace( "\0", "" ); index.shortName = Regex.Replace( index.name, @"^.*/", "" ); index.fileData = fileData; this.npkIndexList.Add( index ); } } }
internal Extract(string file) { var offset = 0; using (var fs = new FileStream(file, FileMode.Open, FileAccess.Read)) { var fileData = new byte[fs.Length]; fs.Read(fileData, 0, (int)fs.Length); var header = new NpkHeader(); header.flag = Encoding.UTF8.GetString(fileData, offset, 16); offset += 16; header.count = BitConverter.ToUInt32(fileData, offset); offset += 4; this.npkIndexList = new List <NpkIndex>(); for (var i = 0; i < header.count; ++i) { var index = new NpkIndex(); index.startOffset = (int)(BitConverter.ToUInt32(fileData, offset)); offset += 4; index.size = BitConverter.ToUInt32(fileData, offset); offset += 4; var indexName = new char[256]; for (var j = 0; j < 256; j++) { indexName[j] = (char)(fileData[offset++] ^ DECORD_FLAG[j]); } index.name = new string( indexName ); index.name = index.name.Replace("\0", ""); index.shortName = Regex.Replace(index.name, @"^.*/", ""); index.fileData = fileData; this.npkIndexList.Add(index); } } }