source: code/trunk/src/core/lpath.ml@ 1

Last change on this file since 1 was 1, checked in by fox, 9 years ago

initial simple example with omd

File size: 1012 bytes
RevLine 
[1]1open Fpath
2type repo_t = Repo of t
3type note_t = Note of { repo: repo_t; basename: t }
4
5let fpath_of_repo = function Repo p -> p
6let string_of_repo r = fpath_of_repo r |> to_string
7let repo_of_string s = Repo (v s)
8
9let fpath_of_note = function Note n -> (fpath_of_repo n.repo // n.basename)
10let string_of_note n = fpath_of_note n |> to_string
11let note_of_basename repo s = Note { repo; basename = v s }
12
13let alias_of_note = function Note n -> n.basename |> rem_ext |> to_string
14let note_of_alias repo extension alias = note_of_basename repo (alias ^ extension)
15
16let versioned_basename_of_title ?(version=0) repo extension (title : string) =
17 let notes_fpath = fpath_of_repo repo in
18 let basename = v @@ Meta.string_alias title in
19 let rec next version =
20 let candidate = basename |> add_ext (string_of_int version) |> add_ext extension in
21 if Sys.file_exists (to_string (notes_fpath // candidate))
22 then next (succ version)
23 else note_of_basename repo (to_string candidate)
24 in
25 next version
Note: See TracBrowser for help on using the repository browser.