Add vscode detection on macOS
This commit is contained in:
@@ -10,6 +10,9 @@
|
||||
#include "Engine/Platform/Win32/IncludeWindowsHeaders.h"
|
||||
#if PLATFORM_LINUX
|
||||
#include <stdio.h>
|
||||
#elif PLATFORM_MAC
|
||||
#include "Engine/Platform/Mac/MacUtils.h"
|
||||
#include <AppKit/AppKit.h>
|
||||
#endif
|
||||
|
||||
VisualStudioCodeEditor::VisualStudioCodeEditor(const String& execPath, const bool isInsiders)
|
||||
@@ -80,6 +83,33 @@ void VisualStudioCodeEditor::FindEditors(Array<CodeEditor*>* output)
|
||||
return;
|
||||
}
|
||||
}
|
||||
#elif PLATFORM_MAC
|
||||
// System installed app
|
||||
NSURL* AppURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"com.microsoft.VSCode"];
|
||||
if (AppURL != nullptr)
|
||||
{
|
||||
const String path = MacUtils::ToString((CFStringRef)[AppURL path]);
|
||||
output->Add(New<VisualStudioCodeEditor>(path, false));
|
||||
return;
|
||||
}
|
||||
|
||||
// Predefined locations
|
||||
String userFolder;
|
||||
FileSystem::GetSpecialFolderPath(SpecialFolder::Documents, userFolder);
|
||||
String paths[3] =
|
||||
{
|
||||
TEXT("/Applications/Visual Studio Code.app"),
|
||||
userFolder + TEXT("/../Visual Studio Code.app"),
|
||||
userFolder + TEXT("/../Downloads/Visual Studio Code.app"),
|
||||
};
|
||||
for (const String& path : paths)
|
||||
{
|
||||
if (FileSystem::DirectoryExists(path))
|
||||
{
|
||||
output->Add(New<VisualStudioCodeEditor>(path, false));
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -699,8 +699,32 @@ int32 MacProcess(const StringView& cmdLine, const StringView& workingDir, const
|
||||
int32 MacPlatform::StartProcess(const StringView& filename, const StringView& args, const StringView& workingDir, bool hiddenWindow, bool waitForEnd)
|
||||
{
|
||||
// hiddenWindow has hardly any meaning on UNIX/Linux/OSX as the program that is called decides whether it has a GUI or not
|
||||
String cmdLine(filename);
|
||||
if (args.HasChars()) cmdLine = cmdLine + TEXT(" ") + args;
|
||||
|
||||
// Special case if filename points to the app package (use actual executable)
|
||||
String exePath = filename;
|
||||
{
|
||||
NSString* processPath = (NSString*)MacUtils::ToString(filename);
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath: processPath])
|
||||
{
|
||||
NSString* appName = [[processPath lastPathComponent] stringByDeletingPathExtension];
|
||||
processPath = [[NSWorkspace sharedWorkspace] fullPathForApplication:appName];
|
||||
}
|
||||
if ([[NSFileManager defaultManager] fileExistsAtPath: processPath])
|
||||
{
|
||||
if([[NSWorkspace sharedWorkspace] isFilePackageAtPath: processPath])
|
||||
{
|
||||
NSBundle* bundle = [NSBundle bundleWithPath:processPath];
|
||||
if (bundle != nil)
|
||||
{
|
||||
processPath = [bundle executablePath];
|
||||
if (processPath != nil)
|
||||
exePath = MacUtils::ToString((CFStringRef)processPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String cmdLine = String::Format(TEXT("\"{0}\" {1}"), exePath, args);
|
||||
return MacProcess(cmdLine, workingDir, Dictionary<String, String>(), waitForEnd, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user