Ejemplo n.º 1
0
        List <int> extracted_list;         //a list containing the datum indexes already extracted


        public MetaExtractor(int datum, string type, Dictionary <int, string> SID_list, StreamReader sr)
        {
            InitializeComponent();

            //initialise all stuff
            map_stream      = sr;
            this.SID_list   = SID_list;
            extraction_list = new List <tagRef>();
            extracted_list  = new List <int>();

            //lets add the currently passed datum to the list
            tagRef temp = new tagRef();

            temp.datum_index = datum;
            temp.type        = type;

            extraction_list.Add(temp);
        }
Ejemplo n.º 2
0
        private void Extract_Click(object sender, EventArgs e)
        {
            string log = "\nEXTRACTION LOG : ";//or log

            string rel_path = SID_list[extraction_list[0].datum_index] + "." + extraction_list[0].type;

            XmlTextWriter xw = new XmlTextWriter(textBox1.Text + "\\" + DATA_READ.Read_File_from_file_location(rel_path) + ".xml", Encoding.UTF8);

            xw.Formatting = Formatting.Indented;
            xw.WriteStartElement("config");

            if (textBox1.Text.Length > 0)
            {
                for (int i = 0; i < extraction_list.Count; i++)
                {
                    tagRef temp_tagref = extraction_list[i];

                    int    datum = temp_tagref.datum_index;
                    string type  = temp_tagref.type;

                    if (datum != -1)
                    {
                        if (!extracted_list.Contains(datum))
                        {
                            if (File.Exists(Application.StartupPath + "\\plugins\\" + type + ".xml"))
                            {
                                if (SID_list.ContainsKey(datum))
                                {
                                    meta obj = new meta(datum, SID_list[datum], map_stream);
                                    obj.Rebase_meta(0x0);

                                    if (checkBox1.Checked)
                                    {
                                        obj.Null_StringID();
                                    }

                                    if (radioButton1.Checked == true)
                                    {
                                        //add recursivity
                                        extraction_list.AddRange(obj.Get_all_tag_refs());
                                    }

                                    byte[] data = obj.Generate_meta_file();

                                    string path      = textBox1.Text + "\\" + obj.Get_Path() + "." + obj.Get_Type();
                                    string directory = DATA_READ.ReadDirectory_from_file_location(path);

                                    //lets create our directory
                                    System.IO.Directory.CreateDirectory(directory);
                                    //create our file
                                    StreamWriter sw = new StreamWriter(path);
                                    sw.BaseStream.Write(data, 0, obj.Get_Total_size());
                                    sw.Dispose();

                                    //write to configuration xml
                                    xw.WriteStartElement("tag");
                                    xw.WriteStartElement("name");
                                    xw.WriteString(obj.Get_Path() + "." + type); //writing in the inner most level ie,name
                                    xw.WriteEndElement();                        //name level
                                    xw.WriteStartElement("datum");
                                    xw.WriteString(datum.ToString("X"));         //writing in the inner most level ie here,datum
                                    xw.WriteEndElement();                        //datum level
                                    xw.WriteEndElement();                        //tag level

                                    //at least mention this in the logs
                                    log += "\nExtracted meta " + datum.ToString("X") + " to " + path;

                                    //add it to the extracted list
                                    extracted_list.Add(datum);
                                }
                                else
                                {
                                    log += "\nCouldnot find stringID to datum_index " + datum.ToString("X");
                                }
                            }
                            else
                            {
                                log += "\nPlugin " + type + ".xml doesnt exist";
                                extracted_list.Add(datum);
                            }
                        }
                    }
                }
                //close the config field and close the xml handle
                xw.WriteEndElement();
                xw.Dispose();

                //Log box
                LogBox lb = new LogBox(log);
                lb.Show();

                //wprk is now done so lets close this stupid box
                this.Close();
            }
            else
            {
                MessageBox.Show("At least Select the Directory", "Error");
            }
        }