1 | open Logarion
|
---|
2 | let file files =
|
---|
3 | let dirs, files = File_store.split_filetypes files in
|
---|
4 | let _link_as_named dir file = Unix.link file (Filename.concat dir file) in
|
---|
5 | let link_with_id dir file =
|
---|
6 | match File_store.to_text file with Error s -> prerr_endline s
|
---|
7 | | Ok t -> Unix.link file (Filename.concat dir (Text.short_id t^".txt")) in
|
---|
8 | let link = link_with_id in
|
---|
9 | List.iter (fun d -> List.iter (link d) files) dirs
|
---|
10 |
|
---|
11 | let unfile files =
|
---|
12 | let dirs, files = File_store.split_filetypes files in
|
---|
13 | let unlink dir file = try Unix.unlink (Filename.concat dir file)
|
---|
14 | with Unix.(Unix_error(ENOENT,_,_))-> () in
|
---|
15 | List.iter (fun d -> List.iter (unlink d) files) dirs
|
---|
16 |
|
---|
17 | open Cmdliner
|
---|
18 | let term =
|
---|
19 | let files = Arg.(value & pos_all string [] & info []
|
---|
20 | ~docv:"text filenames and subdirectories") in
|
---|
21 | Term.(const file $ files), Term.info "file"
|
---|
22 | ~doc:"file texts in subdirectories"
|
---|
23 | ~man:[ `S "DESCRIPTION"; `P "Files all texts in parameter in every
|
---|
24 | directory in parameter, using hardlinks.
|
---|
25 |
|
---|
26 | Use it to create sub-repositories for sharing or converting" ]
|
---|
27 |
|
---|
28 | let unfile_term =
|
---|
29 | let files = Arg.(value & pos_all string [] & info []
|
---|
30 | ~docv:"text filenames and subdirectories") in
|
---|
31 | Term.(const unfile $ files), Term.info "unfile"
|
---|
32 | ~doc:"unfile texts from subdirectories"
|
---|
33 | ~man:[ `S "DESCRIPTION"; `P "unfile texts in parameter from
|
---|
34 | directories in parameter, by removing hardlinks" ]
|
---|