Exemple #1
0
		public bool Save(string FileName)
		{
			if (true)//FHasBeenOpened)
			{
				try
				{
					// read the .class file systematically
					FileStream fs = new FileStream(FileName, FileMode.Create, FileAccess.Write);
					BinaryWriter FWriter = new BinaryWriter(fs);
					// write header
					Common.WriteDWord(FWriter, FMagic);

					Common.WriteWord(FWriter, FMinorVersion);
					Common.WriteWord(FWriter, FMajorVersion);
					// write constant pool
					// this also writes the "FConstantPoolCount"
					FConstantPool.Write(FWriter);
					// more constants
					Common.WriteWord(FWriter, (int)FAccessFlags);
					Common.WriteWord(FWriter, FThisClass + 1);
					Common.WriteWord(FWriter, FSuperClass + 1);

					FInterfaces.Write(FWriter);
					FFields.Write(FWriter);
					FMethods.Write(FWriter);
					FAttributes.Write(FWriter);

					FWriter.Close();
					return true;
				}
				catch (Exception e)
				{
					// catch any unhandled exceptions here
					// and exit gracefully.
					// garbage collection does the rest ;D
					return false;
				}
			}
		}