예제 #1
0
        void init(string filename)
        {
            filename = IO.InnerFilePath(filename);
            string filenameOnly = Path.GetFileName(filename);
            string filenameAlt  = Path.Combine(Path.GetDirectoryName(filename), "_" + filenameOnly);

            try
            {
                IO.FileReplaceRename(filenameAlt, filename);
            }
            catch
            {
            }

            list = new Dictionary <string, HamCoreEntry>();

            try
            {
                hamcore_io = IO.FileOpen(filename);
            }
            catch
            {
                return;
            }

            try
            {
                byte[] header  = hamcore_io.Read(HamcoreHeaderSize);
                byte[] header2 = Str.AsciiEncoding.GetBytes(HamcoreHeaderData);
                if (header == null || Util.CompareByte(header, header2) == false)
                {
                    throw new SystemException();
                }

                uint   num = 0;
                byte[] buf = hamcore_io.Read(Util.SizeOfInt32);
                num = Util.ByteToUInt(buf);
                uint i;
                for (i = 0; i < num; i++)
                {
                    uint str_size;

                    buf      = hamcore_io.Read(Util.SizeOfInt32);
                    str_size = Util.ByteToUInt(buf);
                    if (str_size >= 1)
                    {
                        str_size--;
                    }

                    byte[] str_data = hamcore_io.Read((int)str_size);
                    string tmp      = Str.ShiftJisEncoding.GetString(str_data);

                    HamCoreEntry c = new HamCoreEntry();
                    c.FileName = tmp;

                    buf    = hamcore_io.Read(Util.SizeOfInt32);
                    c.Size = Util.ByteToUInt(buf);

                    buf = hamcore_io.Read(Util.SizeOfInt32);
                    c.SizeCompressed = Util.ByteToUInt(buf);

                    buf      = hamcore_io.Read(Util.SizeOfInt32);
                    c.Offset = Util.ByteToUInt(buf);

                    list.Add(c.FileName.ToUpper(), c);
                }
            }
            catch
            {
                hamcore_io.Close();
            }
        }