Beispiel #1
0
        public byte[] ReadFile(string filename) // 파일 읽기
        {
            filename = filename.Replace(@"\", "/").ToLower();

            string Hash;

            if (FileHash.ContainsKey(filename))
            {
                Hash = FileHash[filename];
            }
            else
            {
                return(new byte[0]);
            }


            CascLib.CascOpenStorage(datapath, 0x200, ref hStorage);

            MemoryStream memstream = new MemoryStream();

            BinaryWriter bytewriter = new BinaryWriter(memstream);
            BinaryReader bytereader = new BinaryReader(memstream);

            byte[] Buffer = new byte[1025];

            CascLib.CascOpenFile(hStorage, Hash, 0, 0x1, ref hfile);

            while ((true))
            {
                IntPtr dwBytesRead = new IntPtr();
                CascLib.CascReadFile(hfile, Buffer, (uint)Buffer.Length, ref dwBytesRead);
                if ((dwBytesRead == new IntPtr()))
                {
                    break;
                }
                bytewriter.Write(Buffer);
            }
            memstream.Position = 0;
            byte[] Bytes = memstream.ToArray();

            CascLib.CascCloseFile(hfile);

            bytereader.Close();
            bytewriter.Close();
            memstream.Close();



            CascLib.CascCloseStorage(hStorage);

            return(Bytes);
        }
Beispiel #2
0
 public bool OpenCascStorage()
 {
     CascLib.CascOpenStorage(datapath, 0x200, ref hStorage);
     return(hStorage.ToInt64() != 0);
 }