This commit is contained in:
Dante
2026-05-21 23:40:20 -07:00
parent 3e2915dff7
commit 877a69d844
5737 changed files with 29796 additions and 1589684 deletions

View File

@ -41,19 +41,41 @@ class FileSystem {
var f = new File(path);
if (!f.exists())
throw "Path " + path + " doesn't exist";
return {
gid: 0, // java doesn't let you get this info
uid: 0, // same
atime: Date.now(), // same
mtime: Date.fromTime(cast(f.lastModified(), Float)),
ctime: Date.fromTime(cast(f.lastModified(), Float)), // same
size: cast(f.length(), Int), // TODO: maybe change to Int64 for Haxe 3?
dev: 0, // FIXME: not sure what that is
ino: 0, // FIXME: not sure what that is
nlink: 0, // FIXME: not sure what that is
rdev: 0, // FIXME: not sure what that is
mode: 0 // FIXME: not sure what that is
};
try {
final pathObject = java.nio.file.Paths.get(path);
final attributes = java.nio.file.Files.readAttributes(pathObject, "unix:*");
return {
atime: Date.fromTime(cast(attributes.get("lastAccessTime").toMillis(), Float)),
ctime: Date.fromTime(cast(attributes.get("creationTime").toMillis(), Float)),
dev: cast(attributes.get("dev"), Int),
gid: attributes.get("gid"),
ino: cast(attributes.get("ino"), Int),
mode: attributes.get("mode"),
mtime: Date.fromTime(cast(attributes.get("lastModifiedTime").toMillis(), Float)),
nlink: attributes.get("nlink"),
rdev: cast(attributes.get("rdev"), Int),
size: cast(attributes.get("size"), Int),
uid: attributes.get("uid"),
};
}
catch (e) {
return {
gid: 0, // java doesn't let you get this info
uid: 0, // same
atime: Date.now(), // same
mtime: Date.fromTime(cast(f.lastModified(), Float)),
ctime: Date.fromTime(cast(f.lastModified(), Float)), // same
size: cast(f.length(), Int), // TODO: maybe change to Int64 for Haxe 3?
dev: 0, // FIXME: not sure what that is
ino: 0, // FIXME: not sure what that is
nlink: 0, // FIXME: not sure what that is
rdev: 0, // FIXME: not sure what that is
mode: 0 // FIXME: not sure what that is
};
}
}
public static function fullPath(relPath:String):String {

View File

@ -75,7 +75,7 @@ class Process {
}
}
return new java.lang.ProcessBuilder(pargs);
return new java.lang.ProcessBuilder(...pargs);
}
public function new(cmd:String, ?args:Array<String>, ?detached:Bool):Void {

View File

@ -0,0 +1,45 @@
package sys.thread;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.Condition as NativeCondition;
@:access(sys.thread.Mutex)
@:coreApi
@:native('haxe.java.vm.Condition')
class Condition {
final lock:ReentrantLock;
final native:NativeCondition;
public function new():Void {
this.lock = new ReentrantLock();
this.native = lock.newCondition();
}
public function acquire():Void {
lock.lock();
}
public function tryAcquire():Bool {
return this.lock.tryLock();
}
public function release():Void {
lock.unlock();
}
// without the @:native, you get "java.lang.VerifyError: class sys.thread.Condition overrides final method java.lang.Object.wait()V" on jvm
// and "wait() in Condition cannot override wait() in Object" from javac
@:native("waitOn")
public function wait():Void {
native.await();
}
public function signal():Void {
native.signal();
}
public function broadcast():Void {
native.signalAll();
}
}

View File

@ -0,0 +1,25 @@
package sys.thread;
import java.util.concurrent.TimeUnit;
@:coreApi
@:native('haxe.java.vm.Semaphore')
class Semaphore {
final native:java.util.concurrent.Semaphore;
public function new(value:Int):Void {
this.native = new java.util.concurrent.Semaphore(value);
}
public function acquire():Void {
native.acquire();
}
public function tryAcquire(?timeout:Float):Bool {
return timeout == null ? native.tryAcquire() : native.tryAcquire(haxe.Int64.fromFloat(timeout * 1000000000),TimeUnit.NANOSECONDS);
}
public function release():Void {
native.release();
}
}