Beispiel #1
0
        public static Dictionary <UInt64, ExtentRecord> er_dic = new Dictionary <UInt64, ExtentRecord>(); //NodeID, ExtentRecord

        public static void init_btln(FileStream stream, UInt64 block_num)
        {
            Table header = Table.get_table_header(stream, block_num);

            if (header.table_type == 0)
            {
                return;
            }

            TableType[] table_info = Table.save_record(stream, block_num, header);



            //Console.WriteLine("block_num: {0}, 0x{1}", block_num, block_num.ToString("X"));
            //Console.WriteLine("table type : {0}", header.table_type);

            for (int i = 0; i < header.record_num; i++)
            {
                char record_type = table_info[i].KeySection[14];
                //Console.WriteLine("\n\n{0} record\nrecord_type {1}", i, record_type);
                //Console.WriteLine("key len : {0}, data len {1}", table_info[i].KeyLength, table_info[i].DataLength);
                switch (record_type)
                {
                case '3':
                    FileFolderRecord f = new FileFolderRecord();
                    try
                    {
                        f = FileFolderRecord.get(table_info[i].KeySection, table_info[i].DataSection);


                        String fname = new string(f.FileName, 0, f.FileName.Length - 1);
                        // Console.WriteLine("Node ID : {0}, ParentID : {1}, Filename : {2}, Flag : {3} ", f.NodeID, f.ParentID, fname, f.Flag );
                        if (!ffr_dict.ContainsKey(f.NodeID))
                        {
                            ffr_dict.Add(f.NodeID, f);
                        }
                        else
                        {
                            ffr_dict[f.NodeID] = f;
                        }


                        if (!parent_node_dic.ContainsKey(f.ParentID))
                        {
                            List <UInt64> node_list = new List <UInt64>();
                            node_list.Add(f.NodeID);
                            parent_node_dic.Add(f.ParentID, node_list);
                        }
                        else
                        {
                            List <UInt64> child_list = parent_node_dic[f.ParentID];
                            if (!child_list.Exists(x => x == f.NodeID))
                            {
                                parent_node_dic[f.ParentID].Add(f.NodeID);
                            }
                        }
                    }
                    catch (ArgumentException)
                    {
                        Console.WriteLine("**************An element with Key = {0} already exists.", f.NodeID);
                    }

                    break;

                //case '6':
                //    ExtentStatus es = ExtentStatus.get(table_info[i].KeySection, table_info[i].DataSection);
                //    RECORD.es_list.Add(es);

                //    break;

                case '8':
                    ExtentRecord er = ExtentRecord.get(table_info[i].KeySection, table_info[i].DataSection);
                    if (!er_dic.ContainsKey(er.NodeID))
                    {
                        er_dic.Add(er.NodeID, er);
                    }
                    else
                    {
                        //  Console.WriteLine("*****Modify Extent Record , nodeID{0}", er.NodeID);
                        er_dic[er.NodeID] = er;
                    }

                    break;

                    //case '9':
                    //    KeyRecord kr = KeyRecord.get(table_info[i].KeySection, table_info[i].DataSection);
                    //    RECORD.kr_list.Add(kr);

                    //    break;
                }
            }


            return;
        }
Beispiel #2
0
        public UInt64 ContentLenGross;   // lengthMethod가 2일 경우에만



        public static FileFolderRecord get(string key, string data)
        {
            //Console.WriteLine("key : {0}, data : {1}", key, data);

            int start, len;
            FileFolderRecord ffr = new FileFolderRecord();

            start        = 0;
            len          = 8;
            ffr.ParentID = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("ParentID : {0}, {1}", ffr.ParentID, data.Substring(start, 2 * len));

            start     += 2 * len;
            len        = 8;
            ffr.NodeID = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("NodeID : {0}, {1}", ffr.NodeID, data.Substring(start, 2 * len));

            start         += 2 * len;
            len            = 8;
            ffr.CreateTime = Utility.hex_to_dateTime(data.Substring(start, 2 * len));
            //Console.WriteLine("CreateTime : {0}", ffr.CreateTime);

            start         += 2 * len;
            len            = 8;
            ffr.ModifyTime = Utility.hex_to_dateTime(data.Substring(start, 2 * len));
            //Console.WriteLine("ModifyTime : {0}", ffr.ModifyTime);

            start += 2 * len;
            len    = 8;
            ffr.InodeModifyTime = Utility.hex_to_dateTime(data.Substring(start, 2 * len));
            //Console.WriteLine("InodeModifyTime : {0}", ffr.InodeModifyTime);

            start           += 2 * len;
            len              = 8;
            ffr.AccessedTime = Utility.hex_to_dateTime(data.Substring(start, 2 * len));
            //Console.WriteLine("AccessedTime : {0}", ffr.AccessedTime);

            start            += 4 * len;
            len               = 8;
            ffr.FileFolderNum = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("FileFolderNum : {0}, {1}", ffr.FileFolderNum, data.Substring(start, 2 * len));

            start          += 2 * len;
            len             = 8;
            ffr.HardlinkNum = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("HardlinkNum : {0}, {1}", ffr.HardlinkNum, data.Substring(start, 2 * len));

            start      += 2 * len;
            len         = 4;
            ffr.OwnerID = (uint)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("OwnerID : {0}, {1}", ffr.OwnerID, data.Substring(start, 2 * len));

            start      += 2 * len;
            len         = 4;
            ffr.GroupID = (uint)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("GroupID : {0}, {1}", ffr.GroupID, data.Substring(start, 2 * len));

            /* - Flag -
             * folder : 0100000 + rwxrwxrwx
             * file : 1000000+ rwxrwxrwx
             */

            start   += 2 * len;
            len      = 8;
            ffr.Flag = Utility.littleEndian_to_bigEndian(data.Substring(start, 2 * len), 2);
            //Console.WriteLine("Flag : {0}, {1}", ffr.Flag, data.Substring(start, 2 * len));


            start           += 2 * len + 8;
            len              = 2;
            ffr.LengthMethod = (UInt16)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("LengthMethod : {0}, {1}", ffr.LengthMethod, data.Substring(start, 2 * len));

            start           += 2 * len;
            len              = 2;
            ffr.NameLengross = (UInt16)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("NameLengross : {0}, {1}", ffr.NameLengross, data.Substring(start, 2 * len));


            start       += 2 * len;
            len          = 2;
            ffr.DataType = (UInt16)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("DataType : {0}, {1}", ffr.DataType, data.Substring(start, 2 * len));

            start += 2 * len;
            len    = 2;
            ffr.FileNameLength = (UInt16)Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
            //Console.WriteLine("FileNameLength : {0}, {1}", ffr.FileNameLength, data.Substring(start, 2 * len));


            if (ffr.LengthMethod == 1)
            {
                start       += 2 * len;
                len          = ffr.FileNameLength;
                ffr.FileName = Utility.hex_to_charArray(data.Substring(start, 2 * len));
            }
            else
            {
                start       += 12;
                len          = ffr.FileNameLength;
                ffr.FileName = Utility.hex_to_charArray(data.Substring(start, 2 * len));

                start            += 2 * (len + 8 - len % 8);
                len               = 8;
                ffr.ContentLenLog = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
                //Console.WriteLine("ContentLenLog : {0}, {1}", ffr.ContentLenLog, data.Substring(start, 2 * len));

                start += 2 * len;
                len    = 8;
                ffr.ContentLenGross = Utility.little_hex_to_uint64(data.Substring(start, 2 * len), len);
                //Console.WriteLine("ContentLenGross : {0}, {1}", ffr.ContentLenGross, data.Substring(start, 2 * len));
            }

            return(ffr);
        }