Beispiel #1
0
        //extract a whole file into memory
        public byte[] ExtractRes2Mem(int index)
        {
            byte[]         retval = null;
            StResourceDscp dscp   = GetResourceDscp(index);

            mFs.Position = getResourceDataBegpos(index);
            retval       = mBr.ReadBytes((int)dscp.len);
            return(retval);
        }
Beispiel #2
0
        public StResourceDscp GetResourceDscp(int index)
        {
            StResourceDscp retval = new StResourceDscp();

            mFs.Position = GetIndexBeg(index);

            retval.beg  = ReadLong();
            retval.len  = ReadLong();
            retval.type = ReadLong();

            return(retval);
        }
Beispiel #3
0
        //extract file to hard disk (currently not in use)
        public void ExtractRes(String destFolder, int rangeStart, int count)
        {
            String path = destFolder;

            if (rangeStart >= 0 && count > 0 && count <= mResCount)
            {
                int rangeEnd = rangeStart + count;

                StResourceDscp resDscp = null;

                byte[] buffer = new byte[BUFFERLEN];

                for (int i = rangeStart; i < rangeEnd; i++)
                {
                    resDscp = GetResourceDscp(i);

                    FileStream fso =
                        new FileStream(path + i.ToString() + GetExtendName(resDscp),
                                       FileMode.Create, FileAccess.Write);

                    mFs.Position = getResourceDataBegpos(i);

                    if (resDscp.len < BUFFERLEN)
                    {
                        mBr.Read(buffer, (int)resDscp.beg, (int)resDscp.len);
                        fso.Write(buffer, 0, (int)resDscp.len);
                    }
                    else
                    {
                        int time    = (int)(resDscp.len / BUFFERLEN + 1);
                        int lastLen = (int)(resDscp.len % BUFFERLEN);
                        int red     = 0;

                        for (int j = 0; j < time; j++)
                        {
                            if (j != time - 1)
                            {
                                red = mBr.Read(buffer, 0, BUFFERLEN);
                                fso.Write(buffer, 0, BUFFERLEN);
                            }
                            else
                            {
                                red = mBr.Read(buffer, 0, lastLen);
                                fso.Write(buffer, 0, lastLen);
                            }
                        }
                    }

                    fso.Close();
                }
            }
        }
Beispiel #4
0
        public static String GetExtendName(StResourceDscp resDscp)
        {
            String ret = "";

            if (resDscp.type == 0)
            {
                ret = ".jpg";
            }
            else if (resDscp.type == 1)
            {
                ret = ".png";
            }

            return(ret);
        }