Skip to content

Commit d04796f

Browse files
committed
doing things
1 parent 40942f3 commit d04796f

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

source/Main.hx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ import haxe.CallStack;
4141
import 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+
4450
import 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

540583
typedef Boolean = Bool;

source/backend/util/MemoryUtil.hx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

source/backend/window/CppAPI.hx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import backend.window.*;
44

55
class CppAPI
66
{
7-
#if cpp
7+
#if (cpp && (!linux || !mac))
88
public static function obtainRAM():Int
99
{
1010
return WindowsData.obtainRAM();

0 commit comments

Comments
 (0)