/* * Copyright (C)2005-2022 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. */ neko(" @sys_exit = $loader.loadprim('std@sys_exit',1); @get_env = $loader.loadprim('std@get_env',1); @get_cwd = $loader.loadprim('std@get_cwd',0); @exe_path = $loader.loadprim('std@sys_exe_path',0); @sys_file_type = $loader.loadprim('std@sys_file_type',1); @sys_read_dir = $loader.loadprim('std@sys_read_dir',1); "); type version { maj : int; min : int; build : int; } function without_extension(s) { match List.rev (String.split s ".") { | [] -> "" | [x] -> x | ext :: l -> String.concat "." (List.rev l) } } function extension(s) { match List.rev (String.split s ".") { | [] | [_] -> "" | ext :: _ -> ext } } function without_dir(s) { var s = String.concat "/" (String.split s "\\"); match List.rev (String.split s "/") { | [] -> assert() | file :: _ -> file } } var array_dependency = Array.make function args() : string array { neko(" @Array.@make($loader.args) "); } function exit(code : int) : 'a { neko(" @sys_exit(code); "); } var exists : string -> bool = neko "$loader.loadprim('std@sys_exists',1)" var version = { var v : int = neko "$version()"; { maj = v / 100; min = (v / 10) % 10; build = v % 10; } } function get_env( s : string ) : string option { var s = neko "@get_env(s)"; if s == neko "null" then None else Some s; } var put_env : string -> string -> void = neko "$loader.loadprim('std@put_env',2)" function get_cwd() : string { neko "@get_cwd()" } var set_cwd : string -> void = neko "$loader.loadprim('std@set_cwd',1)" function executable_path() : string { neko "@exe_path()" } function is_directory(str:string) : bool { neko "@sys_file_type(str) == 'dir'"; } function read_directory(str:string) : string list { neko "@List.@make(@sys_read_dir(str))" }