Platform

ceramic.Platform (Class)

A class that encapsulate platform-specific code. We usually want platform-specific code to be located in a backend, but it may happen that sometimes creating a backend interface is overkill. That's where this comes handy.

Platform provides utilities for:

  • Reading assets synchronously from disk
  • Getting platform-specific paths and environment variables
  • Running external commands (including the Ceramic CLI)
  • Electron-specific functionality on web builds
  • Platform detection (e.g., isWindows())
  • Application lifecycle (quit)
  • RTTI access utilities

Most platform-specific code should be in backends, but this class is useful for simple platform-specific operations that don't warrant a full backend interface.

See: Backend

Static Members

postAppInit(): Void

readStringFromAsset(assetPath: String): String

Read a string from an asset file, synchronously. Warning: not available on every targets

Name Type
assetPath String
Returns Description
String String

readBytesFromAsset(assetPath: String): haxe.io.Bytes

Read bytes from an asset file, synchronously. Warning: not available on every targets

Name Type
assetPath String
Returns Description
haxe.io.Bytes String

getAssetsPath(): String

Returns assets paths on disk (if any) Warning: not available on every targets

Returns Description
String String

getRtti(c: Class<getRtti.T>): haxe.rtti.Classdef
Name Type
c Class<getRtti.T>
Returns
haxe.rtti.Classdef

quit(): Void

runCeramic(args: Array<String>, callback: Function): Void

Executes the given Ceramic command asynchronously. This will work only on desktop platforms that have a valid Ceramic installation available. When the app has been launched by Ceramic itself, the same CLI tool will be used. Otherwise, it will look for a ceramic command available in PATH

Name Type Description
args Array<String> (optional) The command arguments, which will be automatically escaped
callback Function The callback, called when the command has finished (or failed)

getEnv(key: String): String
Name Type
key String
Returns
String

isWindows(): Bool
Returns
Bool

exec(cmd: String, ?args: Array<String>, callback: Function): Void

Executes the given command asynchronously

Name Type Default Description
cmd String The command to run
args Array<String> (optional) (optional) The command arguments, which will be automatically escaped
callback Function The callback, called when the command has finished

Private Members