Guest User

Untitled

a guest
Jul 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
OCaml 0.57 KB | None | 0 0
  1. let load name = Dir("root", []) ;;
  2.  
  3. let rec printloop o l = match l with
  4.     | [] -> ()
  5.     | y::ys -> output_string o (y^"\n"); printloop o ys;;
  6.  
  7. let rec store n z =
  8.     let fich = open_out n in
  9.         match z with
  10.             | File(name, y) ->
  11.                 output_string fich "f\n"; output_string fich (name^"\n") ; output_binary_int fich (List.length y) ; printloop fich y
  12.             | Dir(name, y::ys) ->
  13.                 output_string fich "d\n"; output_string fich (name^"\n") ; output_binary_int fich ((List.length (getSub y))+(List.length ys)) ;
  14.                 store n y; store n (Dir(name, ys))
  15.             | _ -> close_out fich;;
Add Comment
Please, Sign In to add comment