Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file carton_git_unix.ml
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091openLwt.InfixmoduleStore=structtype'ard=<rd:unit;..>as'atype'awr=<wr:unit;..>as'atype'amode=|Rd:<rd:unit>mode|Wr:<wr:unit>mode|RdWr:<rd:unit;wr:unit>modetypet=Fpath.ttypeuid=Fpath.ttype'afd=Lwt_unix.file_descrtypeerror=[`Not_foundofuid]type+'afiber='aLwt.tletpp_error:errorFmt.t=funppf->function|`Not_founduid->Fmt.pfppf"%a not found"Fpath.ppuidletcreate:typea.mode:amode->t->uid->(afd,error)resultfiber=fun~moderootpath->letflags,perm=matchmodewith|Rd->Unix.[O_RDONLY],0o400|Wr->Unix.[O_WRONLY;O_CREAT;O_APPEND],0o600|RdWr->Unix.[O_RDWR;O_CREAT;O_APPEND],0o600inletpath=Fpath.(root//path)inletprocess()=Lwt_unix.openfile(Fpath.to_stringpath)flagsperm>>=funfd->Lwt.return_okfdinleterror=function|Unix.Unix_error(Unix.EACCES,_,_)->Lwt.return_error(`Not_foundpath)|exn->Lwt.failexninLwt.catchprocesserrorletmap:t->'mrdfd->pos:int64->int->Bigstringaf.t=fun_fd~poslen->letfd=Lwt_unix.unix_file_descrfdinletpayload=Mmap.V1.map_filefd~posBigarray.charBigarray.c_layoutfalse[|len|]inBigarray.array1_of_genarraypayloadletclose_fd=Lwt_unix.closefd>>=fun()->Lwt.return_ok()letlengthfd=Lwt_unix.LargeFile.fstatfd>>=funst->Lwt.returnst.Unix.LargeFile.st_sizeletlistroot=Lwt_unix.opendir(Fpath.to_stringroot)>>=fundh->letrecgoacc=Lwt.catch(fun()->Lwt_unix.readdirdh>>=function|"."|".."->goacc|entry->(matchFpath.of_stringentrywith|Okx->ifFpath.has_ext"pack"xthengo(x::acc)elsegoacc|Error(`Msg_)->(* ignore *)goacc))(functionEnd_of_file->Lwt.returnacc|exn->Lwt.failexn)ingo[]endmoduleMake(Uid:sigincludeCarton.UIDvalof_hex:string->tvalto_hex:t->stringend)=structincludeCarton_git.Make(Carton_lwt.Scheduler)(Lwt)(Store)(Uid)letidx_major_uid_of_uidrootuid=Fpath.(root/Fmt.str"pack-%s.idx"(Uid.to_hexuid))letuid_of_major_uidpath=letstr=Fpath.basename(Fpath.rem_extpath)inmatchAstring.String.cut~sep:"pack-"strwith|Some("",uid)->Uid.of_hexuid|_->Fmt.failwith"Invalid path of major file: %a"Fpath.pppathletmakestore=make~uid_of_major_uid~idx_major_uid_of_uidstoreend