mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-28 03:23:05 +00:00
Fixed WindowsNative.GetShortPathName to use LibraryImport
Changed comparison method in FormatMessage to use string.IsNullOrEmpty
This commit is contained in:
parent
db68879351
commit
90de1e0fab
2 changed files with 6 additions and 7 deletions
|
@ -108,7 +108,7 @@ namespace Ryujinx.Common.Logging
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
private static string FormatMessage(LogClass logClass, string caller, string message)
|
private static string FormatMessage(LogClass logClass, string caller, string message)
|
||||||
{
|
{
|
||||||
if (_homeDirShort != "")
|
if (!string.IsNullOrEmpty(_homeDirShort))
|
||||||
{
|
{
|
||||||
message = message.Replace(_homeDirShort, _homeDirRedacted);
|
message = message.Replace(_homeDirShort, _homeDirRedacted);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Ryujinx.Common.Utilities
|
namespace Ryujinx.Common.Utilities
|
||||||
{
|
{
|
||||||
public static partial class WindowsNative
|
public static partial class WindowsNative
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
[LibraryImport("kernel32.dll", StringMarshalling = StringMarshalling.Utf16, SetLastError = true)]
|
||||||
static extern int GetShortPathName(string longPath, StringBuilder shortPath, int bufferSize);
|
internal static partial int GetShortPathNameW(string longPath, char[] shortPath, int bufferSize);
|
||||||
|
|
||||||
private const int ShortPathBufferLength = 256;
|
private const int ShortPathBufferLength = 256;
|
||||||
|
|
||||||
|
@ -20,8 +19,8 @@ namespace Ryujinx.Common.Utilities
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder shortPathBuffer = new StringBuilder(ShortPathBufferLength);
|
char[] shortPathBuffer = new char[ShortPathBufferLength];
|
||||||
int result = GetShortPathName(longPath, shortPathBuffer, ShortPathBufferLength);
|
int result = GetShortPathNameW(longPath, shortPathBuffer, shortPathBuffer.Length);
|
||||||
if (result == 0)
|
if (result == 0)
|
||||||
{
|
{
|
||||||
int errCode = Marshal.GetLastWin32Error();
|
int errCode = Marshal.GetLastWin32Error();
|
||||||
|
@ -29,7 +28,7 @@ namespace Ryujinx.Common.Utilities
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return shortPathBuffer.ToString();
|
return new string(shortPathBuffer[..result]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue