File: sys_js.mli

package info (click to toggle)
js-of-ocaml 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,372 kB
  • sloc: ml: 70,468; javascript: 8,238; ansic: 319; makefile: 217; lisp: 23; sh: 6; perl: 4
file content (70 lines) | stat: -rw-r--r-- 3,110 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(* Js_of_ocaml library
 * http://www.ocsigen.org/js_of_ocaml/
 * Copyright (C) 2014 Hugo Heuzard
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, with linking exception;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *)

(** Javascript specific Sys functions. *)

(** {2 Io.} *)

val set_channel_flusher : out_channel -> (string -> unit) -> unit
(** Set a callback to be called when an out_channel flush its buffer.
      [set_channel_flusher chan cb] install the callback [cb] for [chan] out_channel.
      [cb] will be called with the string to flush. *)

val set_channel_filler : in_channel -> (unit -> string) -> unit
(** Set a callback to be called when an in_channel wants to fill its
      buffer. [set_channel_filler chan cb] install the called [cb] for
      [chan] in_channel. The string returned by [cb] will be appended
      to the channel buffer. *)

(** {2 Pseudo filesystem.} *)

val mount_point : unit -> string list

val unmount : path:string -> unit

val mount : path:string -> (prefix:string -> path:string -> string option) -> unit
(** Register a callback to the [path] to dynamically load missing files.
      Whenever a file is missing in [path], the callback is used to optionally
      get the content of the file.
      [mount ~path f] register the callback [f] to the path [path].
      The callback [f] receives [(prefix,suffix)] where:
       - [prefix] is the path the function has been registered to.
       - [Filename.contact prefix suffix] is the absolute filename .*)

val read_file : name:string -> string
(** [read_file name] returns the content of the file [name].
      Raise [Not_found] if the file does not exists. *)

val create_file : name:string -> content:string -> unit
(** Register a file to a Pseudo Filesystem.
      [create_file ~name ~content] register the file [name] with content [content]
      so it can be be opened with [open_in name] *)

val update_file : name:string -> content:string -> unit
(** Update a file in the Pseudo Filesystem.
      [update_file ~name ~content] update the file [name] with content [content] *)

(** {2 Information.} *)

val js_of_ocaml_version : string
(** [js_of_ocaml_version] is the version of Js_of_ocaml.
      It is a string of the form ["major.minor[.patchlevel][+additional-info]"],
      where [major], [minor], and [patchlevel] are integers, and
      [additional-info] is an arbitrary string. The [[.patchlevel]] and
      [[+additional-info]] parts may be absent. *)