Last change
on this file since 62 was 42, checked in by fox, 2 years ago |
Preliminary support for cross-domain references
|
File size:
961 bytes
|
Line | |
---|
1 | let text_dir = Filename.concat (File_store.txtdir ()) "peers"
|
---|
2 |
|
---|
3 | type t = { path: string; pack: Header_pack.t }
|
---|
4 |
|
---|
5 | let fold fn init = match Sys.readdir text_dir with
|
---|
6 | | exception (Sys_error msg) -> prerr_endline msg; init
|
---|
7 | | dirs ->
|
---|
8 | let read_pack init path =
|
---|
9 | let fullpath = Filename.concat text_dir path in
|
---|
10 | if Sys.is_directory fullpath then begin
|
---|
11 | let pack_path = Filename.concat fullpath "index.pck" in
|
---|
12 | match Sys.file_exists pack_path with
|
---|
13 | | false -> Printf.eprintf "Missing index.pck for %s\n" path; init
|
---|
14 | | true -> match Header_pack.of_string (File_store.to_string pack_path) with
|
---|
15 | | Error s -> Printf.eprintf "%s %s\n" s pack_path; init
|
---|
16 | | Ok pack -> fn init { path; pack }
|
---|
17 | end else init
|
---|
18 | in
|
---|
19 | Array.fold_left read_pack init dirs
|
---|
20 |
|
---|
21 | let scheme url =
|
---|
22 | let colon_idx = String.index_from url 0 ':' in
|
---|
23 | let scheme = String.sub url 0 colon_idx in
|
---|
24 | (* let remain = String.(sub url (colon_idx+1) (length url - length scheme - 1)) in*)
|
---|
25 | scheme
|
---|
Note:
See
TracBrowser
for help on using the repository browser.