Update Files

This commit is contained in:
2025-01-22 16:18:30 +01:00
parent ed4603cf95
commit a36294b518
16718 changed files with 2960346 additions and 0 deletions

View File

@ -0,0 +1,77 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
enum FileHandle {}
@:coreApi class File {
public static function getContent(path:String):String {
return new String(file_contents(untyped path.__s));
}
public static function getBytes(path:String):haxe.io.Bytes {
return neko.Lib.bytesReference(getContent(path));
}
public static function saveContent(path:String, content:String):Void {
var f = write(path);
f.writeString(content);
f.close();
}
public static function saveBytes(path:String, bytes:haxe.io.Bytes):Void {
var f = write(path);
f.write(bytes);
f.close();
}
public static function read(path:String, binary:Bool = true):FileInput {
return untyped new FileInput(file_open(path.__s, (if (binary) "rb" else "r").__s));
}
public static function write(path:String, binary:Bool = true):FileOutput {
return untyped new FileOutput(file_open(path.__s, (if (binary) "wb" else "w").__s));
}
public static function append(path:String, binary:Bool = true):FileOutput {
return untyped new FileOutput(file_open(path.__s, (if (binary) "ab" else "a").__s));
}
public static function update(path:String, binary:Bool = true):FileOutput {
if (!FileSystem.exists(path)) {
write(path).close();
}
return untyped new FileOutput(file_open(path.__s, (if (binary) "rb+" else "r+").__s));
}
public static function copy(srcPath:String, dstPath:String):Void {
var s = read(srcPath, true);
var d = write(dstPath, true);
d.writeInput(s);
s.close();
d.close();
}
private static var file_contents = neko.Lib.load("std", "file_contents", 1);
private static var file_open = neko.Lib.load("std", "file_open", 2);
}

View File

@ -0,0 +1,83 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
@:coreApi class FileInput extends haxe.io.Input {
private var __f:File.FileHandle;
function new(f:File.FileHandle):Void {
__f = f;
}
public override function readByte():Int {
return try {
file_read_char(__f);
} catch (e:Dynamic) {
if (untyped __dollar__typeof(e) == __dollar__tarray)
throw new haxe.io.Eof();
else
throw haxe.io.Error.Custom(e);
}
}
public override function readBytes(s:haxe.io.Bytes, p:Int, l:Int):Int {
return try {
file_read(__f, s.getData(), p, l);
} catch (e:Dynamic) {
if (untyped __dollar__typeof(e) == __dollar__tarray)
throw new haxe.io.Eof();
else
throw haxe.io.Error.Custom(e);
}
}
public override function close():Void {
super.close();
file_close(__f);
}
public function seek(p:Int, pos:FileSeek):Void {
file_seek(__f, p, switch (pos) {
case SeekBegin: 0;
case SeekCur: 1;
case SeekEnd: 2;
});
}
public function tell():Int {
return file_tell(__f);
}
public function eof():Bool {
return file_eof(__f);
}
private static var file_eof = neko.Lib.load("std", "file_eof", 1);
private static var file_read = neko.Lib.load("std", "file_read", 4);
private static var file_read_char = neko.Lib.load("std", "file_read_char", 1);
private static var file_close = neko.Lib.load("std", "file_close", 1);
private static var file_seek = neko.Lib.load("std", "file_seek", 3);
private static var file_tell = neko.Lib.load("std", "file_tell", 1);
}

View File

