You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Fixing up of existing code which used these facilities - this fixes the 'You are attempting to compile on a machine that does not have a supported compiler!' UAT error on machines with really long PATH variables, and exceptions in envvars with non-ASCII characters. #codereview robert.manuszewski [CL 2572445 by Steve Robb in Main branch]
33 lines
893 B
C#
33 lines
893 B
C#
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
|
|
namespace Tools.DotNETCommon.FileSystem
|
|
{
|
|
public static class FileSystem
|
|
{
|
|
[DllImport("kernel32.dll", SetLastError=true)]
|
|
private static extern int GetShortPathName(string pathName, StringBuilder shortName, int cbShortName);
|
|
|
|
public static string GetShortPathName(string Path)
|
|
{
|
|
int BufferSize = GetShortPathName(Path, null, 0);
|
|
if (BufferSize == 0)
|
|
{
|
|
throw new Exception(string.Format("Unable to convert path {0} to 8.3 format", Path));
|
|
}
|
|
|
|
var Builder = new StringBuilder(BufferSize);
|
|
int ConversionResult = GetShortPathName(Path, Builder, BufferSize);
|
|
if (ConversionResult == 0)
|
|
{
|
|
throw new Exception(string.Format("Unable to convert path {0} to 8.3 format", Path));
|
|
}
|
|
|
|
return Builder.ToString();
|
|
}
|
|
}
|
|
}
|