File tree Expand file tree Collapse file tree 3 files changed +29
-17
lines changed
AssetRipper.NativeDialogs Expand file tree Collapse file tree 3 files changed +29
-17
lines changed Original file line number Diff line number Diff line change 88 </PropertyGroup >
99
1010 <ItemGroup >
11- <PackageReference Include =" AssetRipper.Bindings.MacOS" Version =" 1.0.3" />
1211 <PackageReference Include =" GtkSharp" Version =" 3.24.24.117-develop" />
1312 <PackageReference Include =" TerraFX.Interop.Windows" Version =" 10.0.26100.2" />
1413 </ItemGroup >
Original file line number Diff line number Diff line change 1- using AppKit ;
2- using System . Buffers ;
1+ using System . Buffers ;
32using System . Runtime . CompilerServices ;
43using System . Runtime . Versioning ;
54using System . Text ;
@@ -91,20 +90,7 @@ public static class OpenFileDialog
9190 [ SupportedOSPlatform ( "macos" ) ]
9291 private static Task < string ? > OpenFileAsyncMacOS ( OpenFileDialogOptions options )
9392 {
94- NSApplication . Init ( ) ;
95-
96- using NSOpenPanel panel = NSOpenPanel . OpenPanel ;
97- panel . CanChooseFiles = true ;
98- panel . CanChooseDirectories = false ;
99- panel . AllowsMultipleSelection = false ;
100-
101- // Show modally – no need to start a full run‑loop for a simple picker
102- if ( panel . RunModal ( ) == ( int ) NSModalResponse . OK )
103- {
104- return Task . FromResult ( panel . Url ? . Path ) ;
105- }
106-
107- return Task . FromResult < string ? > ( null ) ;
93+ return Task . FromResult ( ProcessExecutor . TryRun ( "osascript" , "-e 'POSIX path of (choose file)" ) ) ;
10894 }
10995
11096 [ SupportedOSPlatform ( "linux" ) ]
Original file line number Diff line number Diff line change 1+ using System . Diagnostics ;
2+
3+ namespace AssetRipper . NativeDialogs ;
4+
5+ internal static class ProcessExecutor
6+ {
7+ public static string ? TryRun ( string command , string arguments )
8+ {
9+ Process p = new ( )
10+ {
11+ StartInfo = new ( )
12+ {
13+ FileName = command ,
14+ Arguments = arguments ,
15+ RedirectStandardOutput = true ,
16+ } ,
17+ } ;
18+ if ( ! p . Start ( ) )
19+ {
20+ return null ;
21+ }
22+
23+ string ? path = p . StandardOutput . ReadLine ( ) ;
24+ p . WaitForExit ( ) ;
25+ return p . ExitCode == 0 ? path : null ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments