File tree Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Expand file tree Collapse file tree 3 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ import haxe.CallStack;
4141import haxe .io .Path ;
4242#end
4343
44+ #if sys
45+ import sys .FileSystem ;
46+ import sys .io .Process ;
47+ import haxe .io .BytesOutput ;
48+ #end
49+
4450import backend .Highscore ;
4551
4652// NATIVE API STUFF, YOU CAN IGNORE THIS AND SCROLL //
@@ -535,6 +541,43 @@ class Main extends Sprite
535541 public static function dummy (): Void
536542 {
537543 }
544+
545+ #if sys
546+ // https://github.com/openfl/hxp/blob/master/src/hxp/System.hx
547+ public static function runProcess (command : String , ? args : Array <String >): Null <String > {
548+ var process = new Process (command , args );
549+ var buffer = new BytesOutput ();
550+ var waiting = true ;
551+
552+ while (waiting ) {
553+ try {
554+ var current = process .stdout .readAll (1024 );
555+ buffer .write (current );
556+
557+ if (current .length == 0 )
558+ waiting = false ;
559+ } catch (e ) {
560+ waiting = false ;
561+ }
562+ }
563+
564+ var result = process .exitCode ();
565+ var output = buffer .getBytes ().toString ();
566+ var retVal : Null <String > = output ;
567+
568+ if (output == " " ) {
569+ var error = process .stderr .readAll ().toString ();
570+ process .close ();
571+
572+ if (result != 0 || error != " " )
573+ retVal = null ;
574+ } else {
575+ process .close ();
576+ }
577+
578+ return retVal ;
579+ }
580+ #end
538581}
539582
540583typedef Boolean = Bool ;
Original file line number Diff line number Diff line change @@ -69,9 +69,9 @@ class MemoryUtil {
6969 #if windows
7070 return backend.window.os. Windows .getTotalRam ();
7171 #elseif mac
72- return backend.os. Mac .getTotalRam ();
72+ return backend.window. os. Mac .getTotalRam ();
7373 #elseif linux
74- return backend.os. Linux .getTotalRam ();
74+ return backend.window. os. Linux .getTotalRam ();
7575 #else
7676 return 0 ;
7777 #end
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import backend.window.*;
44
55class CppAPI
66{
7- #if cpp
7+ #if ( cpp && (!linux || !mac))
88 public static function obtainRAM (): Int
99 {
1010 return WindowsData .obtainRAM ();
You can’t perform that action at this time.
0 commit comments