Esempio n. 1
0
        /// <summary>
        /// Linux bootstrap.
        /// </summary>
        private static void LinuxSetup()
        {
            // Get the path of the process AKA where the engine was launched from.
            string processPath = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);

            if (processPath == null)
            {
                throw new Exception("Failed to get the process path.");
            }

            // Check if the process path is the current path.
            if (processPath != Environment.CurrentDirectory)
            {
                // Set the current path to the process path.
                Directory.SetCurrentDirectory(processPath);
                Unix.chdir(processPath);

                string processName    = Process.GetCurrentProcess().ProcessName;
                string executableName = processName.Replace(processPath + "/", "");

                Debugger.Log(MessageType.Warning, MessageSource.Engine, "It seems the process directory is not the executable directory. Will restart from correct directory.");
                Debugger.Log(MessageType.Warning, MessageSource.Engine, $"Proper directory is: {processPath}");
                Debugger.Log(MessageType.Warning, MessageSource.Engine, $"Executable is: {executableName}");

                // Stop the debugger so that the new instance can attach itself to the console and perform logging in peace.
                Debugger.Stop();

                // Restart the process.
                Process.Start(executableName)?.WaitForExit();
                Environment.Exit(0);
            }

            // Open libraries.
            Debugger.Log(MessageType.Warning, MessageSource.Engine, $"libsndio.so.6.1 found: {File.Exists("./Libraries/x64/libsndio.so.6.1")}");
            Unix.dlopen("./Libraries/x64/libsndio.so.6.1", Unix.RTLD_NOW);
        }