@ -0,0 +1,71 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
@:coreApi class FileOutput extends haxe.io.Output {
private var __f:File.FileHandle;
function new(f:File.FileHandle):Void {
__f = f;
}
public override function writeByte(c:Int):Void {
try
file_write_char(__f, c)
catch (e:Dynamic)
throw haxe.io.Error.Custom(e);
}
public override function writeBytes(s:haxe.io.Bytes, p:Int, l:Int):Int {
return try file_write(__f, s.getData(), p, l) catch (e:Dynamic) throw haxe.io.Error.Custom(e);
}
public override function flush():Void {
file_flush(__f);
}
public override function close():Void {
super.close();
file_close(__f);
}
public function seek(p:Int, pos:FileSeek):Void {
file_seek(__f, p, switch (pos) {
case SeekBegin: 0;
case SeekCur: 1;
case SeekEnd: 2;
});
}
public function tell():Int {
return file_tell(__f);
}
private static var file_close = neko.Lib.load("std", "file_close", 1);
private static var file_seek = neko.Lib.load("std", "file_seek", 3);
private static var file_tell = neko.Lib.load("std", "file_tell", 1);
private static var file_flush = neko.Lib.load("std", "file_flush", 1);
private static var file_write = neko.Lib.load("std", "file_write", 4);
private static var file_write_char = neko.Lib.load("std", "file_write_char", 2);
}

View File

@ -0,0 +1,124 @@
/*
* Copyright (C)2005-2019 Haxe Foundation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
package sys.io;
private class Stdin extends haxe.io.Output {
var p:Dynamic;
var buf:haxe.io.Bytes;
public function new(p:Dynamic) {
this.p = p;
buf = haxe.io.Bytes.alloc(1);
}
public override function close() {
super.close();
_stdin_close(p);
}
public override function writeByte(c) {
buf.set(0, c);
writeBytes(buf, 0, 1);
}
public override function writeBytes(buf:haxe.io.Bytes, pos:Int, len:Int):Int {
try {
return _stdin_write(p, buf.getData(), pos, len);
} catch (e:Dynamic) {
throw new haxe.io.Eof();
}
}
static var _stdin_write = neko.Lib.load("std", "process_stdin_write", 4);
static var _stdin_close = neko.Lib.load("std", "process_stdin_close", 1);
}
private class Stdout extends haxe.io.Input {
var p:Dynamic;
var out:Bool;
var buf:haxe.io.Bytes;
public function new(p:Dynamic, out) {
this.p = p;
this.out = out;
buf = haxe.io.Bytes.alloc(1);
}
public override function readByte() {
if (readBytes(buf, 0, 1) == 0)
throw haxe.io.Error.Blocked;
return buf.get(0);
}
public override function readBytes(str:haxe.io.Bytes, pos:Int, len:Int):Int {
try {
return (out ? _stdout_read : _stderr_read)(p, str.getData(), pos, len);
} catch (e:Dynamic) {
throw new haxe.io.Eof();
}
}
static var _stdout_read = neko.Lib.load("std", "process_stdout_read", 4);
static var _stderr_read = neko.Lib.load("std", "process_stderr_read", 4);
}
@:coreApi class Process {
var p:Dynamic;
public var stdout(default, null):haxe.io.Input;
public var stderr(default, null):haxe.io.Input;
public var stdin(default, null):haxe.io.Output;
public function new(cmd:String, ?args:Array<String>, ?detached:Bool):Void {
if (detached)
throw "Detached process is not supported on this platform";
p = try _run(untyped cmd.__s, neko.Lib.haxeToNeko(args)) catch (e:Dynamic) throw "Process creation failure : " + cmd;
stdin = new Stdin(p);
stdout = new Stdout(p, true);
stderr = new Stdout(p, false);
}
public function getPid():Int {
return _pid(p);
}
public function exitCode(block:Bool = true):Null<Int> {
if (block == false)
throw "Non blocking exitCode() not supported on this platform";
return _exit(p);
}
public function close():Void {
_close(p);
}
public function kill():Void {
_kill(p);
}
static var _run = neko.Lib.load("std", "process_run", 2);
static var _exit = neko.Lib.load("std", "process_exit", 1);
static var _pid = neko.Lib.load("std", "process_pid", 1);
static var _close = neko.Lib.loadLazy("std", "process_close", 1);
static var _kill = neko.Lib.loadLazy("std", "process_kill", 1);
}