示例#1
0
        private static void FixProcessPermissions(FileLocations.CEFDirs dirs)
        {
            uint attributes = (uint)File.GetAttributes(dirs.subprocessFile);

            attributes |= 0x80000000u;
            File.SetAttributes(dirs.subprocessFile, (FileAttributes)attributes);
        }
示例#2
0
        public static void LoadNative()
        {
            if (NativeLoaded)
            {
                return;
            }
            if (webResources == null)
            {
                StandaloneWebResources standaloneWebResources = new StandaloneWebResources(Application.dataPath + "/Resources/browser_assets");
                standaloneWebResources.LoadIndex();
                webResources = standaloneWebResources;
            }
            int debugPort = (Debug.isDebugBuild ? 9849 : 0);

            FileLocations.CEFDirs dirs = FileLocations.Dirs;
            string fullName            = Directory.GetParent(Application.dataPath).FullName;
            string environmentVariable = Environment.GetEnvironmentVariable("PATH");

            environmentVariable = environmentVariable + ";" + fullName;
            Environment.SetEnvironmentVariable("PATH", environmentVariable);
            StandaloneShutdown.Create();
            try
            {
                zfb_destroyAllBrowsers();
                zfb_setDebugFunc(LogCallback);
                zfb_localRequestFuncs(HeaderCallback, DataCallback);
                zfb_setCallbacksEnabled(enabled: true);
                ZFBInitialSettings zFBInitialSettings = default(ZFBInitialSettings);
                zFBInitialSettings.cefPath                  = dirs.resourcesPath;
                zFBInitialSettings.localePath               = dirs.localesPath;
                zFBInitialSettings.subprocessFile           = dirs.subprocessFile;
                zFBInitialSettings.userAgent                = UserAgent.GetUserAgent();
                zFBInitialSettings.logFile                  = dirs.logFile;
                zFBInitialSettings.debugPort                = debugPort;
                zFBInitialSettings.multiThreadedMessageLoop = 1;
                ZFBInitialSettings settings = zFBInitialSettings;
                foreach (string commandLineSwitch in commandLineSwitches)
                {
                    zfb_addCLISwitch(commandLineSwitch);
                }
                if (!zfb_init(settings))
                {
                    throw new Exception("Failed to initialize browser system.");
                }
                NativeLoaded = true;
            }
            finally
            {
            }
            AppDomain.CurrentDomain.DomainUnload += delegate
            {
                zfb_destroyAllBrowsers();
                zfb_setCallbacksEnabled(enabled: false);
            };
        }
示例#3
0
        private static void FixProcessPermissions(FileLocations.CEFDirs dirs)
        {
            /*
             * The package we get from the Asset Store probably won't have the right executable permissions for
             * ZFGameBrowser for OS X, so let's fix that for the user right now.
             */

            var attrs = (uint)File.GetAttributes(dirs.subprocessFile);

            //From https://github.com/mono/mono/blob/master/mono/io-layer/io.c under SetFileAttributes() (also noted in FileAttributes.cs):
            //"Currently we only handle one *internal* case [...]: 0x80000000, which means `set executable bit'"
            //Let's use that now.
            attrs |= 0x80000000;

            //Make it executable.
            File.SetAttributes(dirs.subprocessFile, unchecked ((FileAttributes)attrs));
        }