aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Common/Utilities/OsUtils.cs
blob: a0791b0924cfd541b0cd11bb7e99f9d29c22cb51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace Ryujinx.Common.Utilities
{
    public partial class OsUtils
    {
        [LibraryImport("libc", SetLastError = true)]
        private static partial int setenv([MarshalAs(UnmanagedType.LPStr)] string name, [MarshalAs(UnmanagedType.LPStr)] string value, int overwrite);

        public static void SetEnvironmentVariableNoCaching(string key, string value)
        {
            // Set the value in the cached environment variables, too.
            Environment.SetEnvironmentVariable(key, value);

            if (!OperatingSystem.IsWindows())
            {
                int res = setenv(key, value, 1);
                Debug.Assert(res != -1);
            }
        }
    }
}