//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadFullValue() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testReadFullValue() { Stream @is = this.GetType().ClassLoader.getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt"); sbyte[] data = new sbyte[@is.available()]; DataInputStream dataInputStream = new DataInputStream(@is); dataInputStream.readFully(data); dataInputStream.close(); MockValueFields valueFields = new MockValueFields(); string filename = "file.txt"; valueFields.TextValue = filename; valueFields.ByteArrayValue = data; string mimeType = "text/plain"; string encoding = "UTF-16"; valueFields.TextValue2 = mimeType + SEPARATOR + encoding; FileValue fileValue = serializer.readValue(valueFields, true); assertThat(fileValue.Filename, @is(filename)); assertThat(fileValue.MimeType, @is(mimeType)); assertThat(fileValue.Encoding, @is("UTF-16")); assertThat(fileValue.EncodingAsCharset, @is(Charset.forName("UTF-16"))); checkStreamFromValue(fileValue, "text"); }
private static bool loadSection( DataInputStream @in, List <Object3D> objectList, List <Object3D> rootObjectList) { if (@in.read() == -1) { return(false); } int num = Loader.readIntLE(ref @in); Loader.readIntLE(ref @in); int length = num - 13; sbyte[] numArray = new sbyte[length]; @in.readFully(numArray, length); @in.skip(4L); DataInputStream in1 = new DataInputStream((InputStream) new ByteArrayInputStream(numArray, length)); do { ; }while (Loader.loadObject(ref in1, ref objectList, ref rootObjectList)); return(true); }
public override void readPacketData(DataInputStream datainputstream) { xPosition = datainputstream.readInt(); zPosition = datainputstream.readInt(); size = datainputstream.readShort() & 0xffff; coordinateArray = new short[size]; typeArray = new byte[size]; metadataArray = new byte[size]; for (int i = 0; i < size; i++) { coordinateArray[i] = datainputstream.readShort(); } datainputstream.readFully(typeArray); datainputstream.readFully(metadataArray); }
private static void loadObject3D( Object3D @object, ref DataInputStream @in, ref List <Object3D> objects, ref List <Object3D> rootObjects) { int userID = Loader.readIntLE(ref @in); @object.setUserID(userID); int num1 = Loader.readIntLE(ref @in); for (int index = 0; index < num1; ++index) { AnimationTrack reference = (AnimationTrack)Loader.getReference(ref @in, ref objects, ref rootObjects); @object.addAnimationTrack(reference); } int num2 = Loader.readIntLE(ref @in); for (int index = 0; index < num2; ++index) { Loader.readIntLE(ref @in); sbyte[] b = new sbyte[Loader.readIntLE(ref @in)]; @in.readFully(b); } }
public override void readPacketData(DataInputStream datainputstream) { xPosition = datainputstream.readInt(); yPosition = datainputstream.readShort(); zPosition = datainputstream.readInt(); xSize = datainputstream.read() + 1; ySize = datainputstream.read() + 1; zSize = datainputstream.read() + 1; chunkSize = datainputstream.readInt(); var abyte0 = new byte[chunkSize]; datainputstream.readFully(abyte0); chunk = new byte[(xSize * ySize * zSize * 5) / 2]; var inflater = new Inflater(); inflater.setInput(abyte0); try { inflater.inflate(chunk); } catch (DataFormatException dataformatexception) { throw new IOException("Bad compressed data format"); } finally { inflater.end(); } }
private static object loadImage2D( ref DataInputStream @in, ref List <Object3D> objectList, ref List <Object3D> rootObjectList) { Image2D image2D = new Image2D(); Loader.loadObject3D((Object3D)image2D, ref @in, ref objectList, ref rootObjectList); int format = @in.readUnsignedByte(); bool flag = @in.readBoolean(); int width = Loader.readIntLE(ref @in); int height = Loader.readIntLE(ref @in); image2D.set(format, width, height); if (!flag) { sbyte[] numArray1 = (sbyte[])null; int length = Loader.readIntLE(ref @in); if (length > 0) { numArray1 = new sbyte[length]; @in.readFully(numArray1); } int len = Loader.readIntLE(ref @in); sbyte[] numArray2 = new sbyte[len]; @in.readFully(numArray2, len); if (numArray1 != null) { image2D.commit(numArray1, numArray2); } else { byte[] pixels = new byte[numArray2.Length]; Buffer.BlockCopy((Array)numArray2, 0, (Array)pixels, 0, numArray2.Length); image2D.commit(pixels); } } return((object)image2D); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public static CaptureRAM read(java.io.InputStream in) throws java.io.IOException public static CaptureRAM read(System.IO.Stream @in) { CaptureRAM ramFragment = new CaptureRAM(); DataInputStream data = new DataInputStream(@in); int sizeRemaining = data.readInt(); if (sizeRemaining >= 8) { ramFragment.address = data.readInt(); sizeRemaining -= 4; ramFragment.Length = data.readInt(); sizeRemaining -= 4; if (sizeRemaining > data.available()) { VideoEngine.log_Renamed.warn("CaptureRAM read want=" + sizeRemaining + " available=" + data.available()); } if (sizeRemaining >= ramFragment.Length) { ByteBuffer bb = ByteBuffer.allocate(ramFragment.Length); sbyte[] b = bb.array(); if (b == null) { throw new IOException("Buffer is not backed by an array"); } data.readFully(b, 0, ramFragment.Length); ramFragment.buffer = bb; sizeRemaining -= ramFragment.Length; data.skipBytes(sizeRemaining); VideoEngine.log_Renamed.info(string.Format("Loaded memory {0:x8} - {1:x8} (len {2:x8})", ramFragment.address, ramFragment.address + ramFragment.Length, ramFragment.Length)); } else { throw new IOException("Not enough bytes remaining in stream"); } } else { throw new IOException("Not enough bytes remaining in stream"); } return(ramFragment); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public java.security.PrivateKey loadPrivateKey(java.io.File privateKeyFile) throws java.io.IOException, java.security.NoSuchAlgorithmException, java.security.spec.InvalidKeySpecException public virtual PrivateKey LoadPrivateKey(File privateKeyFile) { using (PemReader r = new PemReader(new StreamReader(privateKeyFile))) { PemObject pemObject = r.readPemObject(); if (pemObject != null) { sbyte[] encodedKey = pemObject.Content; KeySpec keySpec = new PKCS8EncodedKeySpec(encodedKey); try { return(KeyFactory.getInstance("RSA").generatePrivate(keySpec)); } catch (InvalidKeySpecException) { try { return(KeyFactory.getInstance("DSA").generatePrivate(keySpec)); } catch (InvalidKeySpecException) { try { return(KeyFactory.getInstance("EC").generatePrivate(keySpec)); } catch (InvalidKeySpecException e) { throw new InvalidKeySpecException("Neither RSA, DSA nor EC worked", e); } } } } } // Ok, failed to read as PEM file, try and read it as a raw binary private key using (DataInputStream @in = new DataInputStream(new FileStream(privateKeyFile, FileMode.Open, FileAccess.Read))) { sbyte[] keyBytes = new sbyte[( int )privateKeyFile.length()]; @in.readFully(keyBytes); KeySpec keySpec = new PKCS8EncodedKeySpec(keyBytes); return(KeyFactory.getInstance(DEFAULT_ENCRYPTION).generatePrivate(keySpec)); } }
public static House fromXMLStream(DataInputStream @is, string houseName, int houseId) { int length1 = @is.available(); sbyte[] b = new sbyte[length1]; char[] chArray = new char[length1]; @is.readFully(b); for (int index = 0; index < length1; ++index) { chArray[index] = (char)b[index]; } string str1 = new string(chArray); string str2 = "<room "; string str3 = "<door "; string str4 = "<window "; string str5 = "<object "; House house = new House(houseName, houseId); int startIndex = 0; do { int length2 = str1.IndexOf('\n', startIndex); string str6 = str1.Substring(startIndex, length2); if (str6.IndexOf(str2) != -1) { house.addRoom(Room.fromXMLString(str6)); } else if (str6.IndexOf(str3) != -1) { house.addDoor(Door.fromXMLString(str6)); } else if (str6.IndexOf(str4) != -1) { house.addWindow(Window.fromXMLString(str6)); } else if (str6.IndexOf(str5) != -1) { house.addHouseObject(HouseObject.fromXMLString(str6)); } startIndex = length2 + 1; }while (startIndex < str1.Length); return(house); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testReadFilenameAndByteArrayValue() throws java.io.IOException //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testReadFilenameAndByteArrayValue() { Stream @is = this.GetType().ClassLoader.getResourceAsStream("org/camunda/bpm/engine/test/standalone/variables/simpleFile.txt"); sbyte[] data = new sbyte[@is.available()]; DataInputStream dataInputStream = new DataInputStream(@is); dataInputStream.readFully(data); dataInputStream.close(); MockValueFields valueFields = new MockValueFields(); string filename = "file.txt"; valueFields.TextValue = filename; valueFields.ByteArrayValue = data; FileValue fileValue = serializer.readValue(valueFields, true); assertThat(fileValue.Filename, @is(filename)); assertThat(fileValue.MimeType, @is(nullValue())); checkStreamFromValue(fileValue, "text"); }
public static Object3D[] load(InputStream stream) { DataInputStream @in = new DataInputStream(stream); sbyte[] b = new sbyte[12]; @in.readFully(b, 12); for (int index = 0; index < 12; ++index) { int num1 = (int)b[index] & (int)byte.MaxValue; int num2 = (int)Loader.M3G_FILE_IDENTIFIER[index] & (int)byte.MaxValue; } List <Object3D> rootObjectList = new List <Object3D>(30); List <Object3D> objectList = new List <Object3D>(30); objectList.Add((Object3D)null); int num = 0; while (Loader.loadSection(ref @in, ref objectList, ref rootObjectList)) { ++num; } @in.close(); return(rootObjectList.ToArray()); }
private static bool loadObject( ref DataInputStream @in, ref List <Object3D> objectList, ref List <Object3D> rootObjectList) { int num = @in.read(); if (num == -1) { return(false); } int length = Loader.readIntLE(ref @in); sbyte[] numArray = new sbyte[length]; @in.readFully(numArray, length); DataInputStream in1 = new DataInputStream((InputStream) new ByteArrayInputStream(numArray, length)); object obj = (object)null; switch (num) { case 0: in1.readUnsignedByte(); in1.readUnsignedByte(); in1.readBoolean(); Loader.readIntLE(ref in1); Loader.readIntLE(ref in1); break; case 1: obj = Loader.loadAnimationController(ref in1, ref objectList, ref rootObjectList); break; case 2: obj = Loader.loadAnimationTrack(ref in1, ref objectList, ref rootObjectList); break; case 3: obj = Loader.loadAppearance(ref in1, ref objectList, ref rootObjectList); break; case 5: obj = Loader.loadCamera(ref in1, ref objectList, ref rootObjectList); break; case 6: obj = Loader.loadCompositingMode(ref in1, ref objectList, ref rootObjectList); break; case 8: obj = Loader.loadPolygonMode(ref in1, ref objectList, ref rootObjectList); break; case 9: obj = (object)new Group(); Loader.loadGroup((Group)obj, ref in1, ref objectList, ref rootObjectList); break; case 10: obj = Loader.loadImage2D(ref in1, ref objectList, ref rootObjectList); break; case 11: obj = Loader.loadTriangleStripArray(ref in1, ref objectList, ref rootObjectList); break; case 14: obj = (object)new Mesh(); Loader.loadMesh((Mesh)obj, ref in1, ref objectList, ref rootObjectList); break; case 16: obj = Loader.loadSkinnedMesh(ref in1, ref objectList, ref rootObjectList); break; case 17: obj = Loader.loadTexture2D(ref in1, ref objectList, ref rootObjectList); break; case 19: obj = Loader.loadKeyframeSequence(ref in1, ref objectList, ref rootObjectList); break; case 20: obj = Loader.loadVertexArray(ref in1, ref objectList, ref rootObjectList); break; case 21: obj = Loader.loadVertexBuffer(ref in1, ref objectList, ref rootObjectList); break; case 22: obj = Loader.loadWorld(ref in1, ref objectList, ref rootObjectList); break; } objectList.Add((Object3D)obj); if (obj != null) { rootObjectList.Add((Object3D)obj); } return(true); }
public static void Main(string[] args) { File fileToc1 = new File("tmp/umdbuffer1.toc"); File fileIso1 = new File("tmp/umdbuffer1.iso"); File fileToc2 = new File("tmp/umdbuffer2.toc"); File fileIso2 = new File("tmp/umdbuffer2.iso"); File fileToc = new File("tmp/umdbuffer.toc"); File fileIso = new File("tmp/umdbuffer.iso"); try { System.IO.FileStream fosToc = new System.IO.FileStream(fileToc, System.IO.FileMode.Create, System.IO.FileAccess.Write); System.IO.FileStream fosIso = new System.IO.FileStream(fileIso, System.IO.FileMode.Create, System.IO.FileAccess.Write); System.IO.FileStream fisToc1 = new System.IO.FileStream(fileToc1, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileStream fisIso1 = new System.IO.FileStream(fileIso1, System.IO.FileMode.Open, System.IO.FileAccess.Read); System.IO.FileStream fisToc2 = new System.IO.FileStream(fileToc2, System.IO.FileMode.Open, System.IO.FileAccess.Read); DataOutput toc = new DataOutputStream(fosToc); DataOutput iso = new DataOutputStream(fosIso); DataInput toc1 = new DataInputStream(fisToc1); DataInput iso1 = new DataInputStream(fisIso1); DataInput toc2 = new DataInputStream(fisToc2); RandomAccessFile iso2 = new RandomAccessFile(fileIso2, "r"); int numSectors = toc1.readInt(); int numSectorsMerge = toc2.readInt(); toc.writeInt(System.Math.Max(numSectors, numSectorsMerge)); Dictionary <int, int> tocHashMap = new Dictionary <int, int>(); for (int i = 4; i < fileToc1.Length(); i += 8) { int sectorNumber = toc1.readInt(); int bufferedSectorNumber = toc1.readInt(); tocHashMap[sectorNumber] = bufferedSectorNumber; toc.writeInt(sectorNumber); toc.writeInt(bufferedSectorNumber); } sbyte[] buffer = new sbyte[sectorLength]; for (int i = 0; i < fileIso1.Length(); i += buffer.Length) { iso1.readFully(buffer); iso.write(buffer); } int nextFreeBufferedSectorNumber = (int)(fileIso1.Length() / sectorLength); for (int i = 4; i < fileToc2.Length(); i += 8) { int sectorNumber = toc2.readInt(); int bufferedSectorNumber = toc2.readInt(); if (!tocHashMap.ContainsKey(sectorNumber)) { iso2.seek(bufferedSectorNumber * (long)sectorLength); iso2.readFully(buffer); iso.write(buffer); toc.writeInt(sectorNumber); toc.writeInt(nextFreeBufferedSectorNumber); tocHashMap[sectorNumber] = nextFreeBufferedSectorNumber; nextFreeBufferedSectorNumber++; } } fosToc.Close(); fosIso.Close(); fisToc1.Close(); fisIso1.Close(); fisToc2.Close(); iso2.close(); } catch (FileNotFoundException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } catch (IOException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } }
public static int loadTextHeader(sbyte[] textHeader) { DataInputStream dataInputStream = new DataInputStream((InputStream) new ByteArrayInputStream(textHeader, 1024)); int num1 = (int)dataInputStream.readByte(); SDKTextUtils.s_chunkConfig = dataInputStream.readByte(); SDKTextUtils.s_textEncodings = (uint)((int)dataInputStream.readByte() << 16 | (int)dataInputStream.readByte() << 8) | (uint)dataInputStream.readByte(); int num2 = (int)dataInputStream.readShort(); SDKTextUtils.s_numLangs = dataInputStream.readByte(); sbyte num3 = dataInputStream.readByte(); sbyte num4 = dataInputStream.readByte(); SDKTextUtils.s_numStorageChunks = (sbyte)((int)num3 + 1); SDKTextUtils.s_numActualChunks = (sbyte)((int)num4 + 1); SDKTextUtils.s_languageArray = new SDKStringLanguage[(int)SDKTextUtils.s_numLangs]; SDKTextUtils.s_groupArray = new SDKStringGroup[(int)SDKTextUtils.s_numActualChunks]; SDKTextUtils.s_actualChunkArray = new SDKStringActualChunk[(int)SDKTextUtils.s_numActualChunks]; for (int index = 0; index < (int)SDKTextUtils.s_numActualChunks; ++index) { SDKTextUtils.s_groupArray[index] = new SDKStringGroup(); SDKTextUtils.s_actualChunkArray[index] = new SDKStringActualChunk(); } SDKTextUtils.s_storageChunkArray = new SDKStringStorageChunk[(int)SDKTextUtils.s_numStorageChunks]; for (int index = 0; index < (int)SDKTextUtils.s_numStorageChunks; ++index) { SDKTextUtils.s_storageChunkArray[index] = new SDKStringStorageChunk(); } SDKStringActualChunk actualChunk1 = SDKTextUtils.s_actualChunkArray[0]; SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[0]; actualChunk1.numStrings = num2; actualChunk1.flags = sbyte.MinValue; actualChunk1.group = (sbyte)0; for (int index = 0; index != (int)SDKTextUtils.s_numLangs; ++index) { SDKTextUtils.s_languageArray[index] = new SDKStringLanguage(); SDKTextUtils.s_languageArray[index].chunkSizeArray = new ushort[(int)SDKTextUtils.s_numActualChunks]; } int num5 = num2 + 1; for (int index1 = 0; index1 != (int)SDKTextUtils.s_numLangs; ++index1) { SDKStringLanguage language = SDKTextUtils.s_languageArray[index1]; language.isoCodeArray = new sbyte[5]; for (int index2 = 0; index2 != 5; ++index2) { language.isoCodeArray[index2] = dataInputStream.readByte(); } language.encoding = (int)dataInputStream.readByte(); language.fontDifferentiator = dataInputStream.readByte(); if (num2 > 0) { if (storageChunk.stringOffsetArray == null) { storageChunk.stringOffsetArray = new ushort[(int)SDKTextUtils.s_numLangs * num5]; } for (int index2 = 0; index2 != num5; ++index2) { storageChunk.stringOffsetArray[index1 * num5 + index2] = (ushort)dataInputStream.readShort(); } } } if (num2 > 0) { int stringOffset = (int)storageChunk.stringOffsetArray[(int)SDKTextUtils.s_numLangs * num5 - 1]; storageChunk.stringData = new sbyte[stringOffset]; dataInputStream.readFully(storageChunk.stringData, stringOffset); } for (int index1 = 1; index1 != (int)SDKTextUtils.s_numActualChunks; ++index1) { SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index1]; int num6 = (int)dataInputStream.readByte(); actualChunk2.flags = (sbyte)(num6 & 192); actualChunk2.group = (sbyte)(num6 & 63); actualChunk2.numStrings = (int)dataInputStream.readShort(); SDKStringGroup group = SDKTextUtils.s_groupArray[(int)actualChunk2.group]; ushort num7 = (ushort)(actualChunk2.numStrings + 1); if ((int)num7 > (int)group.maxNumOffsets) { group.maxNumOffsets = num7; } for (int index2 = 0; index2 != (int)SDKTextUtils.s_numLangs; ++index2) { int num8 = dataInputStream.readUnsignedShort(); SDKTextUtils.s_languageArray[index2].chunkSizeArray[index1] = (ushort)num8; if (num8 > (int)group.maxSize) { group.maxSize = (ushort)num8; } } } SDKTextUtils.s_currentLanguage = SDKTextUtils.s_languageArray[(int)SDKTextUtils.s_langIndex]; if (SDKTextUtils.s_currentLanguage.encoding > 1) { SDKTextUtils.loadCharMap((sbyte)SDKTextUtils.s_currentLanguage.encoding); } SDKTextUtils.s_hdrLoaded = true; dataInputStream.close(); return((int)SDKTextUtils.s_numLangs); }
public static void loadStringsChunk(int chunkID) { if (SDKTextUtils.isLoadedStringsChunk(chunkID) && !SDKTextUtils.s_forceChunkLoad) { return; } SDKStringActualChunk actualChunk1 = SDKTextUtils.s_actualChunkArray[chunkID]; int index1 = ((int)actualChunk1.flags & 64) == 0 ? (int)SDKTextUtils.s_langIndex : 0; string str1 = ""; InputStream resourceAsStream; switch (SDKTextUtils.s_chunkConfig) { case 0: string str2 = str1 + "t_"; string sourcestring1 = new string(new char[6]); int index2 = -1; sbyte num1; do { ++index2; num1 = index2 != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[index2] : (sbyte)32; sourcestring1 = StringFunctions.ChangeCharacter(sourcestring1, index2, (char)num1); }while (num1 != (sbyte)32); string str3 = sourcestring1.Substring(0, index2); resourceAsStream = JavaLib.getResourceAsStream(str2 + str3, false); ushort[] chunkSizeArray = SDKTextUtils.s_languageArray[index1].chunkSizeArray; for (int index3 = 1; index3 != chunkID; ++index3) { SDKStringActualChunk actualChunk2 = SDKTextUtils.s_actualChunkArray[index3]; if (((int)actualChunk2.flags & 64) == 0 || index1 == 0) { resourceAsStream.skip((long)((actualChunk2.numStrings + 1 << 1) + (int)chunkSizeArray[index3])); } } break; case 1: string str4 = str1 + "t_"; string sourcestring2 = new string(new char[6]); int charindex = -1; sbyte num2; do { ++charindex; num2 = charindex != 5 ? SDKTextUtils.s_languageArray[index1].isoCodeArray[charindex] : (sbyte)32; sourcestring2 = StringFunctions.ChangeCharacter(sourcestring2, charindex, (char)num2); }while (num2 != (sbyte)32); string str5 = StringFunctions.ChangeCharacter(sourcestring2, charindex, char.MinValue); resourceAsStream = JavaLib.getResourceAsStream(str4 + str5 + (object)chunkID, false); break; default: return; } DataInputStream dataInputStream = new DataInputStream(resourceAsStream); int num3 = actualChunk1.numStrings + 1; int group1 = (int)actualChunk1.group; SDKStringGroup group2 = SDKTextUtils.s_groupArray[group1]; SDKStringStorageChunk storageChunk = SDKTextUtils.s_storageChunkArray[group1]; if (storageChunk.stringOffsetArray == null) { storageChunk.stringOffsetArray = new ushort[(int)group2.maxNumOffsets]; } for (int index3 = 0; index3 != num3; ++index3) { storageChunk.stringOffsetArray[index3] = (ushort)dataInputStream.readShort(); } if (storageChunk.stringData == null) { storageChunk.stringData = new sbyte[(int)group2.maxSize]; } dataInputStream.readFully(storageChunk.stringData, (int)SDKTextUtils.s_languageArray[index1].chunkSizeArray[chunkID]); group2.map = (sbyte)chunkID; dataInputStream.close(); }