/^
Read string contents from file
^/
func FS.ReadAllText(filesystem, path)
/^
Write string contents to file
^/
func FS.WriteAllText(filesystem, path, contents)
/^
Read bytes from file
^/
func FS.ReadAllBytes(filesystem, path)
/^
Write bytes to file
^/
func FS.WriteAllBytes(filesystem, path, bytes)
/^
Create a crvm archive from fs to strm with name version and info
^/
func FS.CreateArchive(fs, strm, name, version, info)
/^
Extract a crvm archive from strm to vfs
^/
func FS.ExtractArchive(strm, vfs)
/^
Its a field FS.Local with type LocalFilesystem
^/
func FS.getLocal()
/^
returns the current working directory
^/
func FS.getCurrentPath()
/^
set the current working directory
^/
func FS.setCurrentPath(path)
/^
Make absolute path from relative path
^/
func FS.MakeFull(path)
/^
Returns DictionaryEnumerator
^/
func Dictionary.Items(dictordyndict)
/^
Set field in dictionary
^/
func Dictionary.SetField(dict, key, value)
/^
Get field in dictionary
^/
func Dictionary.GetField(dict, key)
/^
Create bytearray but with secure random bytes in it instead of zeros
^/
func Crypto.RandomBytes(byteCount, personalString)
/^
Hash passwords with PBKDF2
shanum:
1: sha1 (please don't)
224: sha224 (please use this)
256: sha256 (vunerable to length extension attack)
384: sha384 (perferably this)
512: sha512 (vunerable to length extension attack)
^/
func Crypto.PBKDF2(pass, salt, itterations, keylen, shanum)
/^
Base64 Encode
^/
func Crypto.Base64Encode(bytes)
/^
Base64 Decode
^/
func Crypto.Base64Decode(str)
/^
Decode JSON String to Object
^/
func Json.Decode(text)
/^
Encode Object to JSON String
pretty: true: make pretty, false: compact
^/
func Json.Encode(obj, $pretty)
/^
Get Environment variable
^/
func Env.GetAt(key)
/^
Set Environment variable
^/
func Env.SetAt(key, value)
/^
Get Desktop Folder
^/
func Env.getDesktop()
/^
Get Downloads Folder
^/
func Env.getDownloads()
/^
Get Documents Folder
^/
func Env.getDocuments()
/^
Get Music Folder
^/
func Env.getMusic()
/^
Get Picture Folder
^/
func Env.getPictures()
/^
Get State Folder
^/
func Env.getState()
/^
Get Cache Folder
^/
func Env.getCache()
/^
Get Config Folder
^/
func Env.getConfig()
/^
Get CrossLang Config Folder
^/
func Env.getCrossLangConfig()
/^
Get Data Folder
^/
func Env.getData()
/^
Get User Folder
^/
func Env.getUser()
/^
Get Current Platform
^/
func Env.getPlatform()
/^
Get the real path for executable
^/
func Env.GetRealExecutablePath(path)
/^
Get the environment path seperator (its a field not a property so it is uncallable)
^/
func Env.getEnvPathSeperator()
/^
example dict
{
FileName = "git",
Arguments = ["clone","https://gitea.site.tesses.net/tesses50/crosslang.git"],
Environment = [],
InheritParentEnvironment=true,
RedirectStandardInput=false,
RedirectStandardOutput=false,
RedirectStandardError=false,
WorkingDirectory="/tmp"
}
returns instance of Process or null if fails
^/
func Process.Start(dict)
/^
Parse Long from String
base: (optional) base of number
returns null if it fails
^/
func ParseLong(str, $base)
/^
Parse Double from String
returns null if it fails
^/
func ParseDouble(str)
/^
Get type of object as String
^/
func TypeOf(o)
/^
Is object defined
^/
func TypeIsDefined(o)
/^
Is object heap
^/
func TypeIsHeap(o)
/^
Is object number
^/
func TypeIsNumber(o)
/^
Is object long
^/
func TypeIsLong(o)
/^
Is object double
^/
func TypeIsDouble(o)
/^
Is object string
^/
func TypeIsString(o)
/^
Is object callable
^/
func TypeIsCallable(o)
/^
Is object a class
^/
func TypeIsClass(o)
/^
Is object a dictionary
^/
func TypeIsDictionary(o)
/^
Is object a list
^/
func TypeIsList(o)
/^
Is object a stream
^/
func TypeIsStream(o)
/^
Is object a vfs
^/
func TypeIsVFS(o)
/^
Is object a datetime
^/
func TypeIsDateTime(o)
/^
Parse version from string,
if TypeIsVersion(textOrVersion) return textOrVersion
^/
func Version.Parse(textOrVersion)
/^
Create version from ByteArray
^/
func Version.FromByteArray(ba, offset)
/^
Create version from long
^/
func Version.FromLong(num)
/^
Load a native plugin, requires a dynamic linker and shared build of libcrosslang
^/
func Reflection.LoadNativePlugin(path)
/^
Get the class info returns ClassInfo
^/
func Class.GetInfo(classInstanceOrClassName)
/^
Get the names of all the loaded classes on root environment
^/
func Class.GetClassNames()
/^
Create instance of class (supports both name and list of name parts split on '.')
^/
func Class.CreateInstance(name, args)
/^
Get the name of the class instance
^/
func Class.Name(instance)
/^
Get the instance specific info, including current values, returns ClassInstanceInfo
^/
func Class.GetInstanceInfo(instance)
/^
Copy Stream to another (but with progress event)
^/
func Helpers.CopyToProgress(src, dest, progressCB, $precision)
/^
Returns instance of SQLiteDatabase
^/
func Sqlite.Open(filename)
/^
Escapes a String, Long or Double (everything else returns NULL)
^/
func Sqlite.Escape(v)
/^
Closes the db
^/
func Sqlite.Close(db)
/^
Returns a string if an error happens
Returns list of dictionaries that the column values are accessed by dictionary keys
^/
func Sqlite.Exec(db, sql)
/^
Get the ip addresses of the machine, pass true if you want ipv6, returns List of schema Net.IPAddress
^/
func Net.getIPAddresses($ipv6)
/^
Send an email
dict looks like this from crosslang's point of view
{
server = {
host = "smtp.example.com",
tls = true,
port = 465 //You can omit this
},
auth = {
username = "from",
password = "THEPASSWORD"
},
domain = "example.com",
from = {
name = "The name shown in the mail where it is from",
email = "from@example.com"
},
to = "to@example.com",
subject = "My little message",
body = {
type = "text/html",
data = "<h1>Hello, world</h1>"
},
attachments = [
{
name = "myimg.png",
type = "image/png",
data = embed("myimg.png")
}
]
}
^/
func Net.Smtp.Send(dict)
/^
Start server with specified port (and block) server is described by Net.Http.Server
^/
func Net.Http.ListenSimpleWithLoop(server, port)
/^
Listen on unused port
^/
func Net.Http.ListenOnUnusedPort(server)
/^
Create a http server (allows multiple)
server schema is Net.Http.Server
^/
func Net.Http.HttpServer(server, portOrUnixPath, $printIPs)
/^
Create a file server
returns schema Net.Http.FileServer
^/
func Net.Http.FileServer(vfs, allowListing, spa)
/^
Create a server you can mount to, must mount parents before child
returns schema Net.Http.MountableServer
^/
func Net.Http.MountableServer(root)
/^
Download file to string
^/
func Net.Http.DownloadToString(url)
/^
Download file to stream
^/
func Net.Http.DownloadToStream(url, strm)
/^
Download file to file
^/
func Net.Http.DownloadToFile(url, vfs, path)
/^
Create a websocket connection
^/
func Net.Http.WebSocketClient(url, headers, conn, $successCB)
/^
Convert text like this: "My page is https://tesses.net/\nExample email is mailto:example@example.com" to "My page is <a href=\"https://tesses.net/\"">https:/tesses.net/</a><br>Example email is <a href=\"mailto:example@example.com\">example@example.com</a>"
for html expressions you can use <plink("Some\nText")> (the string can be dynamic) will become <p>Some<br>Text</p> instead of this function if you want a p tag with the returned value
^/
func Net.Http.HtmlP(text)
/^
Html encode some text (this will be implicit in html expressions)
^/
func Net.Http.HtmlEncode(html)
/^
Encode url query params
^/
func Net.Http.UrlEncode(param)
/^
Decode url query params (this is done implcitly on server ctx.QueryParams)
^/
func Net.Http.UrlDecode(param)
/^
Encode url path
^/
func Net.Http.UrlPathEncode(param)
/^
Decode url path
^/
func Net.Http.UrlDecode(param)
/^
Get mimetype from filename
^/
func Net.Http.MimeType(filename)
/^
Create stream for request body
strm: a stream
mimeType: the mimetype
^/
func Net.Http.StreamHttpRequestBody(strm, mimeType)
/^
Create text for request body
text: some text
mimeType: the mimetype
^/
func Net.Http.TextHttpRequestBody(text, mimeType)
/^
Create json for request body
json: some json
^/
func Net.Http.JsonHttpRequestBody(json)
/^
url: the url of the request
extra: optional (extra parameters for http request schema is: Net.Http.HttpRequestExtra)
returns Net.Http.HttpResponse
extra example
{
Method = "POST",
FollowRedirects = true,
RequestHeaders = [
{Key = "User-Agent", Value = "curl/7.54.1"}
],
Body = Net.Http.JsonHttpRequestBody({MyItem = 5})
}
^/
func Net.Http.MakeRequest(url, $extra)
/^
Get whether terminal is echoing characters read
^/
func Console.getEcho()
/^
Set whether terminal is echoing characters read
^/
func Console.setEcho(flag)
/^
Get whether terminal is buffering line by line (true) or byte by byte (false)
^/
func Console.getCanonical()
/^
Set whether terminal is buffering line by line (true) or byte by byte (false)
^/
func Console.setCanonical(flag)
/^
Get whether terminal is sending signals for CTRL+C (true) or via read (false)
^/
func Console.getSignals()
/^
Set whether terminal is sending signals for CTRL+C (true) or via read (false)
^/
func Console.setSignals(flag)
/^
Clear the console
^/
func Console.Clear()
/^
Write Text To Standard Output
^/
func Console.Write(text)
/^
Write Text To Standard Output with newline
^/
func Console.WriteLine($text)
/^
Write Text To Standard Error
^/
func Console.Error(text)
/^
Write Text To Standard Error with newline
^/
func Console.ErrorLine($text)
/^
Read a byte from stdin
^/
func Console.Read()
/^
Read a line from stdin
^/
func Console.ReadLine()
/^
Fatally stop program (only allowed if you have full permissions) with optional message
^/
func Console.Fatal($error_message)
/^
Get stdin Stream
^/
func Console.getIn()
/^
Get stdout Stream
^/
func Console.getOut()
/^
Get stderr Stream
^/
func Console.getError()
/^
Returns Width and Weight of terminal in cells as dictionary
^/
func Console.getSize()
/^
p: Long 0-100, Double: 0.0-1.0
you must call this everytime you want to update progress
^/
func Console.ProgressBar(p)
/^
Create a Path from string
^/
func Path.FromString(path)
/^
Create a Path from parts
^/
func Path.Create(relative, parts)
/^
Create Absolute Root Path
^/
func Path.Root()
/^
Get root environment as a dictionary
^/
func VM.getRootEnvironmentAsDictionary()
/^
Get root environment, for reflection purposes
^/
func VM.getRootEnvironment()
/^
Get current environment, for reflection purposes
^/
func VM.getCurrentEnvironment()
/^
Create root environment
^/
func VM.CreateEnvironment($dict)
/^
Load a crossvm executable
^/
func VM.LoadExecutable(strm)
/^
Eval source code
^/
func VM.Eval(source)
/^
Compile source code (dict schema is VM.CompileDictionary)
Returns {Success=true} if it succeeds or {Success=false, Reason="Reason String"} if it fails
^/
func VM.Compile(dict)
/^
Get the ast of a program
^/
func VM.SourceToAst(source)
/^
Get the runtime version
^/
func VM.getRuntimeVersion()
/^
Is the program still running
^/
func VM.getIsRunning()
/^
Run an itteration of the event loop
^/
func VM.RunEventLoopItteration()
/^
Run the event loop
^/
func VM.RunEventLoop()
/^
Merge all crvm files into one and returns path inside destVFS of output
You should have srcFS a SubdirFilesystem to directory with executable
so if the source executable was /app/bin/app-1.0.0.0-prod.crvm you should pass a SubdirFilesystem pointing to the directory /app/bin and sourcePath set to /app-1.0.0.0-prod.crvm and destVFS to a empty SubdirFilesystem
^/
func VM.Merge(srcVFS, sourcePath, destVFS)
/^
Disassemble crvm file
^/
func VM.Disassemble(strm, vfs, $generateJSON, $extractResources)
/^
Assemble crvm file
^/
func VM.Assemble(vfs)