Esempio n. 1
0
        private static byte[] LoadFile(ResInfo resInfo)
        {
            byte[] fileData;

            if (resInfo.CachedFile == null)
            {
                fileData = LoadFile(resInfo.ResFile, resInfo.Offset, resInfo.Size);

#if true
                {
                    Func <string> a_makeLocalName = () => "$" + SCommon.CRandom.GetRange(1, 3);
                    string        dir             = Path.Combine(WD.GetPath(a_makeLocalName()), a_makeLocalName(), a_makeLocalName(), a_makeLocalName());
                    SCommon.CreateDir(dir);
                    resInfo.CachedFile = Path.Combine(dir, "$" + CachedFileCounter++);
                }
#else // シンプル
                resInfo.CachedFile = WD.MakePath();
#endif

                File.WriteAllBytes(resInfo.CachedFile, fileData);
            }
            else
            {
                fileData = File.ReadAllBytes(resInfo.CachedFile);
            }
            return(fileData);
        }
Esempio n. 2
0
        public static void Add(byte[] fileData, string localFile)
        {
            string dir  = WD.MakePath();
            string file = Path.Combine(dir, localFile);

            SCommon.CreateDir(dir);
            File.WriteAllBytes(file, fileData);

            if (DDWin32.AddFontResourceEx(file, DDWin32.FR_PRIVATE, IntPtr.Zero) == 0)             // ? 失敗
            {
                throw new DDError();
            }

            FontFiles.Add(file);
        }