let buffer_size = 4096 let buffer = String.create buffer_size let copy_data fd_in fd_out translate = let rec copy_loop () = match Unix.read fd_in buffer 0 buffer_size with 0 -> () | r -> for i = 0 to r-1 do buffer.[i] <- translate buffer.[i] done; ignore (Unix.write fd_out buffer 0 r); copy_loop () in copy_loop () |