From 10ade90dfddef81ed80391ed762bbc3a9f5b85b0 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 1 Mar 2022 16:59:23 -0500 Subject: [PATCH] wip --- src/Tiny_httpd_dir.ml | 23 +++++++++++++++++++++++ src/Tiny_httpd_dir.mli | 16 ++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/Tiny_httpd_dir.ml b/src/Tiny_httpd_dir.ml index c250e9cb..8bf93a66 100644 --- a/src/Tiny_httpd_dir.ml +++ b/src/Tiny_httpd_dir.ml @@ -277,3 +277,26 @@ let add_vfs ~config ~vfs ~prefix server : unit = let add_dir_path ~config ~dir ~prefix server : unit = add_vfs_ ~on_fs:true ~top:dir ~config ~prefix ~vfs:(vfs_of_dir dir) server + +module Embedded_fs = struct + module Str_tbl = Hashtbl.Make(struct + include String + let hash = Hashtbl.hash + end) + + type t = { + entries: entry Str_tbl.t + } [@@unboxed] + + and entry = + | File of { + content: string; + } + | Dir of t + + (* TODO: the rest *) + (* TODO: use util.split_on_slash *) + + +end + diff --git a/src/Tiny_httpd_dir.mli b/src/Tiny_httpd_dir.mli index 183d363c..0361a2bd 100644 --- a/src/Tiny_httpd_dir.mli +++ b/src/Tiny_httpd_dir.mli @@ -130,3 +130,19 @@ val add_vfs : @since NEXT_RELEASE *) +(** An embedded file system, as a list of files with (relative) paths. + This is useful in combination with the "tiny-httpd-mkfs" tool, + which embeds the files it's given into a OCaml module. + + @since NEXT_RELEASE +*) +module Embedded_fs : sig + type t + (** The pseudo-filesystem *) + + val create : unit -> t + + val add_file : t -> path:string -> string -> unit + + val to_vfs : t -> (module VFS) +